qt - QAbstractVideoSurface generating A Null Image -


i'm reimplemented present method qabstractvideo surface in order capture frames ip camera.

this reimplemented methods (the required ones):

qlist<qvideoframe::pixelformat> cameraframegrabber::supportedpixelformats(qabstractvideobuffer::handletype handletype) const {     q_unused(handletype);     return qlist<qvideoframe::pixelformat>()         << qvideoframe::format_argb32         << qvideoframe::format_argb32_premultiplied         << qvideoframe::format_rgb32         << qvideoframe::format_rgb24         << qvideoframe::format_rgb565         << qvideoframe::format_rgb555         << qvideoframe::format_argb8565_premultiplied         << qvideoframe::format_bgra32         << qvideoframe::format_bgra32_premultiplied         << qvideoframe::format_bgr32         << qvideoframe::format_bgr24         << qvideoframe::format_bgr565         << qvideoframe::format_bgr555         << qvideoframe::format_bgra5658_premultiplied         << qvideoframe::format_ayuv444         << qvideoframe::format_ayuv444_premultiplied         << qvideoframe::format_yuv444         << qvideoframe::format_yuv420p         << qvideoframe::format_yv12         << qvideoframe::format_uyvy         << qvideoframe::format_yuyv         << qvideoframe::format_nv12         << qvideoframe::format_nv21         << qvideoframe::format_imc1         << qvideoframe::format_imc2         << qvideoframe::format_imc3         << qvideoframe::format_imc4         << qvideoframe::format_y8         << qvideoframe::format_y16         << qvideoframe::format_jpeg         << qvideoframe::format_cameraraw         << qvideoframe::format_adobedng; }  bool cameraframegrabber::present(const qvideoframe &frame) {         //qwarning() << "a frame";     if (frame.isvalid()) {         //qwarning() << "valid frame";         qvideoframe cloneframe(frame);         cloneframe.map(qabstractvideobuffer::readonly);         const qimage image(cloneframe.bits(),                            cloneframe.width(),                            cloneframe.height(),                            qvideoframe::imageformatfrompixelformat(cloneframe .pixelformat()));          qwarning() << "is created image null?" << image.isnull();          if (!image.isnull())             emit nextframeasimage(image);          cloneframe.unmap();         return true;     }     return false; } 

and is how used it:

grabber = new cameraframegrabber(this); connect(grabber,&cameraframegrabber::nextframeasimage,this,&qcmaratest::on_newframe);  qmediaplayer *a = new qmediaplayer(this); qstring url = "http://admin:1234@10.255.255.67:8008"; a->setmedia(qurl(url)); a->setvideooutput(grabber); a->play(); 

the problem image created null. far can tell, can because frame valid not contain data.

any ideas problem be?

important detail: if set stream qvideowidget , show that, works fine.

so found out problem was.

this: qvideoframe::imageformatfrompixelformat(cloneframe .pixelformat())

was returning invalid format because ip cam gave format yuv format qimage can't handle. solution force format , 1 found did not make program crash was: qimage::format_grayscale8.

with that, worked.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -