问题描述
我需要检测图像中的主要(前部)汽车,以将其放置在无背景或纯背景的另一幅图像中。 下面是一个示例图片:
我正在使用OpenCV 4在Python 3中进行开发。
我尝试了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),5)
plt.figure(figsize=(25,15))
plt.imshow(cars_with_detections)