Compare commits
1 Commits
7b7d32d22c
...
64bits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea9b0d3e4a |
@ -38,12 +38,12 @@ void ProcessWebcamThread::Execute() {
|
|||||||
bool temp_not_finish = true;
|
bool temp_not_finish = true;
|
||||||
bool temp_pause = true;
|
bool temp_pause = true;
|
||||||
bool temp_record_frame = false;
|
bool temp_record_frame = false;
|
||||||
|
float frame_clock = 0.0f;
|
||||||
current_frame_clock = 0.0;
|
current_frame_clock = 0.0;
|
||||||
//construction LUT pour synchro avec la clock squirrel
|
//construction LUT pour synchro avec la clock squirrel
|
||||||
std::ofstream lutFile(outputVideoName+"_lut.bin", std::ios::binary);
|
std::ofstream lutFile(outputVideoName+"_lut.bin", std::ios::binary);
|
||||||
__LOG_CAM__ << "NEW RECORDING THREAD "<<videoIndex<<" LAUNCHED \n";
|
__LOG_CAM__ << "NEW RECORDING THREAD "<<videoIndex<<" LAUNCHED \n";
|
||||||
|
|
||||||
int frame_index = 0;
|
|
||||||
while (temp_not_finish) {
|
while (temp_not_finish) {
|
||||||
|
|
||||||
mutex_not_finish.Lock();
|
mutex_not_finish.Lock();
|
||||||
@ -54,17 +54,25 @@ void ProcessWebcamThread::Execute() {
|
|||||||
temp_pause = pause;
|
temp_pause = pause;
|
||||||
mutex_pause.Unlock();
|
mutex_pause.Unlock();
|
||||||
|
|
||||||
|
// Drainer la camera en permanence, meme en pause : si on lit pas, la file
|
||||||
|
// du driver grossit et les frames récupéres ensuite dates du passé, ce qui
|
||||||
|
// decale la video par rapport a la clock (derive qui s'accumule)
|
||||||
|
if (!InputVideo->grab()) {
|
||||||
|
Platform::Get().Sleep(10);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_record_frame.Lock();
|
mutex_record_frame.Lock();
|
||||||
temp_record_frame = record_frame;
|
temp_record_frame = record_frame;
|
||||||
|
frame_clock = current_frame_clock;
|
||||||
|
record_frame = false;
|
||||||
mutex_record_frame.Unlock();
|
mutex_record_frame.Unlock();
|
||||||
|
|
||||||
if (temp_pause || !temp_record_frame)
|
if (!temp_pause && temp_record_frame) {
|
||||||
Platform::Get().Sleep(10);
|
if (InputVideo->retrieve(*im)) {
|
||||||
else{
|
outputVideo->write(*im);
|
||||||
InputVideo->read(*im);
|
lutFile.write(reinterpret_cast<const char*>(&frame_clock), sizeof(float));
|
||||||
outputVideo->write(*im);
|
}
|
||||||
|
|
||||||
lutFile.write(reinterpret_cast<const char*>(¤t_frame_clock),sizeof(float));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__LOG_CAM__ << "THREAD STOPPED "<<videoIndex<<"\n";
|
__LOG_CAM__ << "THREAD STOPPED "<<videoIndex<<"\n";
|
||||||
@ -251,11 +259,13 @@ bool Webcam::Open(int width_, int height_) {
|
|||||||
int device_id = -1;
|
int device_id = -1;
|
||||||
for (int i = 0; i < id_devices.size(); i++)
|
for (int i = 0; i < id_devices.size(); i++)
|
||||||
{
|
{
|
||||||
InputVideo->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()){
|
if(InputVideo->isOpened()){
|
||||||
device_id = id_devices[i];
|
device_id = id_devices[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user