【问题标题】:movement detection with opencv, objects too close使用opencv进行运动检测,物体太近
【发布时间】:2018-12-08 22:59:32
【问题描述】:

我从 https://www.pyimagesearch.com/2015/06/01/home-surveillance-and-motion-detection-with-the-raspberry-pi-python-and-opencv/

效果很好

但我注意到,它会检测到 2 个人在附近移动,或手牵手作为一个人

People nearby in a same surrounding box

如何将它们分开?

# ---- 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 

【问题讨论】:

    标签: python-3.x opencv object-detection


    【解决方案1】:

    所使用的技术本身不足以解决您的问题。您将需要检测个人。查看this tutorial

    【讨论】:

      猜你喜欢
      • 2013-12-23
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      • 2014-08-20
      • 2021-03-01
      • 2012-07-06
      • 1970-01-01
      相关资源
      最近更新 更多