c++ - convert Qimage to cvMat 64FC3 format -


i have searched lot on internet have found how convert qimage rgb format, want convert qimage cv mat format cv_64fc3. have bad results when work cv_8uc3

here code :

qimage myimage; myimage.load("c://images//polarimage300915163358.bmp");  qlabel mylabel; mylabel.setpixmap(qpixmap::fromimage(myimage));  //mylabel.show();  cv::mat image1 = qimage2mat(myimage);    mat img;  image1.convertto(img, cv_64fc3, 1.0 / 255.0); 

and here function used :

cv::mat qimage2mat(qimage const& src) {      cv::mat tmp(src.height(),src.width(),cv_8uc3,(uchar*)src.bits(),src.bytesperline());      cv::mat result; // deep copy in case (my lack of knowledge open cv)      cvtcolor(tmp, result,cv_bgr2rgb);      return result; } 

please me m new both opencv , qt

not sure mean bad results, assuming qimage loads image opencv (bgr). in documentation tells use argb.

so, knowing have 2 options:

  1. convert qimage::format_rgb888 qimage using function converttoformat , line cvtcolor(tmp, result,cv_bgr2rgb); not needed, since in rgb.
  2. use cv_8uc4 when creating cv::mat , drop first channel (channel alpha) using either split , join or mixchannels.

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -