Error trying to encode an empty image with JPEG encoder (Bug #2604)


Added by Luis Díaz Más over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-12-06
Priority:Low Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:highgui-images
Target version:2.4.4
Affected version:branch '2.4' Operating System:
Difficulty: HW Platform:
Pull request:https://github.com/Itseez/opencv/pull/344

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

Revision 255cd61a
Added by Andrey Kamaev about 12 years ago

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)"

Revision b56dce39
Added by Andrey Pavlenko almost 11 years ago

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 Andrey Kamaev about 12 years ago

Fix is pushed to 2.4

  • Status changed from Open to Done

Updated by Kirill Kornyakov about 12 years ago

  • Target version set to 2.4.4

Also available in: Atom PDF