Triangle detection - Canny failing on corner [closed]
Hi
I'm trying to detect a triangle however approxPolyDP fails because:
length(approx) != 3
approx = cv2.approxPolyDP(.....)
I think its because the Canny algortihm somehow cannot find lower right virtex edge. (see image below).
The input image (zoomed using Imagj)
and Imagej pixel inspection tool output of lower right virtexd
Here is the Canny output. I've tried numerous thresholds and get the same opening in the lower RHS virtex.
My code
>>> import cv2
>>> import sys
>>> import numpy as np
>>> filename = 'diffGr.png'
>>> img = cv2.imread(filename,cv2.IMREAD_GRAYSCALE)
>>> minVal = 20
>>> maxVal = 200
>>> edges = cv2.Canny(img,minVal,maxVal)
>>> cv2.namedWindow('Edge image')
>>> cv2.imshow('Edge image',edges)
>>> cv2.waitKey(0)
My input file
Any info on understanding why Canny fails would be appreciated. If this is expected, should I use a different edge detection method?
Cheers
Why not Threshold and then find canny edges?
That worked! Thanks