Ask Your Question
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.

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

Ashiq KS gravatar image

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

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;
   }
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-03-07 05:09:20 -0600

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-03-06 22:16:23 -0600

Seen: 535 times

Last updated: Mar 07 '17