Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control PTZ Camera using HTTP request #161

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
set -ex
sudo apt install -y \
libopenblas-dev libopenblas0 \
libcurl4-openssl-dev \
|| true
export OPENBLAS_HOME=/lib/x86_64-linux-gnu/
cmake -S . -B build \
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ find_package(libobs REQUIRED)
find_package(obs-frontend-api REQUIRED)
include(cmake/ObsPluginHelpers.cmake)
find_qt(VERSION ${QT_VERSION} COMPONENTS Widgets Core Gui)
find_package(CURL REQUIRED)

if (WITH_DLIB_SUBMODULE)
set(CMAKE_POSITION_INDEPENDENT_CODE True)
Expand Down Expand Up @@ -92,6 +93,7 @@ set(PLUGIN_SOURCES
src/helper.cpp
src/ptz-backend.cpp
src/obsptz-backend.cpp
src/ptz-http-backend.cpp
src/dummy-backend.cpp
)

Expand Down Expand Up @@ -122,6 +124,7 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
OBS::libobs
OBS::obs-frontend-api
dlib
CURL::libcurl
${plugin_additional_libs}
)

Expand All @@ -136,6 +139,7 @@ if(OS_WINDOWS)
add_definitions("-D_USE_MATH_DEFINES")
add_definitions("-D_CRT_SECURE_NO_WARNINGS") # to avoid a warning for `fopen`
add_definitions("-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR") # TODO: Remove once requiring OBS 30.2 or later.
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX)
endif()

target_link_libraries(${CMAKE_PROJECT_NAME} OBS::w32-pthreads)
Expand Down
2 changes: 2 additions & 0 deletions ci/plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ BuildRequires: obs-studio-devel
BuildRequires: qt6-qtbase-devel qt6-qtbase-private-devel
BuildRequires: dlib-devel ffmpeg-free-devel sqlite-devel blas-devel lapack-devel
BuildRequires: flexiblas-devel
BuildRequires: libcurl-devel
# dlib-devel requires /usr/include/ffmpeg so that install ffmpeg-free-devel

%package data
Expand Down Expand Up @@ -68,6 +69,7 @@ mv %{buildroot}/%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/LICENSE-shape_predicto
%files
%{_libdir}/obs-plugins/@PLUGIN_NAME@.so
%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/locale/
%{_datadir}/obs/obs-plugins/@PLUGIN_NAME@/ptz/
%{_datadir}/licenses/%{name}/*

%files data
Expand Down
5 changes: 5 additions & 0 deletions data/locale/en-US.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Detector.dlib.hog="HOG, dlib"
Detector.dlib.cnn="CNN, dlib"
Prop.ptz.http.host="Host name"
Prop.ptz.http.host.desc="Host name and optionally port number, eg. 192.0.2.101:8080"
Prop.ptz.http.user="User name"
Prop.ptz.http.user.desc="Set if authentication is required. Leave blank if necessary."
Prop.ptz.http.passwd="Password"
25 changes: 25 additions & 0 deletions data/ptz/ptz-http-backend-camera-models.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"camera-models": [
{
"id": "hikvision",
"name": "HikVision PTZ (HTTP)",
"properties": {
},
"settings": {
"ptz-method": "PUT",
"ptz-url": "http://{host}/ISAPI/PTZCtrl/channels/1/continuous",
"ptz-payload": "<?xml version: \"1.0\" encoding=\"UTF-8\"?><PTZData><pan>{p}</pan><tilt>{t}</tilt><zoom>{z}</zoom></PTZData>"
},
"control-function": {
"p": { "type": "linear-int", "k1": 1.0, "k0": 0, "max": 15 },
"t": { "type": "linear-int", "k1": 1.0, "k0": 0, "max": 15 },
"z": { "type": "linear-int", "k1": 1.0, "k0": 0, "max": 3 },
"TODO": "\"max\" should be configurable."
}
},
{
"id": "sony-srg300se",
"name": "Sony SRG-300SE (HTTP)"
}
]
}
3 changes: 3 additions & 0 deletions src/face-tracker-ptz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifdef WITH_PTZ_TCP
#include "libvisca-thread.hpp"
#endif
#include "ptz-http-backend.hpp"
#include "dummy-backend.hpp"

#define PTZ_MAX_X 0x18
Expand Down Expand Up @@ -107,6 +108,7 @@ static const struct ptz_backend_type_s backends[] =
#ifdef WITH_PTZ_TCP
BACKEND("visca-over-tcp", libvisca_thread),
#endif // WITH_PTZ_TCP
BACKEND("http", ptz_http_backend),
BACKEND("dummy", dummy_backend),
{NULL, NULL, NULL}
#undef BACKEND
Expand Down Expand Up @@ -452,6 +454,7 @@ static obs_properties_t *ftptz_properties(void *data)
#ifdef WITH_PTZ_TCP
obs_property_list_add_string(p, obs_module_text("VISCA over TCP"), "visca-over-tcp");
#endif // WITH_PTZ_TCP
obs_property_list_add_string(p, obs_module_text("HTTP"), "http");
obs_property_set_modified_callback(p, ptz_type_modified);

obs_properties_add_bool(pp, "invert_x", obs_module_text("Invert control (Pan)"));
Expand Down
Loading