Skip to content

Control webcam's gimbal, zoom, ai tracking, recording, wake status and many more from AutoHotkey or any other language that supports DLLCalls.

Notifications You must be signed in to change notification settings

elModo7/OBSBOT-Camera-Control-AHK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OBSBOT Camera Control Library

Control OBSBOT webcams (tested on Tiny 2 Lite) from AutoHotkey over OSC.
This repo provides an OBSBOTController class that talks directly to the camera via UDP/OSC using a custom build of OSC2AHK that supports sending more than two parameters.

The dll is compatible with other languages such as C++, C#, Python...

Usage example as "security camera":

LibreDeck

Features

  • Start/stop PC recording
  • Snap a photo to PC
  • Wake / Sleep
  • Reset gimbal
  • Zoom (0–100)
  • Field of View presets (e.g., 86° / 78° / 65°)
  • Mirror toggle
  • AI tracking controls (mode, lock)
  • AI “composition” mode (Headroom / Standard / Motion)
  • Direct gimbal control: speed, pan, pitch (uses multi-param OSC — requires the custom DLL)

Requirements

  • Windows (64-bit)
  • AutoHotkey v1.1+ 64-bit
  • Custom DLL: OSC2AHKv1.2.dll (modified OSC2AHK that adds a multi-param sender)
    • Functions used:
      • sendOscMessageInt — send one integer argument
      • sendOscMessageInts — send multiple integer arguments (non-standard; added by the custom build)

Place OSC2AHKv1.2.dll next to your script or somewhere on your system PATH.


Installation

  1. Clone or download this repository.
  2. Copy OBSBOTController.ahk into your project or include it.
  3. Ensure OSC2AHKv1.2.dll is available to the script (same folder is easiest).
  4. Make sure your OBSBOT Tiny 2 Lite is on the same network, with OBSBOT control service running and OSC function enabled.
  5. Make sure that you know its IP and OSC/UDP port and that firewall is not blocking the connection.

Quick Start

#NoEnv
#SingleInstance, Force

; Include the class (adjust path if needed)
#Include %A_ScriptDir%\OBSBOTController.ahk

; Replace with your camera's IP and port
ip   := "192.168.1.123"
port := 8999

cam := new OBSBOTController(ip, port)

; Wake the camera and center the shot a bit
cam.Wake()
cam.SetZoom(35)
cam.SetAIMode(1)              ; 0 Headroom, 1 Standard, 2 Motion
cam.SetTrackingMode(1)        ; see modes below
cam.SetAILock(1)              ; lock target

; Move gimbal (speed, pan, pitch)
; Ranges: speed 0–90, pan -129–129, pitch -59–59
cam.SetGimbal(45, 0, -10)

; Start/stop PC recording
cam.StartRecording()
Sleep, 5000
cam.StopRecording()

; Take a snapshot to PC
cam.TakePhoto()

; Put camera to sleep
cam.Sleep()
ExitApp

Class API

All methods send OSC to the camera using the given ip and port.

Constructor

cam := new OBSBOTController(ip, port)

Loads OSC2AHKv1.2.dll and stores network info.

General / Recording

Method OSC Address Value(s) Notes
StartRecording() /OBSBOT/WebCam/General/SetPCRecording 1 Start PC recording
StopRecording() /OBSBOT/WebCam/General/SetPCRecording 0 Stop PC recording
TakePhoto() /OBSBOT/WebCam/General/PCSnapshot 1 Trigger PC snapshot
Wake() /OBSBOT/WebCam/General/WakeSleep 1 Wake device
Sleep() /OBSBOT/WebCam/General/WakeSleep 0 Sleep device
ResetGimbal() /OBSBOT/WebCam/General/ResetGimbal 0 Recenter / reset gimbal

Image / Framing

Method OSC Address Value(s) Notes
SetZoom(v) /OBSBOT/WebCam/General/SetZoom 0–100 (int) Zoom percentage
SetFOV(v) /OBSBOT/WebCam/General/SetView 0 / 1 / 2 0→86°, 1→78°, 2→65°
SetMirror(v) /OBSBOT/WebCam/General/SetMirror 0 / 1 0 not mirrored, 1 mirrored

AI / Tracking (Tiny series)

Method OSC Address Value(s) Notes
SetTrackingMode(v) /OBSBOT/WebCam/Tiny/SetTrackingMode int See “Tracking Modes” below
SetAILock(v) /OBSBOT/WebCam/Tiny/ToggleAILock 0 / 1 1 lock, 0 unlock
SetAIMode(v) /OBSBOT/WebCam/Tiny/SetAiMode 0 / 1 / 2 0 Headroom, 1 Standard, 2 Motion

Tracking Modes (known values)

From the class comments:

  • 0No Tracking
  • 1Normal Tracking
  • Additional modes observed in firmware/UI (naming varies by app version):
    • Upper Body, Lower Body, Desk Mode, Whiteboard, Hand, Group, and possibly others.

Exact numeric mapping for all special modes can vary with firmware/app updates. Start with 0/1 and then test additional integers to confirm behavior on your device/firmware. (The method accepts a single integer.)

Direct Gimbal (multi-parameter)

; speed: 0–90, pan: -129–129, pitch: -59–59
cam.SetGimbal(speed, pan, pitch)
Method OSC Address Values (ints) Notes
SetGimbal(s,p,t) /OBSBOT/WebCam/General/SetGimMotorDegree speed, pan, pitch Uses sendOscMessageInts (custom DLL)

How it Works (OSC / DLL)

  • The class sends OSC packets over UDP to your camera (ip, port).
  • Single-value commands use sendOscMessageInt.
  • Multi-value commands (like SetGimbal) use sendOscMessageInts, which is not in the stock OSC2AHK — it’s part of your custom OSC2AHKv1.2.dll and enables passing more than two parameters.

Tips & Troubleshooting

  • Firewall: Allow outbound UDP traffic for your script if prompted.
  • IP/Port: Verify the camera’s IP and OSC/UDP port (same LAN as your PC).
  • AHK Version: Use AHK 64-bit v1.1+. The syntax in this repo is v1, not v2.
  • DLL loading: If the DLL fails to load, put OSC2AHKv1.2.dll in the same folder as your script.
  • Value ranges: Stay within the specified ranges (e.g., gimbal angles, zoom 0–100).
  • Firmware differences: Some AI/Tracking modes can shift IDs or names across updates — test on your device.

Example: Simple Hotkeys

#NoEnv
#SingleInstance, Force
#Include %A_ScriptDir%\OBSBOTController.ahk

ip := "192.168.1.123"
port := 8999
cam := new OBSBOTController(ip, port)

; F1: Wake & center
F1::
    cam.Wake()
    cam.ResetGimbal()
return

; F2: Standard composition, normal tracking
F2::
    cam.SetAIMode(1)          ; Standard
    cam.SetTrackingMode(1)    ; Normal Tracking
return

; F3: Zoom in a bit
F3::
    cam.SetZoom(60)
return

; F4: Snapshot
F4::cam.TakePhoto()

; F5: Sleep
F5::cam.Sleep()

Project Structure

.
├─ OBSBOTController.ahk   ; The AHK class (this repo)
└─ OSC2AHKv1.2.dll        ; Custom DLL enabling multi-param OSC (place alongside)

Credits


License

MIT License: https://mit-license.org/


Notes for Contributors

  • Keep addresses and value mappings in sync with OBSBOT app/firmware releases.
  • If you add new methods, please document:
    • OSC address
    • Value type/range
    • A short usage example

About

Control webcam's gimbal, zoom, ai tracking, recording, wake status and many more from AutoHotkey or any other language that supports DLLCalls.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published