2

I'm a beginner in c++ and canon EDSDK, now I can control the camera to take pictures using the sdk,but I want to save pictures to path c:\photo, I have tried some methods,now the pictures are not saved to camera,but I can't find them in my pc. How should I change my code or what to add?

#include "stdafx.h"
#include "EDSDK.h"
#include "EDSDKErrors.h"
#include "EDSDKTypes.h"
EdsError getFirstCamera(EdsCameraRef *camera);
int _tmain(int argc, _TCHAR* argv[])
{   EdsError err=EDS_ERR_OK;
EdsCameraRef camera=NULL;
bool isSDKloaded=false;
// Initialize SDK
   err=EdsInitializeSDK();
if(err==EDS_ERR_OK)
{
isSDKloaded=true;
}

// Get first camera
if(err==EDS_ERR_OK)
{
err=getFirstCamera(&camera);
}
EdsOpenSession(camera);
EdsInt32 saveTarget = kEdsSaveTo_Host;
err = EdsSetPropertyData( camera, kEdsPropID_SaveTo, 0, 4, &saveTarget );
EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
EdsCloseSession(camera);
EdsTerminateSDK();
return 0;
}



EdsError getFirstCamera(EdsCameraRef *camera)
{
EdsError err=EDS_ERR_OK;
EdsCameraListRef cameraList=NULL;
EdsUInt32 count=0;
// Get camera list
err = EdsGetCameraList(&cameraList);
// Get number of cameras
if(err == EDS_ERR_OK)
{
    err = EdsGetChildCount(cameraList, &count);
    if(count == 0)
    {
        err = EDS_ERR_DEVICE_NOT_FOUND;
    }
}
// Get first camera retrieved
if(err == EDS_ERR_OK)
{
    err = EdsGetChildAtIndex(cameraList , 0 , camera);
}
// Release camera list
if(cameraList != NULL)
{EdsRelease(cameraList);
cameraList = NULL;
}
return err;
}
user2326877
  • 21
  • 1
  • 3
  • 1
    did you check your application folder, generally its save there. also you need to set `host memory` property `EdsCapacity hostMemory` `EDSDK.EdsSetCapacity(Camera, hostMemory)` – Nikson Kanti Paul May 05 '13 at 05:38

1 Answers1

5

I had the same issue a couple of weeks ago. You told the camera that it should store the pictures to the host, but you did not told it how much space is available on the disk. This can by done via

EdsInt32 saveTarget = kEdsSaveTo_Host;
err = EdsSetPropertyData( camera, kEdsPropID_SaveTo, 0, 4, &saveTarget );
EdsCapacity newCapacity = {0x7FFFFFFF, 0x1000, 1};
err = EdsSetCapacity(camera, newCapacity);

In the next step you would have to modify your download function. If you want to download the picture to your host PC you have to deal the following event

kEdsObjectEvent_DirItemRequestTransfer

To specify the download destination on the host PC you can try this:

str_path = " c:\\photo\\Img.jpg";
const char* ch_dest = str_path.c_str();
EdsCreateFileStream( ch_dest ,kEdsFileCreateDisposition_CreateAlways,kEdsAccess_ReadWrite, &stream);

I would like to mention, that the code snipplet above, overwrites the file Img.jpg everytime a shot is triggert.

Cheers TL

TLkuebler
  • 104
  • 1
  • 6