임 파이썬과 opencv 라이브러리에서 작동합니다.레이블이 지정된 고유 한 윤곽 (또는 독립 윤곽을 그립니다.)
카메라 캡처를 임계 값으로 설정하고 등고선 (두 개 이상)을 찾아 그릴 수 있습니다. 하지만 문제가 있습니다. 고유 한 ID 또는 태그로 그 윤곽을 식별하려고합니다. (예 : Id : 1, Id : 2)를 사용하여 추적합니다. 윤곽선에 영구 ID를 사용해야합니다.
목표는 선을 그어 두 개 이상의 등고선을 계산하고 때로는 둘 이상의 주변선이 큰 선으로 변환합니다.
참고 : 깊이 카메라로 사진을 찍었고 이미지에는 깊이가 있습니다.
코드 조각을 추가하십시오.
미리 감사드립니다.
countours = cv2.findContours(mask, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)[1]
# only proceed if at least one contour was found
if len(countours) > 0:
# find the largest contour in the mask, then use
# it to compute the minimum enclosing circle and
# centroid
for (i,c) in enumerate(countours):
((x, y), radius) = cv2.minEnclosingCircle(c)
M = cv2.moments(c)
if M["m00"] > 0:
center = (int(M["m10"]/M["m00"]), int(M["m01"]/M["m00"]))
centerString = str(center)
x = (int(M["m10"]/M["m00"]))
y = (int(M["m01"]/M["m00"]))
else:
center = int(x), int(y)
if radius > 10:
# draw the circle and centroid on the frame,
cv2.circle(frame, (int(x), int(y)), int(radius),
(0, 255, 255), 2)
cv2.circle(frame, center, 5, (0, 0, 255), -1)
# then update the ponter trail
if self.previous_position:
cv2.line(self.trail, self.previous_position, center,
(255, 255, 255), 2)
cv2.add(self.trail, frame, frame)
print center
self.previous_position = center
if len(countours) < 1:
center = 0
self.trail = numpy.zeros((self.cam_height, self.cam_width, 3),
numpy.uint8)
self.previous_position = None
Hand label 0 and circle 1
. 그러나 이러한 접근법 중 하나를 시도하고 구현하는 데 문제가 있다면 확장 할 수 있습니다! –첫 번째 해답은 등고선을 찾고 라벨을 붙이기 위해 해결되었지만 이제 레이블은 너비와 변경에 따라 달라집니다 (0은 너비의 최고 값, 상단 이미지, 1은 더 낮은 값임). 위치에 따라 프레임 단위로 변경됩니다. 감사. –