Does OpenCV support advanced libjpeg loading options?
Some Android devices have small memory sizes, or implement very stringent memory usage policies.
For my Android image processing application, there are two JPEG-specific image decoding options that are available from libjpeg, which I would like to use through OpenCV's highgui module.
- To find out the size and pixel format of the JPEG file, without loading the pixels into memory.
- To decode the JPEG file with a power-of-two scale down factor, such that it is not necessary to allocate a matrix at the original dimensions. Instead, the matrix only needs to be allocated at the scaled-down dimensions.
- To optionally decode a color JPEG file in grayscale, such that one only needs to allocate a single-channel matrix, instead of a
8UC3
or8UC4
matrix.
My question is:
- Does OpenCV support, or have plans to support such functionality?
- Has anyone done this with OpenCV before?
The image sizes will depend on the camera resolution. On some higher-end models, the image size can be in 10 - 20 megapixels. The allowed memory budget is 128 megapixels. This low memory budget is necessary because on a typical mobile device, a lot of background applications will be running, and it is deemed not acceptable (for a consumer-grade application, not for leisure) to kill or recycle other background applications to make more memory available.
I can program to libjpeg directly. I find the libjpeg static library in the OpenCV4Android package at "sdk/native/3rdparty/libs/arch". However, there is no corresponding header file of the libjpeg inside the OpenCV4Android package.
Linking to a second copy of libjpeg from my code is not an option due to multiple definitions.