2

My goal is to save RAW images captured by Canon EOS 70D to a .tif file using the Canon EDSDK 3.4 for a WPF application It has been mentioned that this version provides support for RAW image processing.

From my search I found out that it is not possible to get the image object from the camera so you have to first download the image to the host PC and then try to read the file for further processing and saving the image using the method EdsSaveImage(). This is the code that I have.

       private uint HandleObjectEvent(uint CamEvent, IntPtr direcItem, IntPtr context)
    {
        uint err = EDSDK.EDS_ERR_OK;
        string path;
        if (_cameraCaptureFileName != null)
        {
            path = ConfigFile.ConfigParams[CAMERA_CAPTURE_PATH] + _getBaseDirName(_cameraCaptureFileName);
        }
        else
            path = ConfigFile.ConfigParams[CAMERA_CAPTURE_PATH];

        string timeStamp = DateTime.Now.ToString();
        ThreadPool.QueueUserWorkItem((state) =>
        {
            if (CamEvent == EDSDK.ObjectEvent_DirItemRequestTransfer)
            {
                IntPtr stream = IntPtr.Zero;
                EDSDK.EdsDirectoryItemInfo dirItemInfo;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                err = EDSDK.EdsGetDirectoryItemInfo(direcItem, out dirItemInfo);
                if (_cameraCaptureFileName != null)
                {
                    if (_isFileType(_cameraCaptureFileName, _imageType))
                    {
                        dirItemInfo.szFileName = path + "\\" + _getFileName(_cameraCaptureFileName);
                    }
                    else
                        System.Windows.MessageBox.Show("Filename is not an Image type","File type",
                            System.Windows.MessageBoxButton.OK,System.Windows.MessageBoxImage.Warning);
                }
                else
                {
                    dirItemInfo.szFileName = path + "\\" + dirItemInfo.szFileName;
                }
                err = EDSDK.EdsCreateFileStream(dirItemInfo.szFileName, EDSDK.EdsFileCreateDisposition.CreateAlways,
                    EDSDK.EdsAccess.ReadWrite, out stream);
                err = EDSDK.EdsDownload(direcItem, dirItemInfo.Size, stream);
                err = EDSDK.EdsDownloadComplete(direcItem);
                EDSDK.EdsRelease(stream);
                stream = IntPtr.Zero;

                IntPtr instream = IntPtr.Zero;
                IntPtr imgref = IntPtr.Zero;
                err = EdsCreateFileStream(dirItemInfo.szFileName, EdsFileCreateDisposition.OpenExisting, EdsAccess.Read, out instream);                  
                err = EdsCreateImageRef(instream, out imgref);


            }

        });
        return err;
    }

So In the last section of the code I save an image in .CR2 format on my PC and I try to read this .CR2 file stream using EdsCreateFileStream(dirItemInfo.szFileName, EdsFileCreateDisposition.OpenExisting, EdsAccess.Read, out instream);

and then when I try to use err = EdsCreateImageRef(instream, out imgref);to create an Image object the error code says EDS_ERR_FILE_FORMAT_UNRECOGNIZED. I don't understand why.I can only save the RAW image to .tif or JPEG format if the imgref has some value in it. I tried reading a JPEG file and it was successful. But reading a JPEG is no use to me. Kindly let me know if there is any setting that I should change for this.

The method in the following link is what am trying to do. But it fails. canon SDk Article by Johannes Bildstein

Community
  • 1
  • 1

1 Answers1

-1

The EDS_ERR_FILE_FORMAT_UNRECOGNIZED probably stems from the fact that RAW conversion support in 64 bit support is in beta and only for newer model cameras (~2015 and up). The error message is deceptive, but likely originates from the fact that the dynamic loading of the DPP libraries in the background fail. If you want to convert 70D images, you should re-compile in 32 bits mode.

gdh
  • 498
  • 3
  • 14
  • I just tried the same as the author of this question. I have a 200D and I have exactly the same issue with reading the cr2 file. I compile for x86. I use EDSDK 3.8.0. – marc40000 Sep 20 '18 at 20:55