adubaldo
2nd March 2015, 16:42
Hi all :),
I'm trying to show an image with opencv function cv::imshow("windowsName",cv::Mat) starting from QByteArray. The problem is that the image appears duplicated:
Like this:
10983
Here the code:
void Locus::getImages(QFile* file, Mat& matImg)
{
QByteArray imagesData;
if(file->exists())
{
//get byteArray from raw data file
file->open(QFile::ReadOnly);
imagesData = file->readAll();
file->close();
//Create qimage
QImage img((const uchar*)imagesData.data(),WIDTH,HEIGHT,QImage::Form at_RGB16);
//create mat image from qimage
matImg = this->qImage2Mat(img);
imshow("window",matImg);
waitKey();
}
}
Mat Locus::qImage2Mat(const QImage& src)
{
Mat tmp(src.height(),src.width(), CV_8UC3,(uchar*)src.bits(),src.bytesPerLine());
Mat res;
cvtColor(tmp, res,CV_RGB2GRAY);
return res;
}
Any help?
ps: i think the problem is the image format, but i've tried many ways help me xD.
I'm trying to show an image with opencv function cv::imshow("windowsName",cv::Mat) starting from QByteArray. The problem is that the image appears duplicated:
Like this:
10983
Here the code:
void Locus::getImages(QFile* file, Mat& matImg)
{
QByteArray imagesData;
if(file->exists())
{
//get byteArray from raw data file
file->open(QFile::ReadOnly);
imagesData = file->readAll();
file->close();
//Create qimage
QImage img((const uchar*)imagesData.data(),WIDTH,HEIGHT,QImage::Form at_RGB16);
//create mat image from qimage
matImg = this->qImage2Mat(img);
imshow("window",matImg);
waitKey();
}
}
Mat Locus::qImage2Mat(const QImage& src)
{
Mat tmp(src.height(),src.width(), CV_8UC3,(uchar*)src.bits(),src.bytesPerLine());
Mat res;
cvtColor(tmp, res,CV_RGB2GRAY);
return res;
}
Any help?
ps: i think the problem is the image format, but i've tried many ways help me xD.