I am trying to get some HDR related functions working with OpenCV-Python: specifically I'm trying to reproduce the OpenCV C++ HDR tutorial. Unfortunately, the resulting hdr image/array comes out completely white (all values are Inf). Here is an MCVE. 1.jpg, 2.jpg, 3.jpg are all 870 × 580 RGB (Internal RGB KODAK sRGB Display) JPG images with exposure times of 1/3200, 1/800, and 1/200 respectively. I've tested this with 2 other JPG image sets now, one of which is available on Wikimedia.
>>> import cv2
>>> import numpy as np
>>>
>>> img = cv2.imread("1.jpg")
>>> img2 = cv2.imread("2.jpg")
>>> img3 = cv2.imread("3.jpg")
>>>
>>> images = np.array([img, img2, img3])
>>> times = np.array([1.0/3200,1.0/800,1.0/200])
>>>
>>> merger = cv2.createMergeDebevec()
>>> hdr = merger.process(images, times)
>>> hdr
array([[[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf],
...,
[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf]],
[[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf],
...,
[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf]],
[[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf],
...,
[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf]],
...,
[[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf],
...,
[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf]],
[[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf],
...,
[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf]],
[[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf],
...,
[ inf, inf, inf],
[ inf, inf, inf],
[ inf, inf, inf]]], dtype=float32)
An interesting thing to note is that the "times" array is modified after the merger.process call
>>> times
array([-8.07090609, -6.68461173, -5.29831737])
I am using OpenCV version:
>>> cv2.__version__
'3.0.0'
The merger.process call has a signature as follows:
>>> import inspect
>>> inspect.getdoc(merger.process)
'process(src, times, response[, dst]) -> dst or process(src, times[, dst]) -> dst'