Strange Problem

88 views
Skip to first unread message

mahmoud sherif

unread,
Oct 8, 2014, 8:56:30 PM10/8/14
to easycap-so...@googlegroups.com
I build the new kernel repo from here https://github.com/jonjonarnearne/smi2021 with success ,I got /dev/video0 device.I tested the easycap with mplayer and the frames are smoth. I have writen a program in opencv to do some image processing and here is an abstract of the program :

int main() {
 
VideoCapture cap(1); // open the video file for reading
if ( !cap.isOpened() )  // if not success, exit program
{
 cout
<< "Cannot open the video file" << endl;
 
return -1;
}


namedWindow
("MyVideo",CV_WINDOW_AUTOSIZE);


while(1)
{
 
Mat frame;


 
bool bSuccess = cap.read(frame); // read a new frame from video or cap >> frame;


 
if (!bSuccess) //if not success, break loop
 
{
 cout
<< "Cannot read the frame from video file" << endl;
 
break;
 
}

 
//Do Image processing here
 

 imshow
("MyVideo", frame); //show the frame in "MyVideo" window


 
if(waitKey(300) == 27) //wait for 'esc' key press for 300 ms. If 'esc' key is pressed, break loop
 
{
 cout
<< "esc key is pressed by user" << endl;
 
break;
 
}
}
cap
.release();
return 0;
}

waitkey(300) ----> 300 ms is the wait time to get a new frame 
the problem is that when this time is small such as 10 or 30 ms frames are fine and smooth, but when this time is large such as 300 ms some frames are crappy as in this picture(time between crappy frames is 2s or more):

The Normal Frame is like this:

Note: the reason I set large delay is that the processing I'am Doing take more than 300ms
Thanks all in advance :) and sorry for my bad English

Reply all
Reply to author
Forward
0 new messages