c++ - Fast way to convert from cv::Mat to QImage -


i'm wondering if there quick way convert mat qimage. have following class conversion:

videoreader::videoreader() {     cap = videocapture( cv_cap_any ); }  qimage videoreader::getframe() {     if (waitkey(30) >= 0)         return;      mat frame;     cap >> frame;      qimage dest = qimage((uchar*)frame.data, frame.cols, frame.rows, frame.step, qimage::format_rgb888);      return dest; } 

this code works, getframe() method takes 20 milliseconds complete. need working @ least twice fast. there ways optimize this/ alternate conversion methods work quicker?

thanks!

waitkey(30) pause code 30 milliseconds.

this line doesn't make sense in function, should better remove it. creating qimage way should not take more microseconds, because no image copied etc... cap >> frame take time, depending on capturing device (but can't against that).

if need waitkey should use waitkey(1) not waste time there.


Comments