Missing support for .hdr (RGBE) on MacOS (macports opencv4)

Dear all,

I am developing some experimental codes with OpenCV4 on MacOS, but target Linux for installations. I am processing CV_32F images. On Linux, I can store these as Radiance RGBE using imwrite (file extension .hdr). On MacOS, this format is not activated and I have to save as OpenEXR instead. I have installed opencv4 via macports on macOS Catalina 10.15. The package with variant information is:

opencv4 @4.5.0_1+contrib+nonfree+openmp+python38

cv::getBuildInformation() gives me the following information on modules and image codecs:

OpenCV modules:
    To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled: python2 world
    Disabled by dependency: dnn_objdetect dnn_superres mcc text
    Unavailable: alphamat cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv dnn java js julia matlab ovis sfm ts viz
    Applications: apps
    Documentation: NO
    Non-free algorithms: YES


Media I/O: 
    ZLib: /opt/local/lib/libz.dylib (ver 1.2.11)
    JPEG: /opt/local/lib/libjpeg.dylib (ver 80)
    WEBP: /opt/local/lib/libwebp.dylib (ver encoder: 0x020f)
    PNG: /opt/local/lib/libpng.dylib (ver 1.6.37)
    TIFF: /opt/local/lib/libtiff.dylib (ver 42 / 4.2.0)
    JPEG 2000: OpenJPEG (ver 2.3.1)
    OpenEXR: build (ver 2.3.0)
    HDR: NO
    PXM: NO
    PFM: NO

Is there any way to get HDR support enabled? Since the encoders are part of OpenCV, I was surprised that they are not active by default.

Best, Lars.

that’s indeed a bit weird, since the hdr code is part of imgcodecs (no 3rdparty deps)
someone must have explicitly disabled WITH_IMGCODEC_HDR when building the libs.

not with what you have now.
build from github src / complain to the maintainer of your prebuilt package, i guess.
if it’s about python, try pip install opencv-python

Hi Berak, thank you for hinting me at that define. I was able to locate it in the Macports “portsfile”, where it is explicitly disabled, and opened a request to re-enable HDR support.

Best, Lars.

1 Like