python - opencv 包 python numpy

标签 python opencv numpy

<分区>

import numpy as np
import cv2
import os
import math

webcam=cv2.VideoCapture(0)
frame = webcam.read()
webcam.release()
detector =cv2.CascadeClassifier("xml/frontal_face.xml")
scale_factor=1.2
min_neighbors=5
min_size=(30,30)
biggest_only= True
flags= cv2.CASCADE_SCALE_IMAGE
#print type(frame)
flags =cv2.CASCADE_FIND_BIGGEST_OBJECT | cv2.CASCADE_DO_ROUGH_SEARCH if biggest_only else cv2.CASCADE_SCALE_IMAGE

face = detector.detectMultiScale(
        frame,
        scaleFactor=1.1,
        minNeighbors=5,
        minSize=(30, 30),
        flags=flags)

错误:

File "C:\Users\DELL\workspace\facedetect\detect.py", line 23, in flags=flags) TypeError: image is not a numerical tuple

最佳答案

如果您看到 THIS LINK ,它声明行 webcam.read() 返回两个值。

你应该考虑把这行改成这样:

ret, frame = webcam.read()

frame 变量返回从视频中获取的图像帧。

ret 变量返回一个 bool 值 (True/False),指示帧是否已被正确读取。

关于python - opencv 包 python numpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41392911/

相关文章:

python - 在 Tastypie 中以 JSON 形式返回异常错误

python - 将列表项与上一项连接

python - 当我 easy_install greenlet 时,我得到 "error: Setup script exited with error: command ' gcc' failed with exit status 1 "

c++ - 将 cv::Mat 转换为 Magick::Image

c++ - cvQueryFrame() 在文件结束前返回 NULL

python - 使用 aptitude 安装包时的多个版本的 python

Python assertItemsEqual/assertCountEqual 属性错误

python - OpenCV python FlannBasedMatcher 添加多个描述符

python - 从 numpy 数组 python 中提取索引

python - 自动从csv文件中提取数据到特定的矩阵位置