qt - Introducing a delay in OpenCV::VideoCapture -


i have class camera inheriting cv::videocapture, core method convert cv::mat live stream qimage :

qimage camera::getframe() {     if(isopened()) {         cv::mat image;         (*this) >> image;         cv::cvtcolor(image, image, cv_bgr2rgb);         return qimage((uchar*) image.data, image.cols, image.rows, image.step, qimage::format_rgb888);     }     else return qimage(); } 

and encapsulating class cameradelayedview calls method , adds delay :

void cameradelayedview::timerevent(qtimerevent *evt) {     if(cam != null) {         buffer.enqueue(cam->getframe());          if(buffer.size() > delay*fps) {             setpixmap(qpixmap::fromimage(buffer.dequeue()));         }     } } 

i can see delay of 5seconds initial display of video delayed, after runs smoothly. seems images still somehow linked live feed through pointers (or qqeueue not proper fifo doubt it)... ?

if is, way may give answer other people going through same thing, , interested in efficient way of copying (or more efficient of above code). if not, have no idea what's happening...

thanks in advance.

regards, mister mystère

the feed camera queued in sort of buffer. have struggled problem myself while go, solved using separate thread, takes frames buffer, , if asked sends frame main thread.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -