79730969

Date: 2025-08-10 02:48:42
Score: 1
Natty:
Report link

I was reviewing your code but found that cv2.findContours isn't a good way to detect the hand in image 1, because it's detecting too much detail and not the entire object. Therefore, image 2 has less detail.

import cv2
import sys

img = cv2.imread(sys.argv[1])
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (15, 15), 0)

edged = cv2.Canny(gray, 5, 100)
contours, _ = cv2.findContours(edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

if contours:
    max_area = max(cv2.contourArea(c) for c in contours)
    print(max_area)
else:
    print(0)

better use to measure the area of the larger contour like this, and also that value in image2 that image generates a larger contour.

I recommend using a model like mediapipegoogle for more robust things and detecting hands with landmarks instead of just using contours.

This video could explain more about this topic and is good for future projects using a model with AI. youtube, it was complicate either cuz i dont speak russian btw.

Reasons:
  • Blacklisted phrase (1): This video
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jared McCarthy