Skip to content

Commit 8a52162

Browse files
committed
Using max contours
1 parent 17fc99f commit 8a52162

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

color_object_detection/src/object_detection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ def callback(self,data):
4848

4949
ret,thresh = cv2.threshold(mask,200,255,0)
5050
im, contours,hierarchy= cv2.findContours(thresh, 1, 2)
51+
52+
c = max(contours, key = cv2.contourArea)
53+
5154
cnt = contours[0]
52-
x,y,w,h = cv2.boundingRect(cnt)
55+
x,y,w,h = cv2.boundingRect(c)
5356

5457
# Bitwise-AND mask and original image
5558
# res1 = cv2.bitwise_and(cv_image,cv_image, mask= mask1)

0 commit comments

Comments
 (0)