JAVA物体运动检测_用opencv检测运动,物体太近

这篇博客探讨了如何使用OpenCV在JAVA中进行物体运动检测,但遇到一个问题:当多人靠近时,系统无法区分独立个体。作者通过获取图像的灰度和差分帧来检测运动,然后进行阈值处理和膨胀操作找到轮廓。目前的问题是如何从检测到的轮廓中分离出单独的个体。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

This works great .

但是我注意到,它会检测到附近有2个人移动,或者是单人牵手 .

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值