Skip to main content

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 resolutionView area resolutionOutput resolutionDownscaling factorAvailable lossless zoom
10240x256010240x25608192x20481.25Up to 1.25x
10240x256010240x25602048x5125Up to 5x
10240x25604096x10242048x5122Up to 2x
10240x25604096x10244096x10241None. 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 --request GET \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1

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 --request GET \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1/channels/3

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 --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

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 --request GET \
--anyauth \
--user "<username>:<password>" \
--http1.1 \
--header "Content-Type: application/json" \
http://my-device/config/rest/lossless-zoom/v1/channels/3/overlayInfo

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 --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
}
}'

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 --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
}
}'

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

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