0

I'm trying to examine multiple tone-mapping operators in Open CV, using Python.

Various sources use four operators (Drago, Durand, Reinhard, Mantiuk). Three of them work. However, when I call up cv2.createTonemapDurand(), I get this error:

AttributeError: module 'cv2.cv2' has no attribute 'createTonemapDurand'

Is it possible to call the Durand operator somehow, or did Open CV drop that one recently?

Thanks!

zgebac26
  • 81
  • 9

2 Answers2

2

I'll switch from comment to answer to have a better representation.

you just have to :

import cv2

cv2.xphoto.createTonemapDurand()

Be aware that, if u compiled opencv by yourself, you had to check OPENCV_ENABLE_NONFREE.

Panda50
  • 901
  • 2
  • 8
  • 27
  • Thanks, seems like you're right - I'll have to enable NONFREE. I Tried to find a proper tutorial, but it's quite confusing. Any ideas on how to access cmake and check OPENCV_ENABLE_NONFREE? – zgebac26 Dec 01 '20 at 12:11
  • If u don't need extra modules as CUDA for opencv you don't have to compile it by yourself. Just use pip install opencv-contrib-python , it's gonna be faster. – Panda50 Dec 01 '20 at 14:12
  • Unfortunately, even after installing opencv-contrib-python with pip3 (with pip it said 'requirement already satisfied'), it still raises the same error... @panda50 Do you think it would be wise to uninstall opencv and start from scratch? – zgebac26 Dec 08 '20 at 11:37
  • It looks that since opencv-contrib > 4.0.1 , xphoto is not 'free' anymore. It also happened with Orb function for example. Even while downgrading opencv-contrib to 3.4.11 for example, it asks me to build opencv by myself and enable NONFREE option. If you really want to use xphoto, you'll have to build opencv by yourself using Cmake (for windows), set OPENCV_ENABLE_NONFREE and download last version of opencv-contrib. Don't worry, it'll work with opencv 4.4.0 (that's what I built and it works for me). Or......you can change your method and avoid xphoto. ;) – Panda50 Dec 09 '20 at 12:28
0

Please post your code where you import cv2 and call the function. If you want to look for some functions, attributes or whatever either look in the documentation of the package or use dir() and type(). For your example you can use this:

import cv2
from re import match

cv2_filtered = filter(lambda v: match('.*Tonemap', v), dir(cv2))
[print(val) for val in cv2_filtered]

Returns:

Tonemap
TonemapDrago
TonemapMantiuk
TonemapReinhard
createTonemap
createTonemapDrago
createTonemapMantiuk
createTonemapReinhard

Seems like there is no function createTonemapDurand in cv2.

mnikley
  • 1,625
  • 1
  • 8
  • 21