如何使用EDSDK捕获同一场景的“相同”RGB图像? [英] How to capture the “same” RGB images for the same scene using EDSDK?

查看:156
本文介绍了如何使用EDSDK捕获同一场景的“相同”RGB图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用EDSDK来控制大炮Eos 7D,用一个固定物体拍照。



我们试图让一切都一样,包括相机位置,光圈, ISO,快门速度,对焦(手动对焦),无闪光灯,并一张接一张地拍照,以确保一切都不会改变。预计我们每次都可以获得接近的RGB图像。



但是我们发现每次捕获时JPG图像都不同。例如,我们计算整个对象块的RGB总和(块位置是固定的,背景是纯黑色 - 零),第一次得到RGB ==(10000,20000,15000),第二次得到(12000, 24000,17000),我们第三次得到(9000,18000,13000)。我们知道拍摄照片时必须有一些小的变化/噪音。但RGB值每次移动很多(差异为-15%到15%),这一定不是噪声(我们猜测它必须是由一些自动调整设置引起的)。



为什么我们得到不同的结果?我们在哪里犯错误?



我们还尝试获取原始格式图像(.CR2),然后使用dcraw.exe将其转换为PPM或TIFF格式,具有相同的转换参数(我们使用-v -k 2400 -S 13000 -W -g 2.222 4.5)。但是图像RGB值每次都移动很多。



下面是我们代码的一些片段(在C#中,有些细节被忽略)。



由于我们的任务是准确计算RGB值,所以这个问题对我们来说非常重要。非常感谢你的帮助!





We use EDSDK to control cannon Eos 7D, for taking picture with one fixed object.

We try to make everything the same, including camera position, aperture, ISO, shutter Speed, focus (manual focusing), no flash lamp, and take picture one after another to make sure everything is not changed. It is expected we can obtain the close RGB images every time.

But then we found the JPG images are diffent every time we capture. For example , we calculate the RGB sum of the whole object block (block position is fixed, background are pure dark -- zeros), first time we get RGB == (10000,20000,15000), second time we get (12000,24000,17000), third time we get(9000, 18000, 13000). We know there must be some little variance/noise when capturing pictures. But the RGB values shifted much every time (-15% to 15% difference), this must be not noise ( we guess it must be caused by some auto adjusting setting).

Why we get the different results? Where do we make mistake?

We also try to get the raw format image (.CR2) , and then use dcraw.exe to transfer it to PPM or TIFF format, with the same tranforming parameter (we use -v -k 2400 -S 13000 -W -g 2.222 4.5 ). But the image RGB values still shifted much every time.

Below are some snippet of our code (in C#, some details are ignored).

Since our task is to calculate the RGB values accurately, so this problem is quite important for us. Thank you very much for your help !


public void main(){

    EDSDK.EdsInitializeSDK();
    EDSDK.EdsGetCameraList(out cameraList);
    EDSDK.EdsGetChildCount(cameraList, out cameraCount);
    EDSDK.EdsGetChildAtIndex(cameraList, 0, out cam);
    EDSDK.EdsGetDeviceInfo(cam, out deviceInfo);
    EDSDK.EdsSetPropertyEventHandler(cam, EDSDK.PropertyEvent_All, propertyEventHandle, inContext);
    ObjectEventHandle = new EDSDK.EdsObjectEventHandler(ObjectEventCallBack);
    EDSDK.EdsSetObjectEventHandler(cam, EDSDK.ObjectEvent_All, ObjectEventHandle, IntPtr.Zero);
    EDSDK.EdsSetCameraStateEventHandler(cam, EDSDK.StateEvent_All, stateEventHandle, inContext);
    EDSDK.EdsOpenSession(cam);

    EDSDK.EdsSetPropertyData(cam, EDSDK.PropID_SaveTo, 0, 4, (uint)EDSDK.EdsSaveTo.Host);
    EDSDK.EdsSetPropertyData(cam, EDSDK.PropID_ImageQuality, 0, 4, (uint)0x0013ff0f);

    EDSDK.EdsSetPropertyData(cam, EDSDK.PropID_Av, 0, 4, (uint)0x58);
    EDSDK.EdsSetPropertyData(cam, EDSDK.PropID_Tv, 0, 4, (uint)0x6b);
    EDSDK.EdsSetPropertyData(cam, EDSDK.PropID_ISOSpeed, 0, 4, (uint)0x48);

    EDSDK.EdsCapacity capacity = default(EDSDK.EdsCapacity);
    capacity.NumberOfFreeClusters = 0x10000000;
    capacity.BytesPerSector = 0x0200;
    capacity.Reset = 1;
    EDSDK.EdsSetCapacity(cam, capacity);

    EDSDK.EdsSendCommand(cam, EDSDK.CameraCommand_TakePicture, 0);


}


    public void DownloadImage(String Path, IntPtr DirItem)
    {
        uint Err = 0;

        EDSDK.EdsDirectoryItemInfo DirInfo;

        Err = EDSDK.EdsGetDirectoryItemInfo(DirItem, out DirInfo);
        if (Err != 0) throw new Exception();

        IntPtr Stream;
        Err = EDSDK.EdsCreateFileStream(Path, EDSDK.EdsFileCreateDisposition.CreateAlways, EDSDK.EdsAccess.ReadWrite, out Stream);
        if (Err != 0) throw new Exception();

        Err = EDSDK.EdsDownload(DirItem, DirInfo.Size, Stream);
        if (Err != 0) throw new Exception();

        Err = EDSDK.EdsDownloadComplete(DirItem);
        if (Err != 0) throw new Exception();

        Err = EDSDK.EdsRelease(Stream);
        if (Err != 0) throw new Exception();

        while (!System.IO.File.Exists(Path))
            Thread.Sleep(100);

    }

   public uint ObjectEventCallBack(uint Event, IntPtr Object, IntPtr Context)
    {
        switch (Event)
        {
            case EDSDK.ObjectEvent_DirItemCreated:
                foreach (EDSFileObject File in Results)
                {
                    if (File.mFileInfo.isFolder == 0)
                    {
                            DownloadImage(Filepath, File.mFilePointer);
                        }
                    }
                }
                break;
        }
        return EDSDKLib.EDSDK.EDS_ERR_OK;
    }

推荐答案

我不认为你在编程时犯了错误。相机传感器是模拟设备,它具有一定的测量精度和一定的噪音。我想说它即使在完全静态的条件下也具有随机数字输出。但是,另外,条件不是完全静态的。尽管你付出了很多努力,场景摇晃(顺便说一句,你是否在整个过程中保持镜子抬起,或者你是否在每次拍摄时来回翻转?不幸的是,在现代相机中,这是可用性问题;例如,在我的相机上,该功能确实存在,但它仍然在包围操作上翻转镜像,这是一个真正的耻辱;我认真地认为即使在最好的相机制造商中也有很多愚蠢)。无论你怎么努力,照明仍然会轻微波动。最后,我不知道你的相机处理是做什么的。你是原始拍摄吗?



我能建议什么?好吧,学会忍受。使您的算法独立于像素的微小变化。尝试统计,尝试制作相同场景的许多镜头并平均差异。不幸的是,我们没有分享您项目的最终目标。如果我认识他们,也许我可以给你一些想法。无论如何,这听起来很有意思!



-SA
I don''t think you do a mistake in programming. The camera sensor is an analog device, it has certain accuracy of measurement and certain noise. I am trying to say that it has randomized digital output even in the perfectly static conditions. But, additionally, the conditions are not perfectly static. Despite of all your efforts, the scene shakes (by the way, do you keep the mirror lifted during the whole process, or do you flip it back and forth on every shot? unfortunately, in modern cameras, this is the usability problem; for example, on my camera, the feature does exist, but it still flips mirror on bracketing operation, which is a real shame; I seriously think there is a lot of stupidity even in best camera manufacturers). And lighting still slightly fluctuates, no matter how hard you try. And, finally, I don''t know what your in-camera processing does. Do you shoot in raw?

What can I suggest? Well, learn to live with that. Make your algorithms independent of small variations in pixels. Experiment with statistics, try to make many shots of identical scene and average out the difference. Unfortunately, we did not share the ultimate goals of your project. Maybe I could give you some ideas if I knew them. Anyway, it sounds interesting!

—SA


这篇关于如何使用EDSDK捕获同一场景的“相同”RGB图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆