1 | initial version |
I think it doesn't draw the rectangle because the perspective transformed isn't found. Check the transformed points as well as the matrix H. By the way, you should probably try to display a smaller bounding box instead of the full image, which seems almost the same size as destination image.
Some comments on the algorithmic part: 1) use reference as much as you can, and protected them with const if needed. 2) Compute only one time the keypoints and descriptors of your reference image, and give the results to the matching function; as the reference image is never changing, no need to recomputed keypoints and descriptors all the time. You will speed up your results. 3) Are you sure, your approach is appropriated? An object detection approach, with machine learning stage will probably give better results on live stream; train it with multiple view of the car (or cars if you want to retrieve different cars). See SVM tutorial for example.
And last, but not least, don't send all your code, only interesting parts. If it lacks some information, people will ask for the missing parts.