Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

i'm doing a project where i need software triggering for the camera to capture image in every 2 seconds only for entire program.

My project is to detect defects in a solar panel,where solar panels are passed through a conveyor belt on a real time basis.When defective solar panels are found they are rejected . As my camera takes more than 20 frames a second, I don't need that.Instead I need my program to work in the way to capture one single frame at every 2 seconds only.I use opencv3.2 c++ .Here I cite the basic program for a live video .Pls help me with a solution. I use ids usb3.0 camera.

include<opencv2 opencv.hpp="">

include<iostream>

using namespace cv; using namespace std; int main() { Mat CameraFrame; Mat Grey; VideoCapture cap; char keypressed; //Opens the first imaging device. cap.open(0); //Check whether user selected camera is opened successfully. if( !cap.isOpened() ) { cout << "Could not initialize capturing...\n"; return -1; } //Create a windows to display camera preview. namedWindow("Camera Preview", CV_WINDOW_AUTOSIZE); //Loop infinitely to fetch frame from camera and display it. for(;;) { //Fetch frame from camera. cap >> CameraFrame; //Check whether received frame has valid pointer. if( CameraFrame.empty() ) break; //Display the received frame imshow("Camera Preview", CameraFrame); //Wait for Escape keyevent to exit from loop keypressed = (char)waitKey(10); if( keypressed == 27 ) break; } //Release the camera interface. cap.release(); return 0; }

i'm doing a project where i need software triggering for the camera to capture image in every 2 seconds only for entire program.

My project is to detect defects in a solar panel,where solar panels are passed through a conveyor belt on a real time basis.When defective solar panels are found they are rejected . As my camera takes more than 20 frames a second, I don't need that.Instead I need my program to work in the way to capture one single frame at every 2 seconds only.I use opencv3.2 c++ .Here I cite the basic program for a live video .Pls help me with a solution. I use ids usb3.0 camera.

include<opencv2 opencv.hpp="">

include<iostream>

#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main()
{
Mat CameraFrame;
Mat Grey;
VideoCapture cap;
char keypressed;
//Opens the first imaging device.
cap.open(0);
//Check whether user selected camera is opened successfully.
if( !cap.isOpened() )
{
cout << "Could "***Could not initialize capturing...\n";
capturing...***\n";
 return -1;
}
//Create a windows to display camera preview.
namedWindow("Camera Preview", CV_WINDOW_AUTOSIZE);
//Loop infinitely to fetch frame from camera and display it.
for(;;)
{
//Fetch frame from camera.
cap >> CameraFrame;
//Check whether received frame has valid pointer.
if( CameraFrame.empty() )
break;
//Display the received frame
imshow("Camera Preview", CameraFrame);
//Wait for Escape keyevent to exit from loop
keypressed = (char)waitKey(10);
if( keypressed == 27 )
break;
}
//Release the camera interface.
cap.release();
return 0;
}

}