Can imencode() encode a large .bmp image? [closed]
I use imencode() method to put the header for the .bmp image. For an image with 20x20 pixels is working but for an image with 400x400 pixels is not working. There is no error when I use large .bmp. The program is a comparer algorithm.
Another question if imencode () is not working with larger images how to create manually the header for the .bmp content?
NOTE: I am using OpenCV 3.0.0
"is not working" - means ?
please show your code, the problem might rather be on your side, not with imencode.
(and i already guess, you're using strings in some way, they should not be used...)
This is a C++ Addon in Nodejs and I use AsyncWorker to be async. { ... BYTE* DiffBuff ==> where I keep the image content
}
//method which encode bmp bool EncodeMatrix(cv::Mat &imgMatrix, std::vector<uchar> &diffBuffer) { bool result = cv::imencode(".bmp", imgMatrix, diffBuffer, std::vector<int>());
}
please note, that this constructor:
cv::Mat(height, width, CV_8UC3, (void*)DiffBuff);
does not copy pixels, only the pointer, and also, that yourflip()
works in-place. be extra careful here, andclone()
your imgMatrix."is not working" - means : That I use the AyncWorker and on Execute method I do my encode above code and HandleOKCallback() is never called so in my javascript I cannot see anything . If I use below snippet is working fine but is a different result that I expect because of compression and .png extension. std::vector<int> params(1); params[0] = CV_IMWRITE_PNG_COMPRESSION; params[1] = 9;
For small .bmp is working(20x20). I used clone but no difference.
Why is working with .png extension and compression? Is there a method to not use imencode and create manually the bitmap header?
encoding to bmp works for any img size here (please try in an isolated, simple cpp prog), so it's something weird in your context.
Hi, I isolated the imencode method. I put the method in the constructor of the AsyncWorker derived class and is breaking me the flow with Execute method and OKCallback. But when I put the imencode in OKCallback the flow is working ok for me. So AsyncWorker from NodeJS is behaving weird.
There is possible to create manually the header for bitmap? I am using OpenCV3.0.0 I don't have the class cv::BitmapInfoHeader. I would like to create the header manually and attach to the content.