Skip to content

Dtanguy/PTZControl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PTZControlWS

WebSocket-based PTZ Camera Controller for Logitech cameras. This project is a fork of xMRi/PTZControl, reimagined as a headless WebSocket server with a web interface. Thanks to xMRi for the original PTZ control implementation and Logitech camera interface work.

Web UI

A Vue 3-based web interface is included in web-ui/ for easy camera control via browser. Features live MJPEG streaming, PTZ controls, zoom, and preset management.

Web UI Screenshot

cd web-ui
npm install
npm run dev

The UI connects to ws://localhost:8765 and provides an intuitive interface for all camera functions.

Building

Requires Visual Studio 2022 with C++ Desktop Development workload.

MSBuild PTZControlWS\PTZControlWS.sln /p:Configuration=Release /p:Platform=x64

Output: PTZControlWS\x64\Release\PTZControlWS.exe

Hardware Modification

USB-C Connector Mod

For easier connectivity, i have replaced the original connector with a standard USB-C port. This involves unsoldering it and wiring a USB-C module directly to the camera board.

Original Pinout Reference:

PTZ Pro 2 Cable Pinout

Modification Process:

I used this USB-C module for the mod:

USB-C module

Amazon link: https://amazon.fr/dp/B0DL5JJS5T?ref=fed_asin_title

Soldering step 2

Final result

Power Requirements

Important: The camera is designed for 12V operation. However, it functions at 5V USB power in my testing. use at your own risk. While it works for my setup, running below spec voltage may affect longevity or functionality.

Usage

PTZControlWS.exe [options]

Options:
  -p, --port <port>      WebSocket port (default: 8765)
  -n, --no-auto-connect  Don't auto-connect to cameras on startup
  -h, --help             Show help

WebSocket API

Connect to ws://localhost:8765 and send JSON commands:

Camera Management

// List all video devices
{"command": "list"}

// Auto-connect to supported PTZ cameras
{"command": "connect"}

// Connect to specific camera by index
{"command": "connect", "params": {"index": 0}}

// Connect by name filter
{"command": "connect", "params": {"name": "PTZ"}}

// Disconnect all cameras
{"command": "disconnect"}

// Select active camera (when multiple connected)
{"command": "select", "params": {"index": 0}}

// Get current status
{"command": "status"}

PTZ Controls

// Pan: 1 = right, -1 = left, 0 = stop
{"command": "pan", "params": {"direction": 1}}

// Continuous pan (holds until stop)
{"command": "pan", "params": {"direction": 1, "continuous": true}}

// Tilt: 1 = up, -1 = down, 0 = stop
{"command": "tilt", "params": {"direction": 1}}

// Zoom: 1 = in, -1 = out
{"command": "zoom", "params": {"direction": 1}}

// Get current zoom level
{"command": "zoom_level"}

// Go to home position
{"command": "home"}

// Stop all movement
{"command": "stop"}

Presets

// Recall preset (0-7)
{"command": "preset", "params": {"number": 0}}

// Save current position to preset
{"command": "preset", "params": {"number": 0, "save": true}}

Settings

// Get/set camera settings
{"command": "settings", "params": {
  "logitech_motion": true,    // Use Logitech motion control
  "motor_interval": 70        // Motor interval timer (ms)
}}

Streaming

// Start MJPEG stream (default port 8080)
{"command": "stream_start"}

// Start stream on custom port
{"command": "stream_start", "params": {"port": 8081}}

// Stop stream
{"command": "stream_stop"}

// Get stream status
{"command": "stream_status"}

The MJPEG stream is accessible at http://localhost:8080/stream.mjpeg (or your custom port).

Response Format

All commands return JSON:

{
  "success": true,
  "message": "Optional status message",
  "data": { /* Optional response data */ }
}

License

MIT License - See LICENSE file


Note: This README was generated with AI assistance.

About

This small program is designed to control a Logitech PTZ 2 Pro and Rally cameras.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C++ 72.5%
  • Vue 11.9%
  • CSS 11.5%
  • C 3.5%
  • Other 0.6%