如何将 "xphoto_WhiteBalancer.balanceWhite" 与 Python 和 OpenCV 一起使用?
How to use "xphoto_WhiteBalancer.balanceWhite" with Python and OpenCV?
我正在寻找一种将自动白平衡应用于图像的简单方法。
我找到了一些关于 balanceWhite()
方法的官方文档:cv::xphoto::WhiteBalancer Class Reference
但是,当我尝试调用示例中所示的函数时出现了一个模糊的错误。
image = cv2.xphoto_WhiteBalancer.balanceWhite(image)
加薪:
Traceback (most recent call last):
File "C:\Users\Delgan\main.py", line 80, in load
image = cv2.xphoto_WhiteBalancer.balanceWhite(image)
TypeError: descriptor 'balanceWhite' requires a 'cv2.xphoto_WhiteBalancer' object but received a 'numpy.ndarray'
如果那么我尝试根据需要使用 cv2.xphoto_WhiteBalancer
对象:
balancer = cv2.xphoto_WhiteBalancer()
cv2.xphoto_WhiteBalancer.balanceWhite(balancer, image)
它提高了:
Traceback (most recent call last):
File "C:\Users\Delgan\main.py", line 81, in load
cv2.xphoto_WhiteBalancer.balanceWhite(balancer, image)
TypeError: Incorrect type of self (must be 'xphoto_WhiteBalancer' or its derivative)
有没有人在 Python 3.6 和 OpenCV 3.4 中成功使用此功能?
我也尝试使用派生的 类 GrayworldWB
、LearningBasedWB
和 SimpleWB
,但错误是相同的。
答案可以在xphoto
documentation中找到。
创建 WB 算法的适当方法是 createSimpleWB()
、createLearningBasedWB()
和 createGrayworldWB()
。
示例:
wb = cv2.xphoto.createGrayworldWB()
wb.setSaturationThreshold(0.99)
image = wb.balanceWhite(image)
这是官方 OpenCV 存储库中的示例文件:modules/xphoto/samples/color_balance_benchmark.py
我正在寻找一种将自动白平衡应用于图像的简单方法。
我找到了一些关于 balanceWhite()
方法的官方文档:cv::xphoto::WhiteBalancer Class Reference
但是,当我尝试调用示例中所示的函数时出现了一个模糊的错误。
image = cv2.xphoto_WhiteBalancer.balanceWhite(image)
加薪:
Traceback (most recent call last):
File "C:\Users\Delgan\main.py", line 80, in load
image = cv2.xphoto_WhiteBalancer.balanceWhite(image)
TypeError: descriptor 'balanceWhite' requires a 'cv2.xphoto_WhiteBalancer' object but received a 'numpy.ndarray'
如果那么我尝试根据需要使用 cv2.xphoto_WhiteBalancer
对象:
balancer = cv2.xphoto_WhiteBalancer()
cv2.xphoto_WhiteBalancer.balanceWhite(balancer, image)
它提高了:
Traceback (most recent call last):
File "C:\Users\Delgan\main.py", line 81, in load
cv2.xphoto_WhiteBalancer.balanceWhite(balancer, image)
TypeError: Incorrect type of self (must be 'xphoto_WhiteBalancer' or its derivative)
有没有人在 Python 3.6 和 OpenCV 3.4 中成功使用此功能?
我也尝试使用派生的 类 GrayworldWB
、LearningBasedWB
和 SimpleWB
,但错误是相同的。
答案可以在xphoto
documentation中找到。
创建 WB 算法的适当方法是 createSimpleWB()
、createLearningBasedWB()
和 createGrayworldWB()
。
示例:
wb = cv2.xphoto.createGrayworldWB()
wb.setSaturationThreshold(0.99)
image = wb.balanceWhite(image)
这是官方 OpenCV 存储库中的示例文件:modules/xphoto/samples/color_balance_benchmark.py