@joraclista/ptz-edge-js
ptz-edge-js
API for controlling PTZ device on windows inside electron container
Running DEMO Application
npm installnpm start
Build c# project after changes in c# files:
In cmd of project root do one of the next options:
- run
tools\build.bat - run
dotnet build .\src\logitech-ptz-pro\PTZDevice.csprojand copy dll files frombin\Debugfolder to project root:copy /y .\src\logitech-ptz-pro\bin\Debug\*.dll - open
PTZDevice.csprojin Visual Studio, click 'Build Project' Option, again copy dll files to project root.
Publish npm package:
use npm publish --access public
Mind that only next files are included in npm package:
- DirectShowLib-2005.dll
- PTZDevice.dll
- index.js
- package.json
- README.md
So c-sharp source code is not included.
Usage inside your electron app
const ptz = require("@joraclista/ptz-edge-js");
ptz.getCameraZoomInfo('PTZ Pro 2', function(error, result) {
if (error) throw error;
console.log(JSON.stringify(result));
});
ptz.moveLeft('PTZ Pro 2', function (error, result) {
if (error) throw error;
console.log(result);
});
Available functions:
All function can be run synchronously or async.
To invoke function async, please pass callback as 2nd param: stop(name, callback)
To invoke function in sync, please pass true instead of callback: stop(name, true)
getCameraZoomInfo(name, callback), - returns min/max/current zoom, name - is a name of the camera device
moveLeft(name, callback), moves camera a little bit left
moveRight(name, callback),
moveUp(name, callback),
moveDown(name, callback),
zoomIn(name, callback),
zoomOut(name, callback),
startMoveUp(name, callback), - starts continuously moving camera Up until max Up position is reached or until user invokes stop function
startMoveDown(name, callback),
startMoveLeft(name, callback),
startMoveRight(name, callback),
stop(name, callback) - stops camera if it was moving up/down/left/right
+ getCameras(callback) returns array of cameras, from 1.0.6 version
Project dependencies
Project depends on https://github.com/agracio/electron-edge-js which for now supports Electron 11.x - Node.js v12.18.3 at max, so will not run for Node.js v14.x.y
To build electron-edge-js for later Node.js versions:
- Fork
electron-edge-jsrepo - Run in cmd:
tools\build.bat release 14.6.0where afterreleasedesired node version is specified. - Update lib/edge.js, tools/buildall.bat, tools/build.bat file to include supported Node version
- Submit pull request to main project
NB. For me described above steps worked after Python 3.7.* installation + setting --msvs_version 2019 in build.bat