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

Discussion in 'Digital Photography' started by azuring, Apr 28, 2013.

  1. azuring

    azuring Guest

    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 wecan 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 !

    ############ C# code #########################################


    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;
    }
     
    azuring, Apr 28, 2013
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.