Canon SDK: Download latest picture taken by two de

2019-08-11 02:17发布

I'm writing an windows based application in Visual Studio 2010. My host PC is connected to two Canon EOS 600D. So far I managed two take a picture, download it directly (without a SD card) to the host PC and store the pictures under a specific name on the host. If I execute my code in a loop, it also works fine (the index of the loop specifies the camera and the destination file). In a next step I used OpenMP2.0 to speed up the loop (this is my first project with OpenMP). Now the pictures are taken simultaneously, but unfortunaly both pictures are handled by the same message loop (either camera 0 or camera 1) instead of the corresponding message loop of each task. As a result, the pictures from the camera buffer are stored in the same file.

It would be great if anyone has an idea how to get rid of this issue. The most favorable solution from my point of view would be, that I tell the message loop (since I found out that one is enough) from which thread/camera the picture has been taken. It would also be great if I could avoid using a Mutex since this would slow down my algorithm.

This is my Event handler so far, it works, but the threadNo has to be found

EdsError EDSCALLBACK fHandleObjectEvent( EdsObjectEvent event,EdsBaseRef object,EdsVoid * context){
  if(event){fDownloadImage(object,threadNo}
  /// Object must be released
  if(object){EdsRelease(object);}
  return EDS_ERR_OK;
}

And my main-function

int main(int argc, char** argv){
  #pragma omp parallel for
  for(int ii=0;ii<2;ii++){
    fTakePicture(ii);
  }
  return 0;
}

Thanks in advance.

Edit 1: I just found out, that if I disable the windows message loop (quote it out) the program shows the following behavior:

1st execution: take 2 pictures

2nd execution: download the two pictures form previous execution, take 2 new pictures

So it seems that, the thread number and the message is stored in some way and that it survives the execution and its reloaded in the next execution (doesn't matter if main window is destroyed or not). So I have to get it into the right order.

Edit 2: Now I found a solution which seems to work properly. I solved it via the Serial No. of the camera body, but therefore I had to go back to Canon EDSDK Version 2.11.3 since the feature kEdsPropID_BodyIDEx is disabled in Version 2.12. I hope this will help other users to solve similar tasks.

Cheers TL

1条回答
狗以群分
2楼-- · 2019-08-11 02:52

You should differentiate the two cameras using the 'context' parameter of the callback. Simply pass unique values for each camera as the last parameter when you register the callback with EdsSetObjectEventHandler.

查看更多
登录 后发表回答