Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Identifying black cars with OpenCV in Python

$
0
0
Hello, I'm using OpenCV in Python to identify cars in a parking lot. It works fine when the color of the car is different than black. Here is my code. It basically applies a canny and counts the white points: cv2.imshow("image", image) cv2.waitKey() # Gray scale and blur gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) gray = cv2.bilateralFilter(gray, 5, 10, 10) blur = cv2.GaussianBlur(gray,(5,5),0) cv2.imshow("blur", blur) cv2.waitKey() # Apply canny edged = cv2.Canny(blur, 30, 200) cv2.imshow("Edged", edged) cv2.waitKey() # Result points = cv2.countNonZero(edged) Here is the result for a white car: ![white car](http://i.imgur.com/cRnXEtT.png) But the code doesn't work well with the shadows of the others cars: ![shadows](http://i.imgur.com/BL9BNtB.png) And even worst with black cars: ![black car](http://i.imgur.com/ZNq0Vbw.png) How do I fix this problem? Do I need to change my method? Maybe the canny isn't the best. I'm using this image of the parking: ![parking](http://i.imgur.com/tCRX2u5.png) Any tip will be very helpful, Thanks

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>