I am using a camera to get a imgTomo1 image which is a cv::Mat object. It is a CV_32F image. I am trying to show it on a QLabel using a QPixmap. Here is my code :
cv::Mat imgTomo; imgTomo1.convertTo(imgTomo,CV_8UC1); static QVector<QRgb> sColorTable; // only create our color table the first time if ( sColorTable.isEmpty() ) sColorTable.resize( 256 ); for ( int i = 0; i < 256; ++i ) { sColorTable[i] = qRgb( i, i, >i ); } } QImage image( imgTomo.data, imgTomo.cols, imgTomo.rows, static_cast<int>(imgTomo.step), QImage::Format_Indexed8); image.setColorTable( sColorTable ); _afficheImg->setPixmap(QPixmap::fromImage(image));
Unfortunately, the image displayed remain black. I am a bit lost in the format as i'm new to OpenCV. I think the conversion should work so i don't really know what i am mising.
EDIT : i have deleted the fllowing line :
imgTomo1.convertTo(imgTomo,CV_8UC1);
It resulted in a loss of information. Now i dont have a black screen anymore but some "snow" (pixel that are witching form 1 to 0 very quicly i guess) and i can't really see what my camera is suposed to show.
Thank you for your answers, Grégoire