Search code examples
pythonopencvcascade-classifier

cv2.cuda_CascadeClassifier in python


I am attempting to use the Haarclassifier from opencv cuda, for this I found the object cv.cuda_CascadeClassifier. However, assigning cv.cuda_CascadeClassifier() to a variable spit the following error:

this object has no ''load'' attribute. I could successfully verify it by printing their dir() print(dir(cv.cuda_CascadeClassifier)).

Is there any other way to call this object or did anyone effectively exploite the cascadeclassifier with opencv cuda?

thx


Solution

  • This is most likely due to the use of a version of openCV between 4.0.0 and 4.3.0, In those versions cuda_CascadeClassifier was disabled. In 4.4.0 This functionallity was brought back. (https://github.com/opencv/opencv_contrib/pull/2554/files)

    Even though this seems to work fine in C++ it gives me a segmentation fault using the python wrapper using the following code:

    classifier_cuda = cv2.cuda_CascadeClassifier('cascades_file.xml')
    while True:
        success, frame = vidcap.read()
        cuFrame = cv2.cuda_GpuMat(frame)
        result = classifier_cuda.detectMultiScale(cuFrame)
        print (result) 
    

    Any solutions?