diff --git a/source/webcam.cpp b/source/webcam.cpp index 8f82bc7..f6f4f2d 100644 --- a/source/webcam.cpp +++ b/source/webcam.cpp @@ -38,12 +38,12 @@ void ProcessWebcamThread::Execute() { bool temp_not_finish = true; bool temp_pause = true; bool temp_record_frame = false; + float frame_clock = 0.0f; current_frame_clock = 0.0; //construction LUT pour synchro avec la clock squirrel std::ofstream lutFile(outputVideoName+"_lut.bin", std::ios::binary); __LOG_CAM__ << "NEW RECORDING THREAD "<grab()) { + Platform::Get().Sleep(10); + continue; + } + mutex_record_frame.Lock(); temp_record_frame = record_frame; + frame_clock = current_frame_clock; + record_frame = false; mutex_record_frame.Unlock(); - if (temp_pause || !temp_record_frame) - Platform::Get().Sleep(10); - else{ - InputVideo->read(*im); - outputVideo->write(*im); - - lutFile.write(reinterpret_cast(¤t_frame_clock),sizeof(float)); + if (!temp_pause && temp_record_frame) { + if (InputVideo->retrieve(*im)) { + outputVideo->write(*im); + lutFile.write(reinterpret_cast(&frame_clock), sizeof(float)); + } } } __LOG_CAM__ << "THREAD STOPPED "<open(id_devices[i]); + // CAP_DSHOW : meme ordre d'enumeration que la blacklist DirectShow ci-dessus + // et pas de waitlist interne qui prend du retard + InputVideo->open(id_devices[i] + CAP_DSHOW); if(InputVideo->isOpened()){ device_id = id_devices[i]; break; - } + } }