Introduction

I was thrown a challenge by one of my colleagues — build a computer vision model that could insert any image in a video without distorting the moving object. This turned out to be quite an intriguing project and I had a blast working on it.

Working with videos is notoriously difficult because of their dynamic nature. Unlike images, we don’t have static objects that we can easily identify and track. The complexity level goes up several levels — and that’s where our hold on image processing and computer vision techniques comes to the fore.

I decided to go with a logo in the background. The challenge, which I will elaborate on later, was to insert a logo in a way that wouldn’t impede the dynamic nature of the object in any given video. I used Python and OpenCV to build this computer vision system — and have shared my approach in this article.

Table of Contents

  1. Understanding the Problem Statement
  2. Getting the Data for this Project
  3. Setting the Blueprint for our Computer Vision Project
  4. Implementing the Technique in Python — Let’s Add the Logo!

Understanding the Problem Statement

This is going to be quite an uncommon use case of computer vision. We will be embedding a logo in a video. Now you must be thinking — what’s the big deal in that? We can simply paste the logo on top of the video, right?

However, that logo might just hide some interesting action in the video. What if the logo impedes the moving object in front? That doesn’t make a lot of sense and makes the editing looks amateurish.

Therefore, we have to figure out how we can add the logo somewhere in the background such that it doesn’t block the main action going on in the video. Check out the video below — the left half is the original video and the right half has the logo appearing on the wall behind the dancer:

This is the idea we’ll be implementing in this article.

Getting the Data for this Project

I have taken this video from pexels.com, a website for free stock videos. As I mentioned earlier, our objective is to put a logo in the video such that it should appear behind a certain moving object. So, for the time being, we will use the logo of OpenCV itself. You can use any logo you want (perhaps your favorite sports team?)

#python #opencv #object-detection #data-science #computer-vision

A Classic Computer Vision Project — How to Add an Image Behind Objects in a Video
1.25 GEEK