I’ve been learning OpenCV and since i’m very much into climbing i wanted to try to get the contours of the holds of a climbing wall.
This looked very easy since the holds ussually have very distinct colours.
Unfortunatly I can’t get this to work properly.
It comes down to getting the treshholding technique right i assume.
I’ve been playing with these and other examples for a couple of weeks now but never get close to something that is acceptable.
Anyone can point me in the right direction?
# organizing imports import cv2 import numpy as np segmented =  # path to input image is specified and # image is loaded with imread command image1 = cv2.imread('C:\\Users\##\Downloads\jos.jpg') blue, green, red = cv2.split(image1) # cv2.cvtColor is applied over the # image input with applied parameters # to convert the image in grayscale img = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY) # applying thresholding thresh1 = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C , cv2.THRESH_BINARY, 9, 18) contours1, hierarchy1 = cv2.findContours(thresh1, mode=cv2.RETR_TREE, method=cv2.CHAIN_APPROX_NONE) 12 # draw contours on the original image 13 image_contour_blue = img.copy() 14 cv2.drawContours(image1, contours=contours1, contourIdx=-1, color=(0, 255, 0), thickness=2, lineType=cv2.LINE_AA) 15 # see the results cv2.imshow('Contour detection using blue channels only', image1) cv2.waitKey(0) 16 cv2.imshow('Contour detection using blue channels only', blue) cv2.waitKey(0) cv2.imshow('Contour detection using green channels only', green) cv2.waitKey(0) cv2.imshow('Contour detection using red channels only', red) 17 cv2.waitKey(0) # the window showing output images # with the corresponding thresholding # techniques applied to the input image #cv2.imshow('Adaptive Mean', thresh1) #cv2.imshow('Adaptive Gaussian', thresh2) ![jos|375x500](upload://dCZNqy1H7PN5OmnKSrRdbhPo0yq.jpeg) # De-allocate any associated memory usage if cv2.waitKey(0) & 0xff == 27: cv2.destroyAllWindows()