简体   繁体   English

如何区分opencv中的两个渐进式图像

[英]How to differentiate between two progressive images in opencv

I have a video file of evening time ( 6pm-9pm).我有一个晚上时间(下午 6 点到晚上 9 点)的视频文件。 And I want to detect movement of people on the road.我想检测路上人的移动。

While trying to find the difference between a handful of images from "10 minute" time frame videos (10 equally time spaced images within any 10 minutes video frame clip) I'm facing these challenges:在尝试从“10 分钟”时间帧视频(任何 10 分钟视频帧剪辑中的 10 个等时间隔的图像)中找出少数图像之间的差异时,我面临以下挑战:

  1. All the images are coming as different (coming as Alert) because there is some plant moving due to wind all the time.所有图像都不同(以警报形式出现),因为有一些植物一直因风而移动。

  2. All the 10 images are coming different also because the sun is setting down and hence due to "natural light variation" the 10 images from 10 minute frames after coming different even though there is no public/human movement.所有 10 个图像都不同也是因为太阳正在下山,因此由于“自然光变化”,即使没有公众/人类运动,来自 10 分钟帧的 10 个图像也不同。

  3. How do I restrict my algorithm to focus only on movements ion certain area of the video rather than all of it ?如何限制我的算法只关注视频特定区域的运动而不是全部? (Couldn't find anything on google or dont know if there's any algo in opencv for this) (在 google 上找不到任何东西,或者不知道 opencv 中是否有任何算法)

  1. This one is rather difficult to deal with.这个比较难对付。 I recommend you try to blur the frames a little bit to reduce the noises from moving plants.我建议您尝试稍微模糊帧以减少移动植物的噪音。 Also, if the range of the movement is not so large, try changing the difference threshold and area threshold (if your algorithm contains contour detection as the following step).另外,如果运动的范围不是很大,请尝试更改差异阈值和面积阈值(如果您的算法包含轮廓检测作为以下步骤)。 Hope this can help a little bit.希望这可以帮助一点。

  2. For detecting "movement" of people, a (10 frame/10 min) fps is a little too low.为了检测人的“运动”,(10 帧/10 分钟)fps 有点太低了。 People in the frames can be totally different.框架中的人可能完全不同。 This means you cannot detect the movement of a single person, but to find the differences between two frames.这意味着您无法检测单个人的运动,而是要找出两帧之间的差异。 In the case where you are using low fps videos, I recommend you try Background Subtraction , to find people in the frames instead of people movements between the frames.如果您使用的是低 fps 视频,我建议您尝试使用背景减法来查找帧中的人物,而不是帧之间的人物移动。 For Background Subtraction, to solve对于背景减法,求解

All the 10 images are coming different also because the sun is setting down and hence due to "natural light variation" the 10 images from 10 minute frames after coming different even though there is no public/human movement.所有 10 个图像都不同也是因为太阳正在下山,因此由于“自然光变化”,即使没有公众/人类运动,来自 10 分钟帧的 10 个图像也不同。

you can try using the average image of all frames as the background_img in您可以尝试使用所有帧的平均图像作为background_img

difference = current_img - background_img

If the time span is longer, you can use the average of images more recent to current_img as background_img .如果时间跨度较长,您可以使用最近到current_img的图像的平均值作为background_img And keep updating background_img when running the video.并在运行视频时不断更新background_img

  1. If your ROI is a rectangle in the frame, use如果您的 ROI 是框架中的矩形,请使用

    my_ROI = cv::Rect(x, y, width, height) cv::Mat ROI_img= frame(my_ROI) my_ROI = cv::Rect(x, y, width, height) cv::Mat ROI_img= frame(my_ROI)

If not, try using a mask .如果没有,请尝试使用mask

I think what you are looking for is a Pedestrian Detection.我认为您正在寻找的是行人检测。 You can do this easily in Python with OpenCV package.您可以使用 OpenCV 包在 Python 中轻松完成此操作。

# Initialize a HOG descriptor
hog = cv2.HOGDescriptor()

# Set it for Pedestrian Detection
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())

# Then use the detector
hog.detectMultiScale()

Exemple : Pedestrian Detection OpenCV示例: 行人检测 OpenCV

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM