小编hon*_*ell的帖子

Raspberry Pi上的OpenCV人脸检测速度很慢

我正在使用OpenCV和Python编码测试Raspberry Pi.视频流效果很好(中等速度),但是当我在流上运行面部检测时,CPU被挂起并且刷新图像很慢.

这就是我所拥有的.如何优化我的代码?

#!/usr/bin/env python
import sys
import cv2.cv as cv
from optparse import OptionParser
min_size = (20, 20)
image_scale = 2
haar_scale = 1.2
min_neighbors = 2
haar_flags = 0

def detect_and_draw(img, cascade):
    # allocate temporary images
    gray = cv.CreateImage((img.width,img.height), 8, 1)
    small_img = cv.CreateImage((cv.Round(img.width / image_scale),
                               cv.Round (img.height / image_scale)), 8, 1)
                               cv.Round (img.height / image_scale)), 8, 1)

    # convert color input image to grayscale
    cv.CvtColor(img, gray, cv.CV_BGR2GRAY)

    # scale input image for faster processing
    cv.Resize(gray, small_img, cv.CV_INTER_LINEAR) …
Run Code Online (Sandbox Code Playgroud)

python webcam opencv raspberry-pi

7
推荐指数
1
解决办法
6758
查看次数

标签 统计

opencv ×1

python ×1

raspberry-pi ×1

webcam ×1