大家好,你能给我一些关于OpenCV的建议吗?当我想打印出r以查看rejectLevels时,它只打印出空数组。
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys, logging, time
import numpy as np
import cv2
import cv2.cv as cv
face_cacade = '../home/haarcascade_frontalface_default.xml'
xml = cv2.CascadeClassifier(face_cascade)
array_of_images = [] --> Some images
for image in array_of_images:
img = cv2.imread(image)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.equalizeHist(gray)
**r** = []
x = []
#cv2.CascadeClassifier.detectMultiScale(image, rejectLevels, levelWeights[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[, outputRejectLevels]]]]]]) → objects
faces = xml.detectMultiScale(image = img, rejectLevels = **r**, levelWeights = x ,scaleFactor=1.05, minNeighbors=1, minSize=(30, 30), flags = cv.CV_HAAR_SCALE_IMAGE)
file_out = open('/tmp/faces_score.txt','w+',0)
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),1)
roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]
print **r**, x
你能给我一些解决方案或经验上的Opencv detectMultiScale,我看了c++代码源代码,它看起来很好,但在Python它不会工作,因为它应该是。OpenCV版本:2.4.8Python版本:2.7.6
我不确定,如果我正确地看到这一点,如果不是,请纠正我,但不应该rejectlevels是一个浮点值吗?此外,您没有为或分配任何内容,这意味着它将始终是一个空数组并保持这种状态。我最近也用opencv python的detectmultiscale做了一些事情,我做的是:
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
其中1.3等价于rejectlevels。