This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2, numpy as np, math | |
raw_image = cv2.imread('/home/stephen/Desktop/gear6.jpg') | |
bilateral_filtered_image = cv2.bilateralFilter(raw_image, 5, 175, 175) | |
# Added median blurring to improve edge detection | |
median_blurred_images = cv2.medianBlur(bilateral_filtered_image, 5) | |
edge_detected_image = cv2.Canny(median_blurred_images, 75, 200) | |
# Switched from RETR_TREE to RETR_EXTERNAL to only extract most outer contours | |
_, contours, _ = cv2.findContours(edge_detected_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) | |
contour_list = [] | |
for contour in contours: |