Object Detection in Infrared

Anuj shah (Exploring Neurons)
2 min readJan 5, 2019

--

As a matter of fact, 68% of the universe is dark energy and an image-processing engineer too can’t elude it. Whenever the darkness prevails we look towards Infrared Camera for our rescue.

However, unlike the visible camera, the input from the infrared camera only has a single channel (the image pixel intensity) and unfortunately (or fortunately, we can debate over this) most of the easily available pre-trained algorithms are trained on 3-channel RGB Images.

Recently I had to do object detection in dark and I had my infrared camera with me. The only missing piece was the object detection algorithm and I was too lazy to do everything from scratch, so I just started digging online and encountered the most common way to do object detection. You would have guessed by now and yes you are right — it’s the most popular TensorFlow object detection API. But as said, all the pre-trained models in this API are for RGB-colored input not for single-channel input.

After spending many sleepless nights (I am just kidding, it's the most obvious way) I came up with this:

The logic is to stack the single-channel infrared image 3 times to form a 3-channel input that can be easily fed into the pre-trained algorithms of TensorFlow object detection API.

I am using OpenCV, but you can use the same logic with any other library

The input can be prepared simply as

img = cv2.imread(‘img.png’,0)

say img is your array of single channel image,then

height, width = img.shape

img_new = np.zeros((height, width ,3), np.uint8)

img_new[:,:,0] = img

img_new[:,:,1] = img

img_new[:,:,2] = img

The img_new is your prepared image and from here you can follow the same steps as for RGB input to the object detection algorithm. You can look into my video on using the TensorFlow object detection API: https://www.youtube.com/watch?v=MoMjIwGSFVQ&t=687s

And surprisingly it works quite well even for the infrared input as evident from the image below. The link for the video is attached below.

P.S. I used the ssd_inception_v2 algorithm, you are free to use any depending on your computation power availability

Full video here: https://www.youtube.com/watch?v=rGkOKVz3blU

If you find my articles helpful and wish to support them — Buy me a Coffee

--

--