Commit e9af1d9a authored by Benjamin Gallois's avatar Benjamin Gallois

Add command line options

parent 9d1c2012
......@@ -4,6 +4,7 @@
#include <thread>
#include <mutex>
#include <unistd.h>
#include <getopt.h>
#include <experimental/filesystem>
#include <raspicam/raspicam_cv.h>
#include "opencv2/imgcodecs.hpp"
......@@ -60,12 +61,11 @@ string timestamp ()
* @param queue FIBO queue
* @type std::queue
*/
void grabFrame(queue<frame>& queue){
void grabFrame(queue<frame>& queue, double FPS){
// Statistic variables
time_t timer_begin,timer_end;
int imgCount = 0;
double FPS = 25; // Max 25 FPS
// Object initialization
frame frame;
......@@ -156,13 +156,29 @@ void worker(queue<frame>& queue, double threshold){
}
int main(){
int main(int argc, char *argv[]){
experimental::filesystem::create_directories("images/");
int c;
// Default values
int nWorker = 3;
double threshold = 50000;
double FPS = 15;
queue<frame> frameQueue;
double threshold = 50000;
thread t1(grabFrame, ref(frameQueue));
while ((c = getopt(argc, argv, "t:n:f:")) != -1){ // Command line options parsing
switch(c){
case 't':
threshold = atoi(optarg);
case 'n':
nWorker = atoi(optarg);
case 'f':
FPS = atoi(optarg);
}
}
thread t1(grabFrame, ref(frameQueue), FPS);
thread workerPool[nWorker];
for (int i = 0; i < nWorker; i++ ){
workerPool[i] = thread(worker, ref(frameQueue), threshold);
......
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