i hava problem in fire detection my code is :
ret, frame = cap.read()
lab_image = cv2.cvtColor(frame, cv2.COLOR_BGR2LAB)
L , a , b = cv2.split(lab_image)
ret,thresh_L = cv2.threshold(L,70,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
ret,thresh_a = cv2.threshold(a,70,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
ret,thresh_b = cv2.threshold(b,70,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
thresh_image = cv2.merge((thresh_L, thresh_a, thresh_b))
dilation = cv2.dilate(thresh_image, None, iterations=2)
gray = cv2.cvtColor(thresh_image,cv2.COLOR_
(cnts, _) = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
for c in cnts:
if cv2.contourArea(c) < args["min_area"]:
continue
(x,y,w,h) = cv2.boundingRecy(c)
cv2.rectangle(frame,(x,y),(x+w, y+h), (0,255,0), 2)
cv2.imshow('frame1',frame)
and when i run this program , see this error
FindContours support only 8uC1 and 32sC1 images in function cvStartFindContours
please help me . tnx
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
Use this line on your image to convert it from BGR to grayscale (8UC1) format before finding contours. FindContours function only supports a grayscale image format.
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