Display Qbytearray as Image in QT 5.12.9 version
-
I am reading the QByteArray using QTcpSocket and converting the array into the cvMat image. to display the image using imshow().but i am getting gray image. code is as follows.
cv::Mat img,img1;
img.cols=320;
img.rows=240;
img = cv::Mat(240,320, CV_8UC1,array.data());
cv::cvtColor(img, img, CV_GRAY2RGB); //
cv::imshow("image display",img);
cv::waitKey(5000);after cvtColour() function also its not converting into colour image.
Thanks in advance.
-
@Pooja-Bhusare
Start by determining whether it's your code not doing what you want with correct data, or whether you're not transferring/receiving the right stuff over socket. The two issues are quite independent of each other, you need to know which of the two is problematic. -
@Pooja-Bhusare said in Display Qbytearray as Image in QT 5.12.9 version:
i am getting gray image
Well, should it be the expected behavior? I mean, since you're doing:
cv::cvtColor(img, img, CV_GRAY2RGB)
and CV_GRAY2RGB will convert grayscale to RGB color space but it won't color your already gray image...
See this answer in SO. -
@JonB said in Display Qbytearray as Image in QT 5.12.9 version:
Start by determining whether it's your code not doing what you want with correct data, or whether you're not transferring/receiving the right stuff over socket. The two issues are quite independent of each other, you need to know which of the two is problematic.
Yes , problem is resolved i am not receiving complete buffer socket Thanks
-
@Pooja-Bhusare said in Display Qbytearray as Image in QT 5.12.9 version:
problem is resolved
great, so please don't forget to mark your post as solved!
-
I am trying to convert the cv mat image to Qimage but facing error: ‘class Ui::MainWindow’ has no member named ‘display_image’
-
@Pooja-Bhusare said in Display Qbytearray as Image in QT 5.12.9 version:
but facing error: ‘class Ui::MainWindow’ has no member named ‘display_image’
Should that issue be a new post on its own?