Commit d58db1aa authored by Benjamin Gallois's avatar Benjamin Gallois

Add licence

parent 5a7d08de
/**
CS-11 Asn 6
motionDetector.cpp
@brief Multi threaded proram that capture image from PiCamera of the
Raspberry and detect movement. If a movement is detected a frame is saved on
the disk.
@author Benjamin Gallois
@version 1.0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <ctime>
#include <iostream>
#include <queue>
......@@ -19,15 +47,18 @@ using namespace cv;
// Global variables
mutex mtx; // Shared queue mutex
mutex analysisMtx; // Shared background substractor object
Mat fgMaskMOG2;
Ptr<BackgroundSubtractor> pMOG2 = createBackgroundSubtractorMOG2();
time_t timeBegin, timeNow;
Mat fgMaskMOG2; // Background
Ptr<BackgroundSubtractor> pMOG2 = createBackgroundSubtractorMOG2(); // subtractor
time_t timeBegin, timeNow; // Global time
/**
* Description: struct that contains the frame extract from the camera
* Member image: image openCV Mat type
* Member timestamp: timestamp of the frame std::string
* @brief Structure that contains the frame extracted from the camera.
*
* @param image: a frame
* @type image: cv::Mat
* @param timestamp: timestamp of the frame
* @type timestamp: std::string
*/
struct frame {
Mat image;
......@@ -36,7 +67,8 @@ struct frame {
/**
* Return the date when it is called
* @brief Return the date when it is called
*
* @return date when it is called formated as dd-mm-YYYY-II-MM-SS
* @type std::string
*/
......@@ -58,13 +90,14 @@ string timestamp ()
/**
* Grab frame from the camera and insert it in a queue
* @param queue FIBO queue
* @brief Grab frame from the camera and insert it in a FIBO queue shared between multiple threads
*
* @param queue: FIBO queue
* @type std::queue
* @param FPS goal framerate
* @type double
* @param duration duration of the detection in seconds
* @type double
* @param FPS: goal framerate that will be reduce automatically if not achievable
* @type FPS: double
* @param duration: number of seconds that the program will be running
* @type duration: double
*/
void grabFrame(queue<frame>& queue, double FPS, double duration){
......@@ -125,11 +158,16 @@ void grabFrame(queue<frame>& queue, double FPS, double duration){
/**
* Grab frame from the camera and insert it in a queue
* @param queue FIBO queue
* @type std::queue
* @param threshold
* @type double
* @brief Take frame in a queue and detect if a movement occurs, if a movement occurs write a frame on the disk. Thread safe.
*
* @param queue: FIBO queue
* @type queue: std::queue
* @param threshold: size of the smaller object that can be detected
* @type threshold: double
* @param path: path to where to write the image on disk
* @type path: std:string
* @param duration: number of seconds that the program will be running
* @type duration: double
*/
void worker(queue<frame>& queue, double threshold, string path, double duration){
......
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