佳能SDK:下载由两个设备拍摄的最新图片主机 [英] Canon SDK: Download latest picture taken by two devices to host

查看:808
本文介绍了佳能SDK:下载由两个设备拍摄的最新图片主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2010中编写一个基于Windows的应用程序。我的主机连接到两台Canon EOS 600D。到目前为止,我管理两个拍照,直接下载(没有SD卡)到主机PC和存储在主机上的特定名称下的图片。如果我在一个循环中执行我的代码,它也工作正常(循环的索引指定摄像头和目标文件)。在下一步我使用OpenMP2.0加快循环(这是我第一个项目与OpenMP)。现在图像被同时拍摄,但不幸的是,两个图片由相同的消息循环(相机0或相机1)而不是每个任务的相应消息循环来处理。因此,来自相机缓冲区的图片存储在同一个文件中。



如果任何人有一个想法如何摆脱这个问题,这将是巨大的。从我的角度来看,最有利的解决方案是,我告诉消息循环(因为我发现一个是足够的)从哪个线程/相机拍摄的图片。如果我可以避免使用Mutex,这将是巨大的,因为这将减慢我的算法。



这是我的事件处理程序到目前为止,它的工作,但threadNo找到

  EdsError EDSCALLBACK fHandleObjectEvent(EdsObjectEvent事件,EdsBaseRef对象,EdsVoid *上下文){
if {fDownloadImage(object,threadNo}
///对象必须被释放
if(object){EdsRelease(object);}
return EDS_ERR_OK;
}

和我的主要功能

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

编辑1:我刚刚发现,如果我禁用Windows消息循环(引用它),程序显示以下行为:



第一次执行:拍摄2张照片



第二次执行:从上次执行中下载两张照片,新的图片



所以看来,线程号和消息以某种方式存储,并且它在执行中存活,并在下一次执行时重新加载如果主窗口被破坏或者没有损坏)。



编辑2:现在我发现了一个似乎正常工作的解决方案。我通过相机机身的序列号解决了,因此我不得不回到佳能EDSDK版本2.11.3,因为功能 kEdsPropID_BodyIDEx 在版本2.12中禁用。我希望这将有助于其他用户解决类似的任务。



干杯
TL

方案

您应该使用回调的'context'参数来区分两个摄像机。当您使用EdsSetObjectEventHandler注册回调时,只需为每个摄像头传递唯一值作为最后一个参数。


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

解决方案

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.

这篇关于佳能SDK:下载由两个设备拍摄的最新图片主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆