c++ - cannot convert 'cv::VideoCapture' to 'CvCapture*' -
i have simple program takes video , plays (though image processing on video). video can retrieved dialog box result, or directly giving path of file. when use cv::cvcapture capture1, properties capture1.isopen(), capture1.get(cv_cap_prop_frame_count) etc. when use cvcapture* capture2 weird errors.
i want use cv::cvcapture capture1 because of functions in accordance capture1. or there way use both types kind of conversion between them type casting or else.
actually had 2 programs, functions of program1 cv::cvcapture , functions of program2 cvcapture*. mean 2 programs read video file in different manners.
i merged these 2 programs use functions program1 , functions program2. can't convert cv::cvcapture cvcapture*.
i using opencv qt creator.
my code long post here have simplified code make smaller , understandable. code may not compile correctly because modified make simpler.
any appreciated. in advance :)
void mainwindow::on_pushbutton_clicked() { std::string filename = qfiledialog::getopenfilename(this,tr("open video"), ".",tr("video files (*.mp4 *.avi)")).tostdstring(); cv::videocapture capture1(filename); // when use cv::videocapture capture gives error //error: cannot convert 'cv::videocapture' 'cvcapture*' argument '1' 'iplimage* cvqueryframe(cvcapture*) //cvcapture* capture2 = cvcapturefromcam(-1); // when use cvcapture* capture2, not recognize capture2.isopend() , capture2.get(cv_cap_prop_frame_count) etc. don't work. // there way convert videocapture cvcapture*? if (!capture.isopened()) { qmessagebox msgbox; msgbox.exec(); // messagebox message. not important } cvnamedwindow( name ); iplimage* ximage = cvqueryframe(capture); if (!ximage) { qmessagebox msgbox; msgbox.exec(); } double rate= capture.get(cv_cap_prop_fps); int frames=(int)capture.get(cv_cap_prop_frame_count); int frameno=(int)capture.get(cv_cap_prop_pos_frames); bool stop(false); capture.read(imgsize); cv::mat out(imgsize.rows,imgsize.cols,cv_8sc1); cv::mat out2(imgsize.rows,imgsize.cols,cv_8sc1); //i print frame numbers , total frames on label. ui->label_3->settext(qstring::number(frameno/1000)+" / "+qstring::number(frames/1000)); ui->label->setscaledcontents(true); ui->label->setpixmap(qpixmap::fromimage(img1)); // here show frames on label. }
cv::videocapture c++ interface of opencv, , can used capture camera device , file on disk
cv::videocapture capture1(filename); if (!capture.isopened()) { // failed, print error message } and cvcapturefromcam() function c interface of opencv used capture camera device:
cvcapture* capture2 = cvcapturefromcam(-1); if (!capture2) { // failed, print error message } don't mix/merge interfaces together, pick 1 , stick it.
if want use c interface capture video file, use cvcapturefromfile() instead:
cvcapture* capture = cvcapturefromfile(filename); if (!capture) { // print error, quit application } check these examples:
Comments
Post a Comment