How to capture the "same" RGB images for the same scene using EDSDK?

StackOverflow https://stackoverflow.com/questions/16262608

  •  13-04-2022
  •  | 
  •  

Question

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;
    }
Était-ce utile?

La solution

I use EDSDK on 5DmkII and also compare multiple shots. That amount of variance is something I did not encounter. Could you verify that:

  • you have the camera on "Manual" mode -- so no magic auto-adjustments such as exposure in the camera
  • get similar results when using "Continuous Shooting" mode and send press/release events

However, your setup with an LED screen seems problematic. One could experience many artefacts when shooting DLP projectors or LED panels because of their active update nature:

  • get similar (or better) results with a "passive" object and not an LED screen
  • turn off your LED screen
  • use a static image on your LED screen
  • increase shutter time (e.g. 1/10) to prevent temporal-aliasing with LED refresh rate. Decreasing it will give "incomplete" refreshes, but then you could average multiple shots.

Autres conseils

There is certain random noise during the capture. But I think the variance is too high (sometimes more than 15%), which must be not normal for this situation.

The goal of our project is to calibrate the RGB pixels of the LED screen. So the measurement of RGB must be accurate.

Averaging multiple shots of identical scene is one kind of choice, but this may cause a lot of time, and is not the optimal solution used by other LED calibration commercial software.

We have fixed the camera and target LED sceen, also all the light condition is controlled in dark room to keep the light not fluctuated.

I guess the phenomenon may be cause by reasons below:

  1. The pixels of LED changes with time, so is the shutter time long enough to keep the RGB meaturement stable?

We set Aperture 32, Shutter Time 1/60, ISO 100. Could you give some suggestion about the camera parameter setting?

  1. In-camera processing. From the EDSDK API documents, we know that there is PictureStyle and WhiteBalance operation performed in the CR2->JPEG .

We choose the default setting. PictureStyle => Standard, WhiteBalcne => Daylight. Are they correct setting?

  1. Another solution for the second point, as I mentioned in the initial question. We capture with raw format (.CR2), and use dcraw to transform it to PPM or TIFF, the arguments for dcraw (-v -k 2400 -S 13000 -W -g 2.222 4.5), are they enough to keep the output the same?
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top