Facedetect does not detect any faces with OpenCL enabled (Bug #4275)


Added by Kevron Rees almost 10 years ago. Updated over 9 years ago.


Status:Open Start date:2015-04-12
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:ocl
Target version:-
Affected version:branch 'master' (3.0-dev) Operating System:Linux
Difficulty: HW Platform:x64
Pull request:

Description

Using the following code, I can get detection to work if I turn off OpenCL. However, with OpenCL on, I never get any faces.

import cv2
import numpy as np

cap = cv2.VideoCapture(0)

faceCascade = cv2.CascadeClassifier("/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt_tree.xml")

faces = []
img = None

def detectFaces():
    retval, img = cap.read()

    grayImg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    faces = faceCascade.detectMultiScale(grayImg, 1.1, 2)
    for (x, y, w, h) in faces:
        cv2.rectangle(img, (x, y), (x+w, y+h), (0, 255, 0), 2)

    cv2.imshow("Video", img)
    return faces

def testDetection():
    cv2.ocl.setUseOpenCL(False)
    while True:
        faces = detectFaces()
        if len(faces) > 0:
            print("face detected, punk")
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

I've tried different cascades: frontfacial_defaul.xml and even lbpcascase_frontalface.xml with the same results. OpenCL no work. CPU-only, works.


History

Updated by Steven Puttemans almost 10 years ago

Might be a leap to far, but in order to get the CUDA implementation to work, we added a GPU specific model folder, since the GPU implementation only seems to work with those models.
Can you please try using one of those models?

For 2.4 branch https://github.com/Itseez/opencv/tree/2.4/data/haarcascades_GPU
For master branch https://github.com/Itseez/opencv/tree/master/data/haarcascades_cuda

  • Status changed from New to Open

Updated by Kevron Rees almost 10 years ago

Steven Puttemans wrote:

Might be a leap to far, but in order to get the CUDA implementation to work, we added a GPU specific model folder, since the GPU implementation only seems to work with those models.
Can you please try using one of those models?

For 2.4 branch https://github.com/Itseez/opencv/tree/2.4/data/haarcascades_GPU
For master branch https://github.com/Itseez/opencv/tree/master/data/haarcascades_cuda

I do not have an nvidia GPU. I'm using Intel graphics hence why i'm playing with OpenCL. Do I still need GPU specific cascades?

Updated by Philip L almost 10 years ago

Updated by Kevron Rees almost 10 years ago

Philip L wrote:

seems like the cpu models should be the correct ones
https://github.com/Itseez/opencv/commit/302a5adcc20d96720248c23719f33d3da72886b3

Should I try these instead of the ones in master?

Updated by Philip L almost 10 years ago

no the ones in currently in the cascade folders are the correct ones for cpu and opencl thats what i just wanted to confirm.

Updated by Vadim Pisarevsky almost 10 years ago

  • Category set to ocl

Updated by Kevron Rees almost 10 years ago

Anyone been able to reproduce this?

Updated by Vadim Pisarevsky almost 10 years ago

face detection tests pass on my macbook pro with HD5200 running OSX and the live demo work well. We also run tests on AMD machine with discrete GPU. I know that other team runs it on Intel GPUs under Windows.

So - no, we are not able to reproduce it so far. Try Windows if you have access to one. I know that Linux OpenCL drivers for Intel chips are rather fresh, may be it's drivers that are to blame.

Updated by Vadim Pisarevsky almost 10 years ago

face detection tests pass on my macbook pro with HD5200 running OSX and the live demo work well. We also run tests on AMD machine with discrete GPU. I know that other team runs it on Intel GPUs under Windows.

So - no, we are not able to reproduce it so far. Try Windows if you have access to one. I know that Linux OpenCL drivers for Intel chips are rather fresh, may be it's drivers that are to blame.

  • Assignee set to Vadim Pisarevsky

Updated by Bruno Nascimento over 9 years ago

Im actually having issues on opencl cascade lbp code.
I trained a LBP cascade, where sometimes the cascade gets "stuck" at one particular position. no matter what the image is after that, the detection is always there.
someone else getting the issue?
this does not happen with opencl switched off.
im using a mac book pro, on windows x64. opencv 3.0.0

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4967

Also available in: Atom PDF