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.
//array ->QBytearray (received from socket)
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.
This is the way to modify channels separately:
img = cv::Mat(240,320, CV_8UC1,array.data());
cv::Mat img1;
cv::divide(img,cv::Scalar(2),img1);
std::vector<cv::Mat> channels;
channels.push_back(img);
channels.push_back(img1);
channels.push_back(img);
cv::merge(channels, img);
cv::imshow("image display",img);
cv::waitKey(5000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.