How do I solve Handle_Error canon EDSDK Error 97/61?

20 views Asked by At

So I am trying to download the latest picture I took, but I keep getting error code 97, which is 61 in hex. I looked it up in the EDSDKErrors.h and it seems to be a handle error. I don't know how to resolve this error so all the help and suggestions are welcome :).

const EdsChar *fileName = "Photos/Testt.jpg";
void download_img(EdsDirectoryItemRef object)
{
    EdsError err = EDS_ERR_OK;
    EdsStreamRef stream = NULL;
    EdsDirectoryItemInfo dirItemInfo;
    if (err == EDS_ERR_OK)
    {
        err = EdsCreateFileStream(fileName, kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream);
    }

    // Download image
    if (err == EDS_ERR_OK)
    {
        std::cout << "download started" << std::endl;
        err = EdsDownload(object, dirItemInfo.size, stream);
    }
    std::cout << std::hex << err << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds (5));
    // Issue notification that download is complete
    if (err == EDS_ERR_OK)
    {
        std::cout << "download complete" << std::endl;
        err = EdsDownloadComplete(object);
    }

    // Release stream
    if (stream != NULL)
    {
        EdsRelease(stream);
        stream = NULL;
    }
}


EdsError EDSCALLBACK handleObjectEvent(EdsObjectEvent event, EdsBaseRef object, EdsVoid * context)
{
    download_img(object);
    return EDS_ERR_OK;
}

void init_camera(EdsCameraRef & camera)
{
    EdsError err = EDS_ERR_OK;
    EdsCameraListRef cameraList = NULL;
    EdsUInt32 count = 0;
    camera = NULL;

    err = EdsInitializeSDK();
    err = EdsGetCameraList(&cameraList);
    err = EdsGetChildCount(cameraList, &count);
    if (count > 0)
    {
        err = EdsGetChildAtIndex(cameraList, 0, &camera);
        EdsRelease(cameraList);
    }
    EdsSetObjectEventHandler(camera, kEdsObjectEvent_DirItemCreated, handleObjectEvent, NULL);
    EdsSendStatusCommand(camera, kEdsCameraStatusCommand_UIUnLock, 0);
    EdsSendStatusCommand(camera, kEdsCameraStatusCommand_EnterDirectTransfer, 0);
}

void take_photo(EdsCameraRef camera, int count, int interv_millsec)
{
    for (int i = 0; i < count; ++i) {
        EdsOpenSession(camera);
        EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
        download_img(camera);
        std::this_thread::sleep_for(std::chrono::milliseconds(interv_millsec));
        EdsCloseSession(camera);
    }
}

and this is my main:

int main (){
    EdsCameraRef camera;
    std::cout <<"initialized" << std::endl;
    init_camera(camera);
    take_photo(camera, 1,100);
    std::cout <<"pic made" << std::endl;
    dispose(camera);
    return 0;
}

I tried to add delays and change the inDiItemRef, but nothing seems to work like I want it to. The furthest I got was to download the second latest picture, which is not what I want.

0

There are 0 answers