IP Camera
Content
Introduction
Tested Devices
Run Device Service
IP Camera Setup
Device Service REST API Reference
Introduction
The EdgeX camera device service is designed to control/communicate ONVIF-compliant cameras that can be accessed via http. Use Device-Camera to find out those IP cameras in the local area network and manage the interaction between the EdgeX application and the network cameras. The current system supports the ability to capture still images from IP cameras.
There are two sets of APIs. One is used by the native EdgeX device service, and the other is a simple API designed to configure camera scan rules and retrieve scan results. The former listens on port 50010, and the latter listens on port 50011.
Tested Devices
This service has been tested with the following devices:
The tested devices with the following configuration:
GV-TBL2703 with firmware version: v1.0.1 2019-05-16
GV-TDR2700 with firmware version: v1.0.1 2018-07-24
VIVOTEK FD9360-H with firmware version: 0100p
Prerequisites for Ubuntu Linux
Install the latest version of the Docker engine to avoid vulnerabilities
(1) How to remove the current Docker installation
$ sudo apt-get remove --purge docker docker-engine docker.io -y |
(2) How to add the necessary repository
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg |
$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null |
(3) How to install the latest Docker engine
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y |
$ sudo apt-get update |
$ sudo apt-get install docker-ce docker-ce-cli containerd.io -y |
(4) Make sure your user is still a member of the docker group
$ sudo usermod -aG docker $USER |
(5) Install masscan (Mass IP port scanner)
$ sudo apt-get install masscan |
(6) Install arp - manipulate the system ARP cache
$ sudo apt-get install net-tools |
(7) Preparing EdgeX Stack
Please reference https://github.com/edgexfoundry/device-camera-go/tree/delhi#preparing-edgex-stack
Run Device Service
1.The camera device service runs on TCP port numbers 50010 and 50011. Before starting the service, open a command prompt and enter the below two commands to make sure that no one is using the port numbers.
Windows
netstat -na | look for "50010" |
Linux
netstat -na | look for "50011" |
Service | Port |
device-camera | 50010 |
Adv-REST-API | 50011 |
2. For Windows, please use the installed Windows batch scripts start_ds.bat and stop_ds.bat provided in the installation package to start or stop the device service.
3. Ubuntu platforms
Launch the EdgeX stack by checking
https://github.com/edgexfoundry/device-camera-go/tree/delhi#running-device-camera-go
Run the device-camera executable directly with root privileges, and note that the configuration file directory res/ must be the same path as the device-camera file.
4. After the device service is started, you could request to hit ping endpoint for check if device service is available. If yes, it returns a string: pong.
$ curl http://{hostip}:50010/api/v1/ping |
5. To check whether the ADV-REST-API is available, you can request scanning rules to confirm. If it is, the current scan rule is returned in JSON format.
$ curl http://{hostip}:50011/camscan.json |
IP Camera Setup
In addition to the setup and operation of the IP camera, please pay attention to the following points.
Make sure that the IP camera and EdgeX server are on the same local area network (LAN).
Configure 80 as the HTTP port of each IP camera.
Record the serial number, login account/password, and IP address.
Provide instructions for using the IP camera, such as nickname, location and purpose. This information will be used to build camtag.json.
Device Service REST API Reference
EdgeX device-camera
URI pattern
http://{hostip}:50010/api/v1/device/name/edgex-camera-onvif-{serialnumber}/{CommandId} |
http://{hostip}:50010/api/v1/device/{id}/{CommandId} |
Description
CommandId | Description |
onvif_profiles | ONVIF-compliant IP camera information with its queried capabilities |
Tags | Camera information and its tag data combined by serial number index |
hostip: The host ip address of the EdgeX device camera service running
serialnumber: The serial number of ONVIF camera
id: The ONVIF camera registered id in EdgeX core
Properties
The collection {CommandId} has the following properties:
CommandId | Type | Read/Write | HTTP Method |
onvif_profiles | JSON | R | GET |
tags | JSON | R | GET |
Example
1. Get the camera onvif_profiles:
Example Requests
http://127.0.0.1:50010/api/v1/device/name/edgex-camera-onvif-0002D18921E9/onvif_profiles
http://127.0.0.1:50010/api/v1/device/62620d189f8fc200016104aa/onvif_profiles
Example Response
{"id":"","pushed":0,"device":"edgex-camera-onvif-0002D18921E9","created":0,"modified":0,"origin":1650594198189,"schedule":null,"event":null,"readings":[{"id":"","pushed":0,"created":0,"origin":1650594198189,"modified":0,"device":"edgex-camera-onvif-0002D18921E9","name":"onvif_camera_metadata","value":"{"ip":"192.168.0.106:80","productname":"VIVOTEK","firmwareversion":"0100","serialnumber":"0002D18921E9","profiles":[{"ProfileName":"Profile8442","Formats":"H264","Resolutions":["1920","1080"],"RTSPPath":"rtsp://192.168.0.106:554/live1s1.sdp","ImagePath":"http://192.168.0.106:80/cgi-bin/viewer/video.jpg?channel=0\u0026streamid=0","ProfileToken":"Profile8442"},{"ProfileName":"Profile6707","Formats":"H264","Resolutions":["640","360"],"RTSPPath":"rtsp://192.168.0.106:554/live1s2.sdp","ImagePath":"http://192.168.0.106:80/cgi-bin/viewer/video.jpg?channel=0\u0026streamid=1","ProfileToken":"Profile6707"}],"tags":"nickname:onvif3,location:room3","ScannedTimes":0}"}]} |
2. Find EdgeX registered id from the available EdgeX core commands using your device name:
Example Requests
http://127.0.0.1:48082/api/v1/device/name/edgex-camera-onvif-0002D18921E9
Example Response
{"id":"62620d189f8fc200016104aa","name":"edgex-camera-onvif-0002D18921E9","adminState":"UNLOCKED","operatingState":"ENABLED","lastConnected":0,"lastReported":0,"labels":[],"location":null,"commands":[{"created":1650003530589,"modified":0,"origin":0,"id":"62590e4a9f8fc200018ff341","name":"tags","get":{"path":"/api/v1/device/{deviceId}/tags","responses":[{"code":"200","description":"Get Tags","expectedValues":["cameradevice_tags"]},{"code":"503","description":"Get Tags Error","expectedValues":["cameradevice_error"]}],"url":"http://edgex-core-command:48082/api/v1/device/62620d189f8fc200016104aa/command/62590e4a9f8fc200018ff341"},"put":{"path":"/api/v1/device/{deviceId}/tags","responses":[{"code":"200","description":"Set Tags","expectedValues":["cameradevice_id"]},{"code":"503","description":"Set Tags Error","expectedValues":["cameradevice_error"]}],"parameterNames":["cameradevice_tags"],"url":"http://edgex-core-command:48082/api/v1/device/62620d189f8fc200016104aa/command/62590e4a9f8fc200018ff341"}},{"created":1650003530590,"modified":0,"origin":0,"id":"62590e4a9f8fc200018ff342","name":"onvif_profiles","get":{"path":"/api/v1/device/{deviceId}/onvif_profiles","responses":[{"code":"200","description":"Get ONVIF Profiles","expectedValues":["onvif_camera_metadata"]},{"code":"503","description":"Get ONVIF Profiles Error","expectedValues":["cameradevice_error"]}],"url":"http://edgex-core-command:48082/api/v1/device/62620d189f8fc200016104aa/command/62590e4a9f8fc200018ff342"},"put":{"path":"/api/v1/device/{deviceId}/onvif_profiles","responses":[{"code":"200","description":"Set ONVIF Profiles","expectedValues":["onvif_camera_metadata"]},{"code":"503","description":"Set ONVIF Profiles Error","expectedValues":["cameradevice_error"]}],"parameterNames":["onvif_camera_metadata"],"url":"http://edgex-core-command:48082/api/v1/device/62620d189f8fc200016104aa/command/62590e4a9f8fc200018ff342"}}]} |
3. Get the camera tags:
Example Requests
http://127.0.0.1:50010/api/v1/device/name/edgex-camera-onvif-0002D18921E9/tags
http://127.0.0.1:50010/api/v1/device/62620d189f8fc200016104aa/tags
Example Response
{"id":"","pushed":0,"device":"edgex-camera-onvif-0002D18921E9","created":0,"modified":0,"origin":1650594337132,"schedule":null,"event":null,"readings":[{"id":"","pushed":0,"created":0,"origin":1650594337132,"modified":0,"device":"edgex-camera-onvif-0002D18921E9","name":"cameradevice_tags","value":"nickname:onvif3,location:room3"}]} |
ADV-REST-API
URI pattern
http://{hostip}:50011/{CommandId} |
Description
CommandId | Description |
advinfocache.json | Camera scan runtime result |
camscan.json | Scan camera IP address and login account configuration |
camtags.json | Camera usage tags configuration |
Properties
The collection {CommandId} has the following properties:
Command ID | Type | Read/Write | HTTP Method |
advinfocache.json | JSON | R | GET |
camscan.json | JSON | R/W | GET/PUT |
camtags.json | JSON | R/W | GET/PUT |
Limitation
For the rules in camscan.json, the ip range rules cannot overlap.
Except that the system has just started, the system will only perform camera scan operations when the content of the camscan.json file is changed or the timestamp is updated.
The value of camtags.json members cannot contain double quote characters, even if they are escaped with a backslash.
Each camtages.json object consists of a camera serial number and a 255-length tag string name/value pair.
Example
Get the current camera scan result:
curl http://127.0.0.1:50011/advinfocache.jsonn |
[{"SerialNumber":"000017509314","IPAddress":"172.22.24.96","Snapshot":"http://172.22.24.96:85/images/snapshot.jpg","Tags":"nickname:onvif1,location:room1"},{"SerialNumber":"0002D18921E9","IPAddress":"172.22.24.85","Snapshot":"http://172.22.24.85:80/cgi-bin/viewer/video.jpg?channel=0\u0026streamid=0","Tags":"nickname:onvif3,location:room3"},{"SerialNumber":"000017658940","IPAddress":"172.22.24.76","Snapshot":"http://172.22.24.76:85/images/snapshot.jpg","Tags":"nickname:onvif2,location:room2"},{"SerialNumber":"0002D18921ED","IPAddress":"172.22.24.101","Snapshot":"http://172.22.24.101:80/cgi-bin/viewer/video.jpg?channel=0\u0026streamid=0","Tags":"nickname:onvif?,location:room!"}] |
Set the camera scan rules:
curl -H 'Content-Type: application/json' -X PUT -d '[{"ipRange":"172.22.24.85","username":"root","password":"trek-676"},{"ipRange":"172.22.24.100-172.22.24.132","username":"root","password":"trek-676"},{"ipRange":"172.22.24.96","username":"admin","password":"admin"},{"ipRange":"172.22.24.72/29","username":"admin","password":"admin"}]' http://127.0.0.1:50011/camscan.json |
Set the camera tags data:
curl -H 'Content-Type: application/json' -X PUT -d '[{"sn":"000017509314","tags":"nickname:onvif1,location:room1"},{"sn":"000017658940","tags":"nickname:onvif2,location:room2"},{"sn":"0002D18921ED","tags":"nickname:onvif?,location:room!"},{"sn":"0002D18921E9","tags":"nickname:onvif3,location:room3"}]' http://127.0.0.1:50011/camtags.json |
Last updated