THIS is my small pet project, which I think can showcase a few somewhat creative ways of using OpenCV and image processing in general.


You’ve all heard about license plate recognition (heck, we have it on all speed cameras nowadays), but today we will take a look at another fun thing we can do with license plates — hide them from the preying eyes.

It’s not in my authority to explain why someone might want to remove the license plate from their car photos, if you’re interested go ahead google it on your own. From this point let’s just assume and agree that we want to do that.

I will be using Python and OpenCV to demonstrate how I did it, but the basic ideas behind it can be used in any other language/framework. Also I’d like to note that Python isn’t my “native” programming language so-to-say, and I apologize in advance for all the camelCase variable names you see, and some clumsiness in my code.

To break down the algorithm before we start coding:

  1. Detect where the license plate is located on our input image
  2. Approximate license plate’s background color
  3. Fill the license plate with the color we calculated

Let’s start by opening our image, we’ll take this beautiful RWB 911 as the main example here.

Image for post

We will need to open it as PIL image first, and then we can convert it to the OpenCV format:

from PIL import Image as imageMain
from PIL.Image import Image
import cv2
import numpy

imagePath = '../sample-images/1.jpg'
imagePil = imageMain.open(imagePath)
imageCv = cv2.cvtColor(numpy.array(imagePil), cv2.COLOR_RGB2BGR)
cv2.imshow('Original Image', imageCv)

Image for post

#image-processing #python #ai #opencv #computer-vision

License plate removal with OpenCV
3.35 GEEK