opencv/python: Draw image over a webcam stream

Cap.Alvez picture Cap.Alvez · Jan 26, 2013 · Viewed 15.1k times · Source

Hey everyone I'm trying to make a game using my webcam where I need some objects to fall down the screen while Im streaming video with my webcam (that stream being my background).

The question is: how do I draw the image over this background? I know how to capture each frame and that I have to draw the image over the frames, but using what?

  • For this I am using python and opencv and the cv2 module.
  • Ive already searched and I discovered that you can use regions of interest to do that but I am using cv2 and it is said that using the numpy arrays that is much simpler.. but I dont understand how to do that..

Can anyone give me some tips or examples of how to do this?

Thanks in advance!

Answer

b_m picture b_m · Jan 26, 2013

Here's an example. It shows how to overlay transparent images too. You can use the built in draw functions as well. There's a neat little trick to draw transparent shapes too.