OpenCV 3rdparty libjasper causes failure in imencode / imwrite to JPEG2000

asked 2014-07-14 23:58:27 -0600

darryln gravatar image

updated 2014-07-15 00:02:25 -0600

When using imencode or imwrite with extension ".jp2", error below is always thrown: Error = ......\modules\highgui\src\loadsave.cpp:440: error: (-215) code in function cv::imencode

This is performed on Windows OS 32-bit and 64-bit.

Digging deeper finds that jas_stream.c's jas_stream_tmpfile() returns 0 due to unlink() unsuccessful.

Looking through the source for libjasper (latest 1.900.1-13) shows that the commit for Debian bug at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=501021 has removed the comment before the call to "unlink()" that Windows will fail to unlink if file is already opened, and with that, a flag is set to unlink later.

source: https://github.com/Itseez/opencv/blob/master/3rdparty/libjasper/jas_stream.c#L390

With that reverted and a new opencv_highgui249d.dll built, I managed to encode to JPEG2000 into a file / memory by calling imencode or imwrite.

OpenCV's master source has the same code in that region.

I am not sure if this is a bug introduced for Windows in specific, or if I am calling opencv's code wrong. Please advice.

Thanks in advance.

edit retag flag offensive close merge delete

Comments

1

valid reason to make an issue, imho.

btw, same code for 2.4 and master branch in this case

berak gravatar imageberak ( 2014-07-15 00:16:28 -0600 )edit