Skip to main content

M12 Lens Selection API

The VAPIX® M12 Lens Selection API provides the ability to select M12 lenses with different field of views and distortions for individual camera sensors.

  • The API will extract information from a file with both lens data and lens distortion data, and update the field of view data to correspond to the selected lens.
  • This API is required in products that controls a remote PTZ camera and have exchangeable lenses.
warning

This API was deprecated prior to release and will not receive any updates.

Overview

The API uses m12-lensselection.cgi as its communication interface and supports the following methods:

MethodDescription
getSupportedLensesReturn a list of supported lenses.
setCurrentLensSet the current lens for one of the sensors.
getCurrentLensesReturn the current lenses used by the camera sensors.
getSupportedVersionsReturn a list of supported API versions.

Identification

  • Property: Properties.API.HTTP.Version=3
  • Property: Properties.M12LensSelection.M12LensSelection=yes
  • Property: Properties.M12LensSelection.Version=1.00
  • Firmware: 6.50

Use Cases

Get supported versions

This example will show you how to create a list of all API versions currently supported by your device.

  1. Retrieve a list of supported API versions.

http://<servername>/axis-cgi/m12-lensselection.cgi

JSON input parameters

{
"context": "abc",
"method": "getSupportedVersions"
}
  1. Parse the JSON response.

Successful response example

{
"apiVersion": "2.1",
"context": "abc",
"method": "getSupportedVersions",
"data": {
"apiVersions": ["1.3","2.1"]
}
}

Error response example

{
"apiVersion": "2.1",
"context": "abc",
"method": "getSupportedVersions",
"error": {
"code": 8000,
"message": "Internal error"
}
}

See getSupportedVersions for further details.

Get supported lenses

This example will show you how to check what lenses to use for a camera sensor that will maintain full PTZ functionality.

  1. Retrieve a list of supported lenses.

http://<servername>/axis-cgi/m12-lensselection.cgi

JSON input parameters

{
"apiVersion": "2.1",
"context": "abc",
"method": "getSupportedLenses",
"params": {
"listSensorIds": true
}
}
  1. Parse the JSON response.

Successful response example

{
"apiVersion": "2.1",
"context": "abc",
"method": "getSupportedLenses",
"data": [
{
"lensId": 1,
"lensName": "M12 6 mm",
"sensorIds": [1, 3]
},
{
"lensId": 2,
"lensName": "M12 1.37 mm",
"sensorIds": [2, 4]
},
{
"lensId": 3,
"lensName": "M12 16 mm",
"sensorIds": []
}
]
}

Error response example

{
"apiVersion": "2.1",
"context": "abc",
"method": "getSupportedLenses",
"error": {
"code": 8000,
"message": "Internal error"
}
}

See getSupportedLenses for further details.

Set current lens

This example will show you how to exchange lenses on a camera sensor while maintaining full PTZ functionality.

  1. Set the current lens.

http://<servername>/axis-cgi/m12-lensselection.cgi

JSON input parameters

{
"apiVersion": "2.1",
"context": "abc",
"method": "setCurrentLens",
"params": {
"sensorId": 1,
"lensId": 2
}
}

  1. Parse the JSON response.

Successful response example

{
"apiVersion": "2.1",
"context": "abc",
"method": "setCurrentLens",
"data": {
}
}

Error response example

{
"apiVersion": "2.1",
"context": "abc",
"method": "setCurrentLens",
"error": {
"code": 1002,
"message": "Unsupported lens"
}
}

See setCurrentLens for further details.

Get current lens

This example will show you how to check which lens that is currently used by the camera sensor.

  1. Get the current lens information.

http://<servername>/axis-cgi/m12-lensselection.cgi

JSON input parameters

{
"apiVersion": "2.1",
"context": "abc",
"method": "getCurrentLenses",
"params": {
"sensorId": 3
}
}
  1. Parse the JSON response.

Successful response example

This response example returns the lens ID and name for the specified sensor ID.

{
"apiVersion": "2.1",
"context": "abc",
"method": "getCurrentLenses",
"data": [
{
"sensorId": 3,
"lensId": 2,
"lensName": "M12 1.37 mm"
}
]
}

This response example returns the lens ID and name of the current lens for all camera sensors.

{
"apiVersion": "2.1",
"context": "abc",
"method": "getCurrentLenses",
"data":[
{
"sensorId": 1,
"lensId": 2,
"lensName": "M12 1.37 mm"
},
{
"sensorId": 2,
"lensId": 1,
"lensName": "M12 6 mm"
},
{
"sensorId": 3,
"lensId": 2,
"lensName": "M12 1.37 mm"
},
{
"sensorId": 4,
"lensId": 1,
"lensName": "M12 6 mm"
}
]
}

Error response example

{
"apiVersion": "2.1",
"context": "abc",
"method": "getCurrentLenses",
"error": {
"code": 1001,
"message": "Invalid sensor"
}
}

See getCurrentLenses for further details.

API Specifications

getSupportedVersions

Retrieve a list of supported API versions.

Request

  • Security level: Operator
  • Method: POST

http://<servername>/axis-cgi/m12-lensselection.cgi

{
"context": <string>,
"method": "getSupportedVersions"
}
ParameterDescription
context=<string>
Optional
The user sets this value in the request and the application will echo it back in the response.
method="getSupportedVersions"The API method called in the request.

Responses

Successful response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"context": <string>,
"method": "getSupportedVersions",
"data": {
"apiVersions": [ "<Major1>.<Minor1>", "<Major2>.<Minor2>" ]
}
}
ParameterDescription
context=<string>
Optional
The context set by the user in the request.
method="getSupportedVersions"The requested API method.
data.apiVersions[]=<list of versions>List of supported versions. Includes all major versions along with their highest minor version.
<list of versions>List of “<Major>.<Minor>" versions, for example ["1.4", "2.5"].

Error response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "getSupportedVersions",
"error": {
"code": <integer error code>,
"message": <string>
}
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version used in the request.
context=<string>
Optional
The context set by the user in the request.
method="getSupportedVersions"The requested API method.
error.code=<integer error code>The error code.
error.message=<string>The error message for the corresponding error code.

Error codes

See General error codes for a complete list of potential errors.

getSupportedLenses

Retrieve a list of supported lenses.

Request

  • Security level: Operator
  • Method: POST

http://<servername>/axis-cgi/m12-lensselection.cgi

{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "getSupportedLenses",
"params": {
"listSensorIds": <boolean>
}
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version that should be used.
context=<string>
Optional
The user sets this value in the request and the application will echo it back in the response.
method="getSupportedLenses"The API method called in the request.
params=<listSensorIds>
Optional
The user sets this value and the server will add an array of sensor IDs for the currently used lens.

Responses

Successful response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "getSupportedLenses",
"data": [
{
"lensId": <integer>,
"lensName": <string>,
"sensorIds": [<integer>, ...]
},
...
]
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version used in the request.
context=<string>
Optional
The context set by the user in the request.
method="getSupportedLenses"The requested API method.
data=<array>Container for response specific parameters listed below.
lensId=<integer>The lens ID.
lensName=<string>The lens name.
sensorIds=<array of integers>An array of sensor IDs where the lens is used.

Error response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "getSupportedLenses",
"error": {
"code": <integer error code>,
"message": <string>
}
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version used in the request.
context=<string>
Optional
The context set by the user in the request.
method="getSupportedLenses"The requested API method.
error.code=<integer error code>The error code.
error.message=<string>The error message for the corresponding error code.

Error codes

See General error codes for a complete list of potential errors.

getCurrentLenses

Retrieve the current lens for each camera sensor.

Request

  • Security level: Operator
  • Method: POST

http://<servername>/axis-cgi/m12-lensselection.cgi

{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "getCurrentLenses",
"params": {
"sensorId": <integer>
}
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version that should be used.
context=<string>
Optional
The user sets this value in the request and the application will echo it back in the response.
method="getCurrentLenses"The API method called in the request.
params=<sensorId>
Optional
The user sets this value and the server will get the current lens for the specified sensor ID.

Responses

Successful response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "getCurrentLenses",
"data": [
{
"sensorId": <integer>,
"lensId": <integer>,
"lensName": <string>

},
...
]
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version used in the request.
context=<string>
Optional
The context set by the user in the request.
method="getCurrentLenses"The requested API method.
data=<array>Container for response specific parameters listed below.
sensorId=<integer>The sensor ID.
lensId=<integer>The lens ID.
lensName=<string>The lens name.

Error response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "getCurrentLenses",
"error": {
"code": <integer error code>,
"message": <string>
}
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version used in the request.
context=<string>
Optional
The context set by the user in the request.
method="getCurrentLenses"The requested API method.
error.code=<integer error code>The error code.
error.message=<string>The error message for the corresponding error code.

Error codes

See General error codes for a complete list of potential errors.

setCurrentLens

Set the current lens for a sensor.

Request

  • Security level: Operator
  • Method: POST

http://<servername>/axis-cgi/m12-lensselection.cgi

{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "setCurrentLens",
"params": {
"sensorId": <integer>,
"lensId": <integer>
}
}

ParameterDescription
apiVersion=<Major>.<Minor>The API version that should be used.
context=<string>
Optional
The user sets this value in the request and the application will echo it back in the response.
method="setCurrentLens"The API method called in the request.
params=<sensorId>The sensor ID that should be set.
params=<lensId>The lens ID that should be set.

Responses

Successful response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "setCurrentLens",
"data": {
}
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version used in the request.
context=<string>
Optional
The context set by the user in the request.
method="setCurrentLens"The requested API method.

Error response

  • HTTP Code: 200 OK
  • Content-Type: application/json
{
"apiVersion": "<Major>.<Minor>",
"context": <string>,
"method": "setCurrentLens",
"error": {
"code": <integer error code>,
"message": <string>
}
}
ParameterDescription
apiVersion=<Major>.<Minor>The API version used in the request.
context=<string>
Optional
The context set by the user in the request.
method="setCurrentLens"The requested API method.
error.code=<integer error code>The error code.
error.message=<string>The error message for the corresponding error code.

Error codes

See General error codes for a complete list of potential errors.

General error codes

CodeDescription
1000Invalid parameter value.
1001Invalid sensor.
1002Unsupported lens.
2000Out of memory.
2001Access forbidden (similar to HTTP 403).
2002HTTP request type not supported. Only POST supported.
2003The requested API version is not supported.
2004Method not supported.
4000The provided JSON input was invalid.
4001A mandatory input parameter was not found in the input.
4002The type of a provided JSON parameter was incorrect.
8000Internal error, could not complete request.