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

asked 2017-03-06 22:16:23 -0500

Ashiq KS gravatar image

updated 2017-03-07 00:40:24 -0500

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.

using namespace cv;
using namespace std;
int main()
    Mat CameraFrame;
    Mat Grey;
 VideoCapture cap;
    char keypressed;
  //Opens the first imaging device.
  //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.
   //Fetch frame from camera.
   cap >> CameraFrame;
  //Check whether received frame has valid pointer.
   if( CameraFrame.empty() )
  //Display the received frame
   imshow("Camera Preview", CameraFrame);
 //Wait for Escape keyevent to exit from loop
   keypressed = (char)waitKey(10);
   if( keypressed == 27 )
 //Release the camera interface.
 return 0;
edit retag flag offensive close merge delete



This is not an opencv, or even computer vision problem. You need to implement a timer, start the timer when you start the camera, and after two seconds update image and reset timer to 0.

Pedro Batista gravatar imagePedro Batista ( 2017-03-07 05:09:20 -0500 )edit