OpenCV JPEG 12-bit support
I am working on a project that requires processing grayscale JPEG images with 12-bit depth per pixel. Does OpenCV support 12-bit JPEG images?
The 3rd party library 'libjepg' used by OpenCV supports 12-bit JPEG's but needs to be built for 12-bit support. The macro that defines 8/12-bit support is BITS_IN_JSAMPLE
in jmorecfg.h under opencv/3rdparty/libjepg
.
If I change that macro to 12-bit and rebuild OpenCV, am I good to go? Or does this mess up the internals of OpenCV?
Not exactly an answer, but did you try to load with
CV_IMREAD_ANYDEPTH
? Check this out http://code.opencv.org/issues/2246I shall try this thanks a lot.
However, my understanding is that I still need to recompile libjpeg for 12-bit support (as this library is in charge of encoding/decoding jpeg images).
I ll have a go and post back.
Changed BITS_IN_JSAMPLE to 12 in jmorecfg.h but OpenCV won't build :-( There's type mismatches in grfmt_jpeg.cpp. OpenCV expects uchar but gets ushort instead. So looks like OpenCV does not take into account the BITS_IN_JSAMPLE macro to configure itself accordingly. Shame.
Would it be complete madness to attempt to fix this myself? The type errors seem to be located only in grfmt_jpeg.cpp and don't seem that hard to fix. I am a bit concerned though that any changes in here will cascade to the rest of the OpenCV library. Are there any gurus that know this part of the code? Any advice?
Did you ever got this to work? I am trying to do the same thing and running into the exact same issue. Would appreciate any tips you have for me. Thanks