I was trying to use the contours of and image, and when I tried the following it gave and error. I know for sure that it is because of the 24, because I used another number such as 45 and it would accept it. The rest of the code is okay, that's why I didn't write it.
ret, thresh = cv2.threshold(angray, 251 , 190, 24)
The error is the following one
error: (-215:Assertion failed) automatic_thresh != (CV_THRESH_OTSU | CV_THRESH_TRIANGLE) in function 'cv::threshold'
And the full code just in case you guys want to see it is this one:
import cv2
ancolor = cv2.imread("Anonymous.jpg")
angray = cv2.cvtColor(ancolor, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(angray, 251 , 190, 24)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
print("Number of contours" + str(len(contours)))
cv2.drawContours(ancolor, contours, -1, (0, 255, 0), 3)
cv2.imshow("AnColor", ancolor)
cv2.imshow("AnGray", angray)
cv2.waitKey()
Thanks a lot, first time asking a question on StackOverflow. Thanks.