我正在尝试使用CUDA和openCV4.4进行级联分类,但是当我运行detectMultiScale函数时,它会给我一个分段错误。我做错了什么
python中openCV for CUDA的文档有限,因此很难找到使用CUDA进行级联分类的正确过程
我的系统:
我想出的代码是:
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)
分类器_cuda和cuda_帧分别被识别为<cuda_GpuMat 0x7fffa9446d10> <cuda_CascadeClassifier 0x7fffa9446cf0>
通过将代码更改为:
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()
现在的问题是结果总是空的。那么,我应该如何从detectmultiscale中提取数据呢?我需要一个边界框列表[x,y,w,h]
output.download()
实际上对我有效,但如果没有检测到任何内容,它将None
我认为您的问题是需要将帧转换为
COLOR_BGR2GRAY
这应该起作用:
(OpenCV 4.4)
相关问题 更多 >
编程相关推荐