I am trying to do cascade classification using CUDA with openCV4.4 however when I run the detectMultiScale function it gives me a segmentation fault. What am I doing wrong?
There is limited documentation from openCV for CUDA in python, making it difficult to find the right procedure to do cascade classification using CUDA.
My system:
- Quadro P620
- Debian 6.3.0-18
- Python 3.5.3
- OpenCV 4.5.0 build with CUDA=ON, CUDNN=ON
The code I came up with:
vidcap = cv2.VideoCapture('video_file.mp4')
classifier_cuda = cv2.cuda_CascadeClassifier('cascades_file.xml')
while True:
success, frame = vidcap.read()
cuda_frame = cv2.cuda_GpuMat(frame)
result = classifier_cuda.detectMultiScale(cuda_frame)
print (result)
classifier_cuda and cuda_frame are respectively recognized as <cuda_GpuMat 0x7fffa9446d10> <cuda_CascadeClassifier 0x7fffa9446cf0>
This was resolved by changing the code to:
classifier_cuda = cv2.cuda.CascadeClassifier_create('model.xml')
while True:
success, frame = vidcap.read()
cuFrame = cv2.cuda_GpuMat(frame)
output2 = cv2.cuda_GpuMat()
output = classifier_cuda.detectMultiScale(cuFrame, output2)
# And then its unclear what to use to get the detections
# I Tried:
final = classifier_cuda.convert(output)
# And:
final = classifier_cuda.convert(output2)
# And:
final = output.download()
# And:
final = output2.download()
The problem now is that the result is all ways empty. So, how should I extract the data from my detectmultiscale? I need to have a list of boundingboxes [x,y,w,h].