add more log for debug info + last frame keeping
This commit is contained in:
@ -9,6 +9,8 @@
|
|||||||
#include "opencv2\opencv.hpp"
|
#include "opencv2\opencv.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
|
||||||
using namespace GS;
|
using namespace GS;
|
||||||
using namespace GS::Script;
|
using namespace GS::Script;
|
||||||
@ -36,10 +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;
|
||||||
|
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();
|
||||||
@ -57,9 +61,12 @@ void ProcessWebcamThread::Execute() {
|
|||||||
if (temp_pause || !temp_record_frame)
|
if (temp_pause || !temp_record_frame)
|
||||||
Platform::Get().Sleep(10);
|
Platform::Get().Sleep(10);
|
||||||
else{
|
else{
|
||||||
InputVideo->read(*im);
|
|
||||||
outputVideo->write(*im);
|
|
||||||
|
|
||||||
|
InputVideo->read(*im);
|
||||||
|
|
||||||
|
__LOG_CAM__ << "Record frame clock: " << (float)current_frame_clock << "at index: "<< frame_index<<"\n";
|
||||||
|
outputVideo->write(*im);
|
||||||
|
frame_index++;
|
||||||
lutFile.write(reinterpret_cast<const char*>(¤t_frame_clock),sizeof(float));
|
lutFile.write(reinterpret_cast<const char*>(¤t_frame_clock),sizeof(float));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,6 +324,8 @@ void Webcam::Close() {
|
|||||||
|
|
||||||
uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index) {
|
uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index) {
|
||||||
//create buffer from lut
|
//create buffer from lut
|
||||||
|
bool is_the_last_record = record_index == index_save_video - 1 ;
|
||||||
|
|
||||||
if(video_times.size() == 0){
|
if(video_times.size() == 0){
|
||||||
//charger lut dans video_times
|
//charger lut dans video_times
|
||||||
__LOG_CAM__ << "Chargement LUT: "<<record_name<<"_"<<record_index<<"_lut.bin\n";
|
__LOG_CAM__ << "Chargement LUT: "<<record_name<<"_"<<record_index<<"_lut.bin\n";
|
||||||
@ -327,7 +336,6 @@ uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index)
|
|||||||
if (!lutFile.is_open())
|
if (!lutFile.is_open())
|
||||||
{
|
{
|
||||||
__LOG_CAM__ << "Cannot open LUT file: " << record_name<<"_lut.bin\n";
|
__LOG_CAM__ << "Cannot open LUT file: " << record_name<<"_lut.bin\n";
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
video_times.clear();
|
video_times.clear();
|
||||||
|
|
||||||
@ -340,6 +348,7 @@ uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index)
|
|||||||
|
|
||||||
lutFile.seekg(size - static_cast<std::streamoff>(sizeof(float)));
|
lutFile.seekg(size - static_cast<std::streamoff>(sizeof(float)));
|
||||||
lutFile.read(reinterpret_cast<char*>(&end_time), sizeof(float));
|
lutFile.read(reinterpret_cast<char*>(&end_time), sizeof(float));
|
||||||
|
|
||||||
__LOG_CAM__ <<"end: "<<(float)end_time<<" asked clock: "<<clock<<"\n";
|
__LOG_CAM__ <<"end: "<<(float)end_time<<" asked clock: "<<clock<<"\n";
|
||||||
//read la derniere et premiere clock
|
//read la derniere et premiere clock
|
||||||
lutFile.seekg(0);
|
lutFile.seekg(0);
|
||||||
@ -352,7 +361,7 @@ uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index)
|
|||||||
lutFile.close();
|
lutFile.close();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if(clock > end_time){
|
else if(clock > end_time && !is_the_last_record){
|
||||||
__LOG_CAM__ << "clock > end_time\n";
|
__LOG_CAM__ << "clock > end_time\n";
|
||||||
lutFile.close();
|
lutFile.close();
|
||||||
return SetFrame(clock,record_name,record_index+1); //recursive search forward
|
return SetFrame(clock,record_name,record_index+1); //recursive search forward
|
||||||
@ -383,7 +392,8 @@ uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
//force reset if clock not in range
|
//force reset if clock not in range
|
||||||
if(clock < video_times[0] || clock > video_times[video_times.size() -1]){
|
if(clock < video_times[0] || (clock > video_times[video_times.size() -1] && !is_the_last_record)){
|
||||||
|
__LOG_CAM__ << "CLEAR \n";
|
||||||
video_times.clear();
|
video_times.clear();
|
||||||
return SetFrame(clock, record_name , 0);
|
return SetFrame(clock, record_name , 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,6 +71,7 @@ private:
|
|||||||
|
|
||||||
int index_save_video;
|
int index_save_video;
|
||||||
int index_replay_video;
|
int index_replay_video;
|
||||||
|
|
||||||
std::vector<float> video_times;
|
std::vector<float> video_times;
|
||||||
cv::VideoCapture *ReplayInputVideo;
|
cv::VideoCapture *ReplayInputVideo;
|
||||||
cv::Mat* ReplayIm;
|
cv::Mat* ReplayIm;
|
||||||
|
|||||||
Reference in New Issue
Block a user