Tags

, , , , , , , , , , , , ,

In my last post, I was able to direct a movie fight scene using webcams at 0 degrees, 90 degrees, 180 degrees and 270 degrees.

In this post I will direct a killer robot scene with the following camera angles:

MovieDirectorUsingPythonMarkII_AllCameras

As you can see, we have 4 webcams plugged into a single PC. One at ground level:

MovieDirectorUsingPythonMarkII_GroundCamera

One from above:

MovieDirectorUsingPythonMarkII_AboveCamera

One from the side:

MovieDirectorUsingPythonMarkII_SideCamera

And one from a railway track:

MovieDirectorUsingPythonMarkII_TrackCamera

I can push the toy train along the track and the camera will pan across the scene as it unfolds!

Let’s take a peek at what each camera can see. Here’s a shot from the ground level camera:

MovieDirectorUsingPythonMarkII_GroundShot

A shot from the camera above:

MovieDirectorUsingPythonMarkII_AboveShot

A shot from the camera at the side:

MovieDirectorUsingPythonMarkII_SideShot

And a shot from the railway tracks:

MovieDirectorUsingPythonMarkII_TrackShot

Okay, so we are ready to film the killer robot scene. My post Camera angles with OpenCV explains how to use OpenCV to capture frames from each of the 4 webcams simultaneously. As each frame is captured, we can save it to disk e.g.

cv2.imwrite('ground/image_{}.jpg'.format(counter), ground_image)

Great, we have the killer robot scene filmed from 4 angles: ground, above, side and track.

Now I can use the code in my last post Be a Movie Director using Python to replay the scene. Google Speech Recognition uses the words I utter into my computer microphone to cut between camera angles. Take a look as the robot terrorizes Lego policemen at a woodland hospital:

As the director, I say “above” and the camera angle cuts to a bird’s-eye view. Next, I say “side” and the camera angle cuts to a side shot. Finally, I say “track” and the camera angle cuts to a panning shot courtesy of the railway track.

I’ve shot the scene in slow-mo with the following OpenCV function:

cv2.waitKey(100)

The video above then shows the whole scene from each camera angle, at a normal speed of cv2.waitKey(35)

So there you have it – with a bit of Python code and 4 webcams we can direct a movie from multiple camera angles. Next up, let’s try using OpenCV computer vision and OpenGL graphics library to create some special effects!

Very Intergalactic.

Ciao!

P.S.

To avoid frame lag when reading frames from a webcam, employ a thread. The Webcam class on GitHub – which is part of the SaltwashAR Python Augmented Reality application – is an example of reading a webcam frame from within a thread.

Advertisements