Unlocking the Power of PTZ Cameras: Automating the SONY SRG-300SE for Cutting-Edge Applications

VAIBHAV GANDOTRA
4 min readOct 30, 2023

--

“It is only natural that sometimes we fall sick. There is no reason to allow yourself to be controlled by illness, for it to fill your life with suffering and distress. From the standpoint of eternal life through the three existences, your fundamentally happy self is incontrovertibly established” — Daisaku Ikeda

Sony PTZ Cameras come with a wide range of features and a great potential for out-of-the-box applications

Introduction:

PTZ (Pan, Tilt, Zoom) cameras are versatile tools with applications ranging from video surveillance to live streaming and lecture recording. The SONY SRG-300SE is a popular PTZ camera with rich features, making it ideal for professional settings. This guide will walk you through automating this camera using CGI commands, focusing on a practical application.

1. Setting up Your Environment:

Before automating the SONY SRG-300SE, ensure your environment is ready. Here are the key elements:

Python Libraries:

You’ll need the ‘requests’, ‘open-cv’, and ‘time’ libraries for sending CGI commands and handling time-related functions; if you are using Python scripting

2. Understanding CGI Commands:

Common Gateway Interface (CGI) commands allow you to communicate with the SONY PTZ camera’s web-based interface. Here’s the syntax:

http://<camera_address>/command/<cgi>?<parameter>=<value>[&<parameter>=<value>…]

- `<camera_address>` is the camera’s HTTP address.

- `<cgi>` can be ‘camera.cgi’ or ‘inquiry.cgi’ for different actions or information, respectively.

3. Available CGI Commands:

The SONY SRG-300SE offers 21 different commands to unleash its full potential. Some examples include ‘preset position’ for storing and recalling specific camera positions, ‘iplimit’ for IP address information, and ‘imaging’ for adjusting image parameters.

4. Writing CGI Commands:

Types of CGI Commands (*Only Commands*):

  • AbsolutePTZF: The ‘parameter’ takes 4 values in hexadecimal indicating Pan Position, Tilt Position, Zoom, and Focus respectively on absolute coordinates
  • AbsolutePanTilt: The ‘parameter’ takes 3 values in hexadecimal for Pan, Tilt, & Movement Velocity (from 1 to 24). The value of Maximum Movement Velocity is subject to zoom.
  • AbsoluteZoom: Takes one unsigned hexadecimal value. The camera has 30x optical zoom and up to 12x digital zoom. Values range from 0000 to 4000 (max optical zoom) to 7ac0 (max digital zoom)
  • ContinousPanTiltZoom: The parameter takes 4 values for Pan speed, Tilt speed, Zoom Speed, and the target video codec instance
  • Move: (i) Value1 = ‘left’ or ‘right’ or ‘down’ or ‘up-left’ or ‘up-right’ or ‘down-left’ or ‘down-right’ or ‘tele’ or ‘wide’ or ‘near’ or ‘far’ or ‘stop’ or ‘onepushaf’ ; (ii) Value2 = value always less than or equal to PanTiltMaxVelocity and ZoomMaxVelocity; (iii) Value3 = target video codec instance (i.e., Image<n>)
  • AreaZoom: (i) Value1 = the distance of x-direction from center (ii) Value2 = the distance of y-direction from the centre (iii) Value3= Width (iv) Value4 = Height (v) Value5 = target video codec instance
  • Relative: As you can tell; it denotes the movement value of the PTZ Camera relative to position using two values. The first value combines two values (integer value)- XXYY. XX indicates the direction of movement and YY indicates the amount of displacement based on the current video size. Value2 is the target video codec instance. It is ‘Image1’ by default.
  • RelativeFocus: The parameter takes a single value in 32-bit signed hexadecimal format and executes a focus movement with the relative direction and the amount from the current position for mechanical pan/tilt models.
  • RelativePanTilt: As for Relative and Relative_Focus this value denotes relative pan/tilt movement based on current position. The parameter takes 4 values:- Pan, Tilt, Speed, and ‘Image1’ (i.e., the default setting for target video codec instance)
  • RelativeZoom: The parameter takes two values; one for relative zoom in signed hexadecimal value and one for ‘Image1’
  • PresetCall: This is the most used parameter for the camera. Mostly for security, surveillance, and live streaming instances, we can set a tour of various set positions such that it will move in a loop and exhaust the whole area using a minimum number of these cameras. The parameter calls preset positions using two values:- (i) Value1 calls the registration ID number you set for the position and (ii) Value2 indicates the movement speed defined i.e., between 1 and PresetNum
  • PresetSet: This parameter registers the current PTZF position as a preset position using 3 Values; from ‘Value1’ to ‘Value3’ indicates the registration ID number to be set, the name of the preset position, and, whether to use the current image as a thumbnail (“yes” or “no”)
  • PresetName: The parameter sets the name of the preset positions only using Value1 and Value2 only. Same as above

5. Practical Use Cases:

The SONY SRG-300SE’s automation can benefit various real-world applications, including:

- Live Streaming and Recording

- Video Conferencing

- Security Surveillance

- Lecture Recording

- Machine Learning-based Applications

For instance, you can use it for tracking objects or people using ML algorithms.

Source: Google Search

6. Conclusion:

CGI commands empower you to unlock the full potential of the SONY SRG-300SE PTZ camera. Its wide range of functions and precise control capabilities make it a powerful tool with applications spanning security, medical procedures, and beyond. By automating it, you bring a new level of flexibility and functionality to your professional projects, i.e., you can probably use it for surveillance and face tracking systems, which I intend to do and publish about on medium in upcoming articles. If you are excited about such coverage, then you can follow me and also read my previous articles on SONY PTZ Camera: Link1 and Link2

End Note:

As technology advances, PTZ cameras like the SONY SRG-300SE continue to play a vital role in enhancing various industries, and automation is at the forefront of this evolution.

--

--