My images are coming in a few milliseconds after another even with a long delay. I am using a for loop with a delay and then I am using other software to convert the type.
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <stdio.h>
#include
#include <string.h>
#include <unistd.h>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
cv::namedWindow(“Capture Example”,cv::WINDOW_AUTOSIZE);
cv::VideoCapture capture(0);
capture.set(CAP_PROP_FRAME_HEIGHT,480);
capture.set(CAP_PROP_FRAME_WIDTH,720);
cout << “helloworld” << endl;
struct timespec start;
struct timespec delay_time = {1,0};
struct timespec remaining_time;
clock_gettime(CLOCK_MONOTONIC, &start);
string filename;
string jpg = ".jpg";
string ppm = ".ppm";
string space = " ";
string command;
cv::Mat frame;
for(int i=0; i<5; i++)
{
bool ret = capture.read(frame);
if(!ret) break;
cv::imshow("Capture Example", frame);
char c = cv::waitKey(33);
if( c == 27 ) break;
filename = "image_";
filename += to_string(i);
cout << "hell world" << filename << endl;
imwrite(filename + jpg, frame);
command = "convert " + filename + jpg + space + filename + ppm;
cout << "shell world" << command << endl;
system(command.c_str());
sleep(3);
//nanosleep(&delay_time, &remaining_time);
}
struct timespec end;
clock_gettime(CLOCK_MONOTONIC, &end);
long time = end.tv_nsec - start.tv_nsec;
cout << “helloworld” << time << endl;
}