Lossless Zoom API
This API is based on the Device Configuration API framework. For guidance on how to use these APIs, please refer to Device Configuration APIs.
Overview
The lossless zoom API lets you find out how far you can zoom in with digital PTZ before the image quality drops. The API tells you when the camera reuses pixels from the source image (lossless zoom) and when it must create new pixels that wasn't in the source image (lossy zoom).
View areas with digital zoom
A view area is a cropped part of the source image. You can resize the view area to change its resolution. For example: You can set a view area with a resolution of 4096x1024 from a source image with a resolution of 10240x2560.
Lossless and lossy zoom
Zooming in on an image could fall within any of these three scenarios: downscaling, no scaling, or upscaling.
-
Downscaling: The output resolution is lower than the view area resolution. The image is scaled down which usually gives good image quality. But it can introduce aliasing effects. This is lossless zoom. As you zoom in further, lossless zoom stays effective until the output resolution becomes the same as the view area resolution which then leads to the no scaling scenario.
-
No scaling: The output resolution is the same as the view area resolution. The image quality is the same as the output. This is lossless zoom sweet spot. Any further zooming in from this point will lead to an upscaling scenario and is therefore lossy.
-
Upscaling: The output resolution is higher than the view area resolution. Additional pixels are created and therefore the image quality is reduced. This is lossy zoom.
Examples
| Source resolution | View area resolution | Output resolution | Downscaling factor | Available lossless zoom |
|---|---|---|---|---|
| 10240x2560 | 10240x2560 | 8192x2048 | 1.25 | Up to 1.25x |
| 10240x2560 | 10240x2560 | 2048x512 | 5 | Up to 5x |
| 10240x2560 | 4096x1024 | 2048x512 | 2 | Up to 2x |
| 10240x2560 | 4096x1024 | 4096x1024 | 1 | None. At the sweet spot |
-
The source resolution is 10240x2560. You select a view area with a resolution of 10240x2560 and request an output resolution of 8192x2048. The camera downscales the image by a factor of 1.25. You can zoom in by a factor of 1.25 before you reach the sweet spot.
-
The source resolution is 10240x2560. You select a view area with a resolution of 10240x2560 and request an output resolution of 2048x512. The camera downscales the image by a factor of 5. You can zoom in by a factor of 5 before you reach the sweet spot.
-
The source resolution is 10240x2560. You select a view area with a resolution of 4096x1024 and request an output resolution of 2048x512. The camera downscales the image by a factor of 2. You can zoom in by a factor of 2 before you reach the sweet spot.
-
The source resolution is 10240x2560. You select a view area with a resolution of 4096x1024 and request an output resolution of 4096x1024. The view area resolution matches the output resolution, so you're already at the sweet spot.
Authentication
For detailed information on how to authenticate requests to this API, please refer to Authentication.
Use cases
Get current lossless zoom information
Request lossless zoom information for all streams on all channels
JSON request:
- curl
- HTTP
curl --request GET \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1
GET /config/rest/lossless-zoom/v1 HTTP/1.1
HOST: my-device
Content-Type: application/json
JSON response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": {
"channels": [
{
"channelId": "0",
"dptzEnabled": false,
"overlayInfo": {
"displayDuration": 0,
"enabled": false
},
"streams": []
},
{
"channelId": "1",
"dptzEnabled": false,
"overlayInfo": {
"displayDuration": 5,
"enabled": true
},
"streams": [
{
"streamId": "31",
"streamInfo": {
"height": 2560,
"maxDigitalZoomMag": 20.0,
"maxLosslessZoom": 1,
"maxLosslessZoomMag": 1.0,
"width": 5120
}
}
]
},
{
"channelId": "2",
"dptzEnabled": false,
"overlayInfo": {
"displayDuration": 0,
"enabled": true
},
"streams": [
{
"streamId": "32",
"streamInfo": {
"height": 2560,
"maxDigitalZoomMag": 20.0,
"maxLosslessZoom": 1,
"maxLosslessZoomMag": 1.0,
"width": 5120
}
}
]
},
{
"channelId": "3",
"dptzEnabled": true,
"overlayInfo": {
"displayDuration": 0,
"enabled": false
},
"streams": [
{
"streamId": "40",
"streamInfo": {
"height": 512,
"maxDigitalZoomMag": 4.0,
"maxLosslessZoom": 8420,
"maxLosslessZoomMag": 5.0,
"width": 2048
}
},
{
"streamId": "39",
"streamInfo": {
"height": 1280,
"maxDigitalZoomMag": 10.0,
"maxLosslessZoom": 5263,
"maxLosslessZoomMag": 2.0,
"width": 2560
}
}
]
},
{
"channelId": "4",
"dptzEnabled": false,
"overlayInfo": {
"displayDuration": 0,
"enabled": false
},
"streams": []
},
{
"channelId": "5",
"dptzEnabled": false,
"overlayInfo": {
"displayDuration": 0,
"enabled": false
},
"streams": []
},
{
"channelId": "6",
"dptzEnabled": false,
"overlayInfo": {
"displayDuration": 0,
"enabled": false
},
"streams": []
},
{
"channelId": "7",
"dptzEnabled": false,
"overlayInfo": {
"displayDuration": 0,
"enabled": false
},
"streams": []
}
]
}
}
Request lossless zoom information for all streams on channel 3
JSON request:
- curl
- HTTP
curl --request GET \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1/channels/3
GET /config/rest/lossless-zoom/v1/channels/3 HTTP/1.1
HOST: my-device
Content-Type: application/json
JSON response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": {
"channelId": "3",
"dptzEnabled": true,
"streams": [
{
"streamId": "40",
"streamInfo": {
"height": 512,
"maxDigitalZoomMag": 4.0,
"maxLosslessZoom": 8420,
"maxLosslessZoomMag": 5.0,
"width": 2048
}
},
{
"streamId": "39",
"streamInfo": {
"height": 1280,
"maxDigitalZoomMag": 10.0,
"maxLosslessZoom": 5263,
"maxLosslessZoomMag": 2.0,
"width": 2560
}
}
]
}
}
Request lossless zoom information on stream 40 on channel 3
JSON request:
- curl
- HTTP
curl --request GET \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1/channels/3/streams/40
GET /config/rest/lossless-zoom/v1/channels/3/streams/40 HTTP/1.1
HOST: my-device
Content-Type: application/json
JSON response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": {
"streamId": "40",
"streamInfo": {
"height": 512,
"maxDigitalZoomMag": 4.0,
"maxLosslessZoom": 8420,
"maxLosslessZoomMag": 5.0,
"width": 2048
}
}
}
Parse the response
-maxLosslessZoomMag: The factor you can zoom in with lossless zoom. For example, a value of 2 means you can zoom in by a factor of 2 before you reach the sweet spot.
-maxDigitalZoomMag: The factor you can zoom in with digital zoom after lossless zoom ends.
-maxLosslessZoom: The zoom position where lossless zoom ends. Use this value to add a divider to the zoom bar.
Enable overlay on channel 3
Get current values of overlayInfo
JSON request:
- curl
- HTTP
curl --request GET \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1/channels/3/overlayInfo
GET /config/rest/lossless-zoom/v1/channels/3/overlayInfo HTTP/1.1
HOST: my-device
Content-Type: application/json
JSON response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": {
"displayDuration": 0,
"enabled": false
}
}
Enable overlay on channel 3 that is always shown
JSON request:
- curl
- HTTP
curl --request PATCH \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1/channels/3/overlayInfo \
--data '{
"data": {
"displayDuration": 0,
"enabled": true
}
}'
PATCH /config/rest/lossless-zoom/v1/channels/3/overlayInfo HTTP/1.1
HOST: my-device
Content-Type: application/json
{
"data": {
"displayDuration": 0,
"enabled": true
}
}
JSON response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success"
}
Enable overlay on channel 3 that is only shown 5s after zoom changes
JSON request:
- curl
- HTTP
curl --request PATCH \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1/channels/3/overlayInfo \
--data '{
"data": {
"displayDuration": 5
}
}'
PATCH /config/rest/lossless-zoom/v1/channels/3/overlayInfo HTTP/1.1
HOST: my-device
Content-Type: application/json
{
"data": {
"displayDuration": 5
}
}
JSON response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success"
}
API definition
Structure
lossless-zoom.v1 (Root Entity)
├── channels (Entity Collection)
├── channelId (Property)
├── dptzEnabled (Property)
├── overlayInfo (Property)
├── streams (Entity Collection)
├── streamId (Property)
├── streamInfo (Property)
Entities
lossless-zoom.v1
- Description: The Lossless Zoom root entity.
- Type: Singleton
- Operations
- Get
- Attributes
- Dynamic Support: No
Properties
This entity has no properties.
Actions
This entity has no actions.
lossless-zoom.v1.channels
- Description: Entity with lossless information for all channels.
- Type: Collection (Key Property: channelId)
- Operations
- Get
- Attributes
- Dynamic Support: No
Properties
channelId
- Description: The channel ID.
- Datatype: string
- Operations
- Get (Permissions: admin, operator, viewer)
- Attributes
- Nullable: No
- Dynamic Support: No / Dynamic Enum: No / Dynamic Range: No
dptzEnabled
- Description: The DPTZ Enabled status.
- Datatype: boolean
- Operations
- Get (Permissions: admin, operator, viewer)
- Attributes
- Nullable: No
- Dynamic Support: No / Dynamic Enum: No / Dynamic Range: No
overlayInfo
- Description: The overlay status.
- Datatype: OverlayInfoDataType
- Operations
- Get (Permissions: admin, operator, viewer)
- Set (Permissions: admin)
- Attributes
- Nullable: No
- Dynamic Support: No / Dynamic Enum: No / Dynamic Range: No
Actions
This entity has no actions.
lossless-zoom.v1.channels.streams
- Description: Entity with lossless information for all streams.
- Type: Collection (Key Property: streamId)
- Operations
- Get
- Attributes
- Dynamic Support: No
Properties
streamId
- Description: The stream ID.
- Datatype: string
- Operations
- Get (Permissions: admin, operator, viewer)
- Attributes
- Nullable: No
- Dynamic Support: No / Dynamic Enum: No / Dynamic Range: No
streamInfo
- Description: All information about one stream.
- Datatype: StreamInfoDataType
- Operations
- Get (Permissions: admin, operator, viewer)
- Attributes
- Nullable: No
- Dynamic Support: No / Dynamic Enum: No / Dynamic Range: No
Actions
This entity has no actions.
Data Types
DisplayDuration
- Description: The duration, in seconds, the overlay is displayed.
- Type: integer
- Minimum Value: 0
- Maximum Value: 60
OverlayInfoDataType
- Description: The overlay information object.
- Type: complex
- Fields
- displayDuration
- Description: The duration, in seconds, the overlay is displayed.
- Type: DisplayDuration
- Nullable: No / Gettable: Yes
- enabled
- Description: If the overlay is enabled or not.
- Type: boolean
- Nullable: No / Gettable: Yes
- displayDuration
StreamInfoDataType
- Description: The stream information object.
- Type: complex
- Fields
- height
- Description: The height of the stream, in pixels.
- Type: integer
- Nullable: No / Gettable: Yes
- maxDigitalZoomMag
- Description: The maximum zoom factor beyond the lossless zoom sweet spot.
- Type: number
- Nullable: No / Gettable: Yes
- maxLosslessZoom
- Description: The zoom position of the lossless zoom sweet spot. If you zoom in beyond this position, the zoom becomes lossy.
- Type: integer
- Nullable: No / Gettable: Yes
- maxLosslessZoomMag
- Description: The maximum zoom factor in lossless zoom. For example, a value of 5.0 means you can zoom in by a factor of 5 before you reach the sweet spot.
- Type: number
- Nullable: No / Gettable: Yes
- width
- Description: The width of the stream, in pixels.
- Type: integer
- Nullable: No / Gettable: Yes
- height