Commit bc4475c8 authored by Benjamin Gallois's avatar Benjamin Gallois

Code cleaning

parent d58db1aa
/**
CS-11 Asn 6
motionDetector.cpp
@brief Multi threaded proram that capture image from PiCamera of the
@brief Multi threaded program that capture images from the PiCamera of the
Raspberry and detect movement. If a movement is detected a frame is saved on
the disk.
......@@ -131,7 +131,7 @@ void grabFrame(queue<frame>& queue, double FPS, double duration){
mtx.unlock();
//cout << imgCount << " " << queue.size() << endl; // For debugging
if (difftime ( timeNow, timeBegin ) < 120 && queue.size() > 500){ // Automatic FPS adjustment during 2 minutes
if (difftime ( timeNow, timeBegin ) < 240 && queue.size() > 500){ // Automatic FPS adjustment during 4 minutes
FPS -= 1;
cout << "Set fps at: " << FPS << endl;
Camera.release();
......@@ -141,7 +141,7 @@ void grabFrame(queue<frame>& queue, double FPS, double duration){
queue.pop();
}
}
else if ( setup == true && difftime(timeNow, timeBegin) > 120) { // End of adjustment time
else if ( setup == true && difftime(timeNow, timeBegin) > 240) { // End of adjustment time
mtx.lock();
for(int i = 0; i < queue.size(); i++){ // Clear queue to begin the recording
queue.pop();
......@@ -194,7 +194,7 @@ void worker(queue<frame>& queue, double threshold, string path, double duration)
time ( &timeNow );
findContours( fgMaskMOG2, contours, RETR_TREE, CHAIN_APPROX_SIMPLE ); // Find contours in the image
for (unsigned int i = 0; i < contours.size(); i++){
if (difftime ( timeNow, timeBegin ) > 125 && contourArea(contours[i]) > threshold) {
if (difftime ( timeNow, timeBegin ) > 245 && contourArea(contours[i]) > threshold) {
cout << "Detect" << endl;
string name = path + frame.timestamp + ".pgm";
imwrite(name, frame.image);
......@@ -243,7 +243,7 @@ int main(int argc, char *argv[]){
}
}
cout << "Parameters: " << ", threshold: " << threshold << ", worker threads:" <<nWorker << ", fps: "<< FPS << ", path: "<< path << ", duration (seconds)" << stopAfter << endl;
cout << "Beginning of setup time (2 minutes)" << endl;
cout << "Beginning of setup time (4 minutes)" << endl;
const std::experimental::filesystem::path folderPath = path;
experimental::filesystem::create_directories(folderPath);
thread t1(grabFrame, ref(frameQueue), FPS, stopAfter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment