c++ - Show camera image with Qt gives HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP -
i trying see camera on qlabel, cannot see opencv window. after start application there small window created opencv there no image. , in log can see errors:
highgui error: v4l/v4l2: vidioc_s_crop (<unknown>:7534): gtk-warning **: gtk_disable_setlocale() must called before gtk_init() in capture... corrupt jpeg data: 1 extraneous bytes before marker 0xd9 corrupt jpeg data: 1 extraneous bytes before marker 0xd9 corrupt jpeg data: 1 extraneous bytes before marker 0xd9
here simple code :
void mainwindow::on_pushbutton_clicked() { cvcapture* capture = 0; cv::mat frame, framecopy; capture = cvcapturefromcam(cv_cap_any); //0=default, -1=any camera, 1..99=your camera if(!capture) { qdebug() << "no camera detected"; } if( capture ) { qdebug() << "in capture..."; for(;;) { iplimage* iplimg = cvqueryframe( capture ); frame = iplimg; if( frame.empty() ) break; if( iplimg->origin == ipl_origin_tl ) frame.copyto( framecopy ); else flip( frame, framecopy, 0 ); if( cv::waitkey( 10 ) >= 0 ) break; cv::imshow("result", framecopy); } } // cv::waitkey(0); cvreleasecapture(&capture); cvdestroywindow("result"); }
could please give me idea, why highgui error , how solve it?
you getting corrupted data camera. jpeg decoder can not decode it. can try increase duration of cvwaitkey().
i hope works you.
Comments
Post a Comment