Close

OpenCV automated PTZ camera control

A project log for Computer controlled TV station and cameras

Extra TV channels for a retirement home's MATV network, with automated playback control of internal event camera streams and video library.

haydenhayden 05/29/2023 at 10:390 Comments

The next stage was to develop the software and hardware solution required to automate the use of the cameras PAN/TILT & 20x Optical ZOOM features via its IP control API/Interface

It was decided to use a dedicated second camera that could always see the full scene, rather than running CV/Image recognition on the main camera, because if the main camera was zoomed in on a performer it would not see some action outside of its vision to zoom out to capture.

I set up a raspberry pi 3 and camera running openCV software and a simple python change/movement detect loop to watch a chosen section of the pi camera (excluding audience at bottom of screen) . This then calculated a target and zoom level to command the PTZ camera to focus on.

There was also a time sequence to for example every 5 minutes zoom right at and do a slow pan left and right to 'look around' before resuming focus on the main action.

The Pi had a calibrated conversion table to convert its pixel coordinates into corresponding tracking commands and zoom levels for the PTZ camera.

Ive since switched the pi and camera combo for a ip camera, and made it that the opencv script is run by the "Live Streams" computer that receives the PTZ stream.

test of pi and pi camera
vnc into pi to monitor it
prev image zoomed in, showing bottom right screen of vision from opencv camera and movement detect, vision from ptz camera top left

after successful test, pi put in roof, and camera mounted on stand

pi & camera combo replaced with ip camera

Discussions