cv::Mat to Magick::Image => Q8 C++ API x64 Windows VS2017
Posted: 2019-01-16T11:56:21-07:00
Helllo,
I asked yesterday on stackoverflow about an issue i face in converting an image from cv::Mat to Magick::Image.
The final aim is to save multiple page tiff file.
The original post is there : https://stackoverflow.com/questions/542 ... age-cv-uc3
I have error on the Magick::Image line :
The problem persist, then it is not related to OpenCV.
When i watch the code of "pixel.c" line 4243, there is a switch case :
Then it is as if i went in the "default" part of this "switch/case".
Do anybody have an idea about what can be the problem ?
Thanks !
I asked yesterday on stackoverflow about an issue i face in converting an image from cv::Mat to Magick::Image.
The final aim is to save multiple page tiff file.
The original post is there : https://stackoverflow.com/questions/542 ... age-cv-uc3
Code: Select all
TiffWriter::TiffWriter(std::string filename) : filename(filename) {}
// for example for a 8 bit gray image buffer
void TiffWriter::writeGray(const unsigned char* buffer, int width, int height)
{
Magick::Blob gray8Blob(buffer, width * height);
Magick::Geometry size(width, height);
Magick::Image gray8Image(gray8Blob, size, 8, "GRAY");
imageList.push_back(gray8Image);
}
void TiffWriter::writeRGB(Mat& mat)
{
auto depth = mat.depth();
auto channels = mat.channels();
auto type = mat.type();
Magick::Image Mg_RGB(mat.cols,mat.rows,"BGR",Magick::CharPixel,(char *)mat.data);
imageList.push_back(Mg_RGB);
}
TiffWriter::~TiffWriter()
{
Magick::writeImages(imageList.begin(), imageList.end(), filename);
}
I tried to changed the cv:mat image by a square 2x2 image and a random char value.Error: Magick: unrecognized pixel map ``QSõ▒' @ error/pixel.c/ImportImagePixels/4243
The problem persist, then it is not related to OpenCV.
When i watch the code of "pixel.c" line 4243, there is a switch case :
Code: Select all
switch (map[i])
{
case 'a':
case 'A':
{
quantum_map[i]=AlphaQuantum;
image->alpha_trait=BlendPixelTrait;
break;
}
case 'B':
case 'b':
{
quantum_map[i]=BlueQuantum;
break;
}
...
default:
{
quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"UnrecognizedPixelMap","`%s'",map);
return(MagickFalse);
}
}
Do anybody have an idea about what can be the problem ?
Thanks !