python热成像_基于热成像凸轮的OpenCV-HOG方法的可靠行人检测

本文介绍了尝试使用OpenCV的HOG检测器在Python中从热成像摄像机捕获的帧中检测行人的经历。虽然存在检测不稳定性,作者询问是否可以调整现有代码(如peopledetect.py)以提高效果,或者寻求预处理方法和其他OpenCV行人检测策略的建议。
摘要由CSDN通过智能技术生成

我使用以下示例(opencv-2.4.11/samples/python2/peopledetect.py)从OpenCV检测行人。在#!/usr/bin/env python

import numpy as np

import cv2

help_message = '''

USAGE: peopledetect.py ...

Press any key to continue, ESC to stop.

'''

def inside(r, q):

rx, ry, rw, rh = r

qx, qy, qw, qh = q

return rx > qx and ry > qy and rx + rw < qx + qw and ry + rh < qy + qh

def draw_detections(img, rects, thickness = 1):

for x, y, w, h in rects:

# the HOG detector returns slightly larger rectangles than the real objects.

# so we slightly shrink the rectangles to get a nicer output.

pad_w, pad_h = int(0.15*w), int(0.05*h)

cv2.rectangle(img, (x+pad_w, y+pad_h), (x+w-pad_w, y+h-pad_h), (0, 255, 0), thickness)

if __name__ == '__main__':

import sys

from glob import glob

import itertools as it

print help_message

hog = cv2.HOGDescriptor()

hog.setSVMDetector( cv2.HOGDescriptor_getDefaultPeopleDetector() )

for fn in it.chain(*map(glob, sys.argv[1:])):

print fn, ' - ',

try:

img = cv2.imread(fn)

except:

print 'loading error'

continue

found, w = hog.detectMultiScale(img, winStride=(8,8), padding=(32,32), scale=1.05)

found_filtered = []

for ri, r in enumerate(found):

for qi, q in enumerate(found):

if ri != qi and inside(r, q):

break

else:

found_filtered.append(r)

draw_detections(img, found)

draw_detections(img, found_filtered, 3)

print '%d (%d) found' % (len(found_filtered), len(found))

cv2.imshow('img', img)

ch = 0xFF & cv2.waitKey()

if ch == 27:

break

cv2.destroyAllWindows()

不幸的是,检测结果似乎不稳定,因为行人是在某些帧上检测到的,而在与第一帧非常相似的其他帧上检测不到,如下图所示。在

我的问题我可以使用OpenCV的HOG实现来检测从热相机捕捉到的帧上的行人吗?在

如果是,如何调整OpenCVpeopledetect.py为了得到更好的结果?在

否则,请给出您对预处理方法的建议或使用OpenCV的行人检测方法的其他说明。在

谢谢你们!在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值