This works great .
但是我注意到,它会检测到附近有2个人移动,或者是单人牵手 .
People nearby in a same surrounding box
How can I separate them?
# ---- Image from video
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (21, 21), 0)
# if the average frame is None, initialize it
if average is None:
print("[INFO] starting background model...")
average = gray.copy().astype("float")
return 0, image
# accumulate the weighted average between the current frame and
# previous frames, then compute the difference between the current
# frame and running average
cv2.accumulateWeighted(gray, average, 0.5)
frame_delta = cv2.absdiff(gray, cv2.convertScaleAbs(average))
# threshold the delta image, dilate the thresholded image to fill
# in holes, then find contours on thresholded image
thresh = cv2.threshold(frame_delta, var_sis.config["delta_thresh"], 255,
cv2.THRESH_BINARY)[1]
thresh = cv2.dilate(thresh, None, iterations=2)
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
sorted contours = sorted(cnts, key=lambda x: cv2.contourArea(x), reverse=True)
# -----> I got contourns
1 回答
所使用的技术本身并不足以解决您的问题 . 您需要检测个体 . 看看this tutorial