Error trying to encode an empty image with JPEG encoder (Bug #2604)
Description
Hi,
I was applying some unitary tests to some personal code when I discovered that OpenCV throws an error when you try to encode an empty image with imencode. I suppose that it would be the normal behaviour, but maybe a more descriptive error message could be useful for developers. I checked that in OpenCV 2.4.3 code, the JPEG encoder doesn't check if you are dealing or not with and empty image.
A simple snippet of code that reproduces this error is:
#include <vector> #include <opencv2/highgui/highgui.hpp> int main() { cv::Mat img; std::vector<uchar> jpegImg; cv::imencode(".jpg", img, jpegImg); }
And the error throw by opencv is this one:
OpenCV Error: Assertion failed (code) in imencode, file /.../OpenCV-2.4.3/modules/highgui/src/loadsave.cpp, line 429 terminate called after throwing an instance of 'cv::Exception' what(): /.../OpenCV-2.4.3/modules/highgui/src/loadsave.cpp:429: error: (-215) code in function imencode
Do you consider this behaviour a bug? Does a change of this behaviour worth it? I would like to contribute in the project, and I could start with something simple like this ^^
Associated revisions
Improve error reporting of JPEG image encoder
OpenCV issue #2604
After this patch applied an attempt to encode empty images produces exception
saying "Raw image encoder error: Empty JPEG image (DNL not supported)"
Merge pull request #2604 from alalek:binary_package_fix
History
Updated by Anna Kogan over 12 years ago
Hello Luis,
It seems that more descriptive error message is a good idea. If you can suggest such a decision, a patch or a pull request there: http://opencv.org/opencv-pull-requests-test-results.html would be highly appreciated!
Updated by Vadim Pisarevsky about 12 years ago
- Target version deleted (
2.4.4)
Updated by Vadim Pisarevsky about 12 years ago
- Assignee deleted (
Vadim Pisarevsky)
Updated by Andrey Kamaev about 12 years ago
- Pull request set to https://github.com/Itseez/opencv/pull/344
- Affected version set to branch '2.4'
- Assignee set to Andrey Kamaev
Updated by Kirill Kornyakov about 12 years ago
- Target version set to 2.4.4