In the following code Im taking each frame of a video and performing histogram equalization with opencv's CLAHE functions.
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)
However this error is returned at the last line (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
convert each frame to grayscale or apply it on each channel
#convert to grayscale
gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With