如何创建精确的Python行人检测器? [英] How do I create an accurate Python pedestrian detector?

查看:331
本文介绍了如何创建精确的Python行人检测器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该怎么做?示例代码会有所帮助。这是一个简单的跟踪应用程序。一个步行者走上街道,程序应该放置一个边界框。这应该是实时的,并且我已经尝试过其他例子,例如opencv提供的例子,它们太慢或太错了。



感谢您抽出宝贵时间阅读此内容



编辑:这是功能非常慢的python代码。你需要行人xml haar级联。



How would I do this? Example code would be helpful. It's a simple tracking application. A pedestrian steps onto the street and the program should place a bounding box. This should be in real time and thougb I have tried other examples such as the one provided by opencv, they're all too slow or way too wrong.

Thanks for taking the time to read this

This is the very slow functioning python code. You need the pedestrian xml haar cascade.

import numpy
import cv2
import sys
import time

cascPath = "pedestrian.xml"
#cascPath1 = "cascades/haarcascade_stop.xml"

faceCascade = cv2.CascadeClassifier(cascPath)
#stopCascade = cv2.CascadeClassifier(cascPath1)


video_capture = cv2.VideoCapture(1)
time.sleep(2)

while True:
    # Capture frame-by-frame
    ret, frame = video_capture.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    body = faceCascade.detectMultiScale(
                gray,
		scaleFactor=1.1,
		minNeighbors=10,
	   
    )
#    stop = stopCascade.detectMultiScale(
#                gray,
#                scaleFactor=1.2,
#                minNeighbors=10
#    )

    # Draw a rectangle around the faces
    for (x, y, w, h) in body:
        cv2.rectangle(frame, (x, y), (x+w, y+h), (255, 255, 0), 4)
#    for (x, y, w, h) in stop:
        
    # Display the resulting frame
    cv2.imshow('Video', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()

<pre lang="Python">

推荐答案

没有人会为您提供简单的答案对此。快速跟踪人体物体是最前沿的科学。



1.进行研究并找出可能的结果。用你的努力你不可能超过这个。谷歌充满了材料。



2.开发出符合您要求的算法。对于这个python和opencv很好,即慢速检测。



http://stackoverflow.com/questions/16673698/people-detection-and-tracking [ ^ ]



https://www.youtube.com/watch?v=AKLEuAtFDXQ [ ^ ]



3.通过优化代码(可能是c ++)提高性能,也许改进硬件。
Nobody will supply you with a simple answer to this. Fast tracking of human objects is cutting edge science.

1. Do your research and find out what is possible. You are unlikely to exceed that with your effort. Google is replete with material.

2. Develop an algorithm that meets your requirements. For this python and opencv is fine i.e. slow detection.

http://stackoverflow.com/questions/16673698/people-detection-and-tracking[^]

https://www.youtube.com/watch?v=AKLEuAtFDXQ[^]

3. Improve the performance by optimising the code (maybe c++) and perhaps improving hardware.


当然没有简单的答案,但有一个想法:也许你只需要一个运动探测器。逻辑是:如果你永久地监视道路,行人在没有动作的情况下就无法进入视野。通常,比所有这些图像特征更容易检测到运动。然后你可以使用光流概念: http:// opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.html [ ^ ]。



即使你'我回答说,汽车和骑车人不是问题,我无法理解它是如何实用的。无论如何,需要区分行人和其他玩家,这可能会使问题变得非常复杂。



-SA
No simple answers, of course, but there is one idea: perhaps you only need a motion detector. The logic would be: if you monitor the road permanently, a pedestrian cannot get in the view without the motion. Normally, motion is easier detected than all those image features. Then you could use, say, the optical flow concept: http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.html[^].

Even though you've answered me that the cars and cyclists are not a problem, I cannot understand how it could be practical. Anyway, a need to discriminate pedestrians and other players, it can make the problem extremely complex.

—SA


这篇关于如何创建精确的Python行人检测器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆