Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Python detectMultiscale

Hi guys can you give me advice about OpenCV? When I want to print out r to see rejectLevels it only print's out empty array.

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, sys, 
import 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

Can you give me some solution or experience on Opencv detectMultiScale, I looked into c++ code source and it's looking fine there, but in Python it wont work as it should be. OpenCV version: 2.4.8 Python version: 2.7.6

OpenCV Python detectMultiscale

Hi guys can you give me advice about OpenCV? When I want to print out r r to see rejectLevels it only print's out empty array.

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, sys, 
import 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

Can you give me some solution or experience on Opencv detectMultiScale, I looked into c++ code source and it's looking fine there, but in Python it wont work as it should be. OpenCV version: 2.4.8 Python version: 2.7.6

click to hide/show revision 3
retagged

updated 2014-05-17 15:27:16 -0600

berak gravatar image

OpenCV Python detectMultiscale

Hi guys can you give me advice about OpenCV? When I want to print out r to see rejectLevels it only print's out empty array.

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, sys, 
import 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

Can you give me some solution or experience on Opencv detectMultiScale, I looked into c++ code source and it's looking fine there, but in Python it wont work as it should be. OpenCV version: 2.4.8 Python version: 2.7.6