I need to detect the main (front) car in the image to put it in another image with no or plain background. Below is an example image:
I am developing in Python 3 with OpenCV 4.
I tried HaarCascade, but it does not work well, even with many different hyper parameters in 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)