I try to add multitheading to edsdk development in c++.but the code get stuck when executing "takeSinglePicture()" in "takePictures()" ,and the camera wont even take a single picture.how to fix this.the code is here.
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
}