pythonopencv检测行人_如何创建精确的Python行人检测器?

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

EDIT: 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()

 
 

解决方案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.

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值