How can i found bottom left contour coordinates with opencv

import cv2
import numpy as np

img = cv2.imread(‘ex4.jpg’)

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
kernel_size = 7
kernel = np.ones((3,3),np.uint8)
gray = cv2.dilate(gray, kernel, iterations=4)
gray = cv2.erode(gray, kernel, iterations=4)

blur = cv2.blur(gray, (5, 5))
blur_gray = cv2.GaussianBlur(blur, (kernel_size, kernel_size), 1)

edged = cv2.Canny(blur_gray, 30, 180)

contours, _ = cv2.findContours(edged, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

cnt = max(contours, key=lambda x: cv2.contourArea(x))

epsilon = 0.0005*cv2.arcLength(cnt, True)
approx = cv2.approxPolyDP(cnt, epsilon, True)
print(contours)

cv2.drawContours(img, contours, -1, (0, 255, 0), 2)

cv2.imshow(‘Contours’, img)
cv2.waitKey(0)
cv2.destroyAllWindows()

You can compute distances from the image lower left vertex to each point in the contour, and get that with the closest, the one with the shortest distance.

1 Like

Actually I need to find the smallest value in the contour array for x axis

You need brain bro. just think a little

Kubilaye, i need some help. Dont trolling bro

This PyImageSearch article shows how to get extreme points.

Look for extLeft in line 24. I believe you don’t need to compute convexHull, you can apply that line to you contour:

extLeft = tuple(c[c[:, :, 0].argmin()][0])
1 Like

I solved it this way. Thanks for your time

cnt = contours[0]
extLeft = tuple(cnt[cnt[:, :, 0].argmin()][0])

1 Like