1

I am trying to detect the triangle in different bicycle Images. For example this image !(https://surlybikes.com/uploads/bikes/_medium_image/BridgeClub_BK9997.jpg) I am new to OpenCV and am trying the cv.approxPolyDP method. However, I am not getting any results.

ret, thresh = cv.threshold(src, 127, 255, 0)
contours, hierarchy = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
largest = None
for contour in contours:
    approx = cv.approxPolyDP(contour, 0.01 * cv.arcLength(contour, True), True)
    if len(approx) == 3:
        # triangle found
        if largest is None or cv.contourArea(contour) > cv.contourArea(largest):
            largest = contour
            print(largest)
            cv.drawContours(src, [largest], 0, (0, 0, 255), 3)
            cv.imshow("Source", src)

cv.waitKey()

I would like the triangles of the frame to be highlighted. Any help is appreciated.

0 Answers0