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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -