Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14215

Computer vision question relating harris corner detector; not detecting properly endpoints

$
0
0

Input image:

Input image

Code used:

import cv2import numpy as npfrom google.colab.patches import cv2_imshow# Read the image and convert to grayscaleimage = cv2.imread('input.png')gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)ret, thresh = cv2.threshold(gray_image, 127, 255, 0)contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)for i, cnt in enumerate(contours):    hull = cv2.convexHull(cnt)    epsilon = 0.02 * cv2.arcLength(cnt, True)    approx = cv2.approxPolyDP(cnt, epsilon, True)    # Draw approximated polygon    for ap in approx:        cv2.circle(image, tuple(ap[0]), 5, (255, 0, 0), -1)# Display the resultcv2_imshow(image)

Output:

Input output wrong

I've tried using other corner detector methods and some filtering methods such as the gaussian blur without any improvement. Can somebody help me to detect correctly the ending points and the intersection points?


Viewing all articles
Browse latest Browse all 14215

Trending Articles