0

I am using the following tutorial as a guide to process some HDR brackets with OpenCV in Python:

http://man.hubwiz.com/docset/OpenCV.docset/Contents/Resources/Documents/d3/db7/tutorial_hdr_imaging.html

However no matter what I try the calibrateDebevec function is throwing an error: error: (-215:Assertion failed) images[0].depth() == CV_8U in function 'CV::CalibrateDebevecImpl::process'. I am new to OpenCV and this is a very obscure error message to me... What is going wrong? I tried checking that all of the inputs are aligned, the exposure times seem to be accurate, the images are all of the same shape (x, y, channel count), etc. I couldn't find any documentation on what format the exposure times should be in, so I am using floating point fractions of a second. Here is a reduced example to show what I mean, the exposure times are just hard-coded at the values I know are correct:

import cv2 as cv
import numpy as np


paths = ['list of images']
times = [0.0666, 0.0333, 0.0166, 0.01, 0.008, 0.1, 0.2]

images = []
for path in paths:
    im = cv.imread(path, cv.IMREAD_UNCHANGED)
    images.append(im)

calibrate = cv.createCalibrateDebevec()
response = calibrate.process(images, times)
Spencer
  • 1,931
  • 1
  • 21
  • 44
  • 1) Is `path` an actual, _valid_, image path? 2) Seems the assertion is indicating that the expected image is `uint8`, however another type (depth) was passed. Check the depth of the image, because a conversion to `uint8` `(CV_8U)` might be needed before passing the image to `calibrate.process`. – stateMachine Nov 15 '21 at 03:58
  • @stateMachine Looks like you got it right, they are 16bpc images. Converting to 8bpc with `im.astype(np.uint8)` has fixed it. I'm loving cv2, but I have to say the documentation is a little skimpy... Bummer none of the HDR tools seem to work on 16bit images. I would think for something as delicate as photo stacking you would want that extra bit depth... – Spencer Nov 15 '21 at 04:23
  • OpenCV definitely has a learning curve. But don’t worry, things became easier the more time we spend with them. OpenCV seems to be the de-facto standard for image processing and computer vision on the industry (in my experience), so there’s certainly an advantage in knowing how to work with it. Note that many of OpenCV’s functions require certain data types. This can be a little bit tricky to see in dynamically-typed languages such as Python, so be on the lookout for explicit data-type conversions! – stateMachine Nov 15 '21 at 04:50
  • @stateMachine Indeed, thanks for the advice! – Spencer Nov 15 '21 at 04:56

0 Answers0