我尝试在 C++ 中添加多标题到 edsdk 开发。但是在“takePictures()”中执行“takeSinglePicture()”时代码卡住了,相机甚至不会拍一张照片。如何解决这个问题。代码在这里。
void CameraControl::takePictures(int n,int time) {
openSession();
CTimer timer;
for (int i = 0; i < n; i++) {
timer.start();
std::cout<<std::this_thread::get_id()<<endl;
takeSinglePicture();
int t = timer.stop();
if (t < time) std::this_thread::sleep_for(std::chrono::milliseconds(time-t));
std::cout << t << std::endl;
}
closeSession();
}
void CameraControl::takePicturesMT(int n,int time) {
std::cout << std::this_thread::get_id() << endl;
std::thread cameraThread([&] {CameraControl::takePictures(n,time); });
cameraThread.join();
}
void CameraControl::takeSinglePicture() {
EdsSendCommand(theCamera, kEdsCameraCommand_PressShutterButton, 1); // Half
EdsSendCommand(theCamera, kEdsCameraCommand_PressShutterButton, 3); // Completely
EdsSendCommand(theCamera, kEdsCameraCommand_PressShutterButton, 0); // Off
}