Gman Gman - 2 years ago 65
Python Question

what is the simple way to find the color of main object in an image

I am developig a vehicle color identifier.The image frame is always 400*300 size.and the vehicle is always at center.How to get the colour of that vehicle only.If vehicle is red it must output red.

Answer Source

If the image size is fixed and If you are sure about its position.You can use

crop_img = img[50:150, 100:200]

to crop a square from center.Then you can find its RGBA value and from RGBA value you can find its colour.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download