gpt4 book ai didi

python - opencv clahe.apply() 错误

转载 作者:太空狗 更新时间:2023-10-29 21:45:06 27 4
gpt4 key购买 nike

在下面的代码中,我获取视频的每一帧并使用 opencv 的 CLAHE 函数执行直方图均衡。

import numpy as np
import matplotlib.pyplot as plt
import cv2
import imutils


#Read video
while True:
VIDEO = cv2.VideoCapture('cellvid3.avi')
ok, videoWidget = VIDEO.read();
image = VIDEO.get(cv2.CAP_PROP_POS_FRAMES);
#Adaptive Histogram Equalization
clahe = cv2.createCLAHE(clipLimit=6, tileGridSize= (8,8))
cl1 = clahe.apply(image)

然而这个错误在最后一行返回(clahe.apply)

    Failed to parse avi: index was not found
OpenCV Error: Assertion failed (_src.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) || _src.type() == (((2) & ((1 << 3) - 1)) + (((1)-1) << 3))) in `anonymous-namespace'::CLAHE_Impl::apply, file C:\projects\opencv-python\opencv\modules\imgproc\src\clahe.cpp, line 360
Traceback (most recent call last):
File "ContoursVid.py", line 23, in <module>
cl1 = clahe.apply(image)
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc\src\clahe.cpp:360: error: (-215) _src.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) || _src.type() == (((2) & ((1 << 3) - 1)) + (((1)-1) << 3)) in function `anonymous-namespace'::CLAHE_Impl::apply

最佳答案

将每个帧转换为灰度或将其应用于每个 channel

#convert to grayscale
gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)

关于python - opencv clahe.apply() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49265735/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com