Video frames problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Video frames problem

opencv-users mailing list
Hi all,i am trying to do a demo project using OpenCV and QT.Using cv::namedWindow() and imShow() i can display the individual frames of any video.Then I tried to display the frames on QT by converting it into a pixmap . It worked OK.
Now the frames are displayed on 2 viewports On namedWindow and QT.

Now I want it to display only on QT and not on namedWindow() . To achieve that I commented
the lines namedWindow() and imShow(). But now nothing except last frame is displayed.

The code fragment is as bellow
cv::Mat myframe;
cv::VideoCapture cap(fileName.toStdString());
while(cap.read(myframe))    {       if(myframe.empty())           continue;       // we read the frame       // now we have to analyze it here       // modified frame should be displayed.       cv::resize(myframe,myframe,cv::Size(ui->pic1->width(),ui->pic1->height()));       cv::imshow("output",myframe);       QImage qimgOriginal((uchar*)myframe.data, myframe.cols, myframe.rows, myframe.step, QImage::Format_RGB888);       ui->pic1->setPixmap(QPixmap::fromImage(qimgOriginal));        cv::waitKey(25);       // i++;    }
Where am I doing wrong???any thing i am missing???
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Video frames problem

opencv-users mailing list
Hi all ,I found the solution.
The solution is to put QCoreApplication::processEvents();
inside the loop.Sorry for not knowing the internal working of QT.RegardsBlue.

    On Sunday, June 11, 2017 10:57 PM, "Ashok Shankar Das [hidden email] [OpenCV]" <[hidden email]> wrote:
 

     Hi all,i am trying to do a demo project using OpenCV and QT.Using cv::namedWindow() and imShow() i can display the individual frames of any video.Then I tried to display the frames on QT by converting it into a pixmap . It worked OK.
Now the frames are displayed on 2 viewports On namedWindow and QT.

Now I want it to display only on QT and not on namedWindow() . To achieve that I commented
the lines namedWindow() and imShow(). But now nothing except last frame is displayed.

The code fragment is as bellow
cv::Mat myframe;
cv::VideoCapture cap(fileName.toStdString());
while(cap.read(myframe))    {       if(myframe.empty())           continue;       // we read the frame       // now we have to analyze it here       // modified frame should be displayed.       cv::resize(myframe,myframe,cv::Size(ui->pic1->width(),ui->pic1->height()));       cv::imshow("output",myframe);       QImage qimgOriginal((uchar*)myframe.data, myframe.cols, myframe.rows, myframe.step, QImage::Format_RGB888);       ui->pic1->setPixmap(QPixmap::fromImage(qimgOriginal));        cv::waitKey(25);       // i++;    }
Where am I doing wrong???any thing i am missing???
  #yiv5375738408 #yiv5375738408 -- #yiv5375738408ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv5375738408 #yiv5375738408ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv5375738408 #yiv5375738408ygrp-mkp #yiv5375738408hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv5375738408 #yiv5375738408ygrp-mkp #yiv5375738408ads {margin-bottom:10px;}#yiv5375738408 #yiv5375738408ygrp-mkp .yiv5375738408ad {padding:0 0;}#yiv5375738408 #yiv5375738408ygrp-mkp .yiv5375738408ad p {margin:0;}#yiv5375738408 #yiv5375738408ygrp-mkp .yiv5375738408ad a {color:#0000ff;text-decoration:none;}#yiv5375738408 #yiv5375738408ygrp-sponsor #yiv5375738408ygrp-lc {font-family:Arial;}#yiv5375738408 #yiv5375738408ygrp-sponsor #yiv5375738408ygrp-lc #yiv5375738408hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv5375738408 #yiv5375738408ygrp-sponsor #yiv5375738408ygrp-lc .yiv5375738408ad {margin-bottom:10px;padding:0 0;}#yiv5375738408 #yiv5375738408actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv5375738408 #yiv5375738408activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv5375738408 #yiv5375738408activity span {font-weight:700;}#yiv5375738408 #yiv5375738408activity span:first-child {text-transform:uppercase;}#yiv5375738408 #yiv5375738408activity span a {color:#5085b6;text-decoration:none;}#yiv5375738408 #yiv5375738408activity span span {color:#ff7900;}#yiv5375738408 #yiv5375738408activity span .yiv5375738408underline {text-decoration:underline;}#yiv5375738408 .yiv5375738408attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv5375738408 .yiv5375738408attach div a {text-decoration:none;}#yiv5375738408 .yiv5375738408attach img {border:none;padding-right:5px;}#yiv5375738408 .yiv5375738408attach label {display:block;margin-bottom:5px;}#yiv5375738408 .yiv5375738408attach label a {text-decoration:none;}#yiv5375738408 blockquote {margin:0 0 0 4px;}#yiv5375738408 .yiv5375738408bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv5375738408 .yiv5375738408bold a {text-decoration:none;}#yiv5375738408 dd.yiv5375738408last p a {font-family:Verdana;font-weight:700;}#yiv5375738408 dd.yiv5375738408last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv5375738408 dd.yiv5375738408last p span.yiv5375738408yshortcuts {margin-right:0;}#yiv5375738408 div.yiv5375738408attach-table div div a {text-decoration:none;}#yiv5375738408 div.yiv5375738408attach-table {width:400px;}#yiv5375738408 div.yiv5375738408file-title a, #yiv5375738408 div.yiv5375738408file-title a:active, #yiv5375738408 div.yiv5375738408file-title a:hover, #yiv5375738408 div.yiv5375738408file-title a:visited {text-decoration:none;}#yiv5375738408 div.yiv5375738408photo-title a, #yiv5375738408 div.yiv5375738408photo-title a:active, #yiv5375738408 div.yiv5375738408photo-title a:hover, #yiv5375738408 div.yiv5375738408photo-title a:visited {text-decoration:none;}#yiv5375738408 div#yiv5375738408ygrp-mlmsg #yiv5375738408ygrp-msg p a span.yiv5375738408yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv5375738408 .yiv5375738408green {color:#628c2a;}#yiv5375738408 .yiv5375738408MsoNormal {margin:0 0 0 0;}#yiv5375738408 o {font-size:0;}#yiv5375738408 #yiv5375738408photos div {float:left;width:72px;}#yiv5375738408 #yiv5375738408photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv5375738408 #yiv5375738408photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv5375738408 #yiv5375738408reco-category {font-size:77%;}#yiv5375738408 #yiv5375738408reco-desc {font-size:77%;}#yiv5375738408 .yiv5375738408replbq {margin:4px;}#yiv5375738408 #yiv5375738408ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv5375738408 #yiv5375738408ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv5375738408 #yiv5375738408ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv5375738408 #yiv5375738408ygrp-mlmsg select, #yiv5375738408 input, #yiv5375738408 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv5375738408 #yiv5375738408ygrp-mlmsg pre, #yiv5375738408 code {font:115% monospace;}#yiv5375738408 #yiv5375738408ygrp-mlmsg * {line-height:1.22em;}#yiv5375738408 #yiv5375738408ygrp-mlmsg #yiv5375738408logo {padding-bottom:10px;}#yiv5375738408 #yiv5375738408ygrp-msg p a {font-family:Verdana;}#yiv5375738408 #yiv5375738408ygrp-msg p#yiv5375738408attach-count span {color:#1E66AE;font-weight:700;}#yiv5375738408 #yiv5375738408ygrp-reco #yiv5375738408reco-head {color:#ff7900;font-weight:700;}#yiv5375738408 #yiv5375738408ygrp-reco {margin-bottom:20px;padding:0px;}#yiv5375738408 #yiv5375738408ygrp-sponsor #yiv5375738408ov li a {font-size:130%;text-decoration:none;}#yiv5375738408 #yiv5375738408ygrp-sponsor #yiv5375738408ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv5375738408 #yiv5375738408ygrp-sponsor #yiv5375738408ov ul {margin:0;padding:0 0 0 8px;}#yiv5375738408 #yiv5375738408ygrp-text {font-family:Georgia;}#yiv5375738408 #yiv5375738408ygrp-text p {margin:0 0 1em 0;}#yiv5375738408 #yiv5375738408ygrp-text tt {font-size:120%;}#yiv5375738408 #yiv5375738408ygrp-vital ul li:last-child {border-right:none !important;}#yiv5375738408

   
Loading...