【发布时间】:2021-01-04 22:19:39
【问题描述】:
我需要检测图像中的主要(前)汽车,以将其放入另一个没有背景或背景简单的图像中。 下面是一个示例图像:
我正在使用 Python 3 和 OpenCV 4 进行开发。
我尝试了 HaarCascade,但效果不佳,即使在 detectMultiScale 中有许多不同的超参数:
car_cascade = cv2.CascadeClassifier('./haarcascade/haarcascade_car.xml')
car_detected = car_cascade.detectMultiScale(img_gray1, 2.2, 4)
cars_with_detections = np.copy(img1)
for (x, y, w, h) in car_detected:
cv2.rectangle(cars_with_detections, (x, y), (x+w, y+h), (255, 0, 0), 5)
plt.figure(figsize=(25,15))
plt.imshow(cars_with_detections)
【问题讨论】:
-
你确定“haarcascade_car.xml”可以正常工作吗?
标签: python opencv image-processing computer-vision haar-classifier