I need to develop an algorithm to remove a background from the foreground image. I would like to use chroma keying. This will be done on a live camera stream and I need to do it using OpenCV in C++.
The algorithm I thought would be something like:
I would like some help on a method to remove a plain color background from foreground image without the color from the foreground image being removed.
Is there like a special type of crop function to remove background?
I'm using OpenCV from Python. Suppose you followed a basic tutorial and have the frame from the camera and have a background image. A single line of code should do the trick with the numpy's where function.
outputImage = np.where(frame == (10,255,10), background, frame)
Now the outputImage contains the original frame where it wasn't green and your background image where it was green. As you said, you should use some tolerance.