Skip to content

Classic API: Camera

Hayun Lee edited this page Dec 21, 2020 · 3 revisions

Parent Document: ANT APIs

Camera API is the set of APIs for using and managing the camera on the device.

You need to load camera API module before you use its API as following.

var cameraApi = require(process.env.ANT_BIN_DIR + '/api/camera-api');
var camObj = new cameraApi.ANTRecording();

recordingStart()

void recordingStart(Integer camera_id, String file_path, Integer seconds, Function callback);

recordingStart() starts recording of the camera specified by camera_id.

It records for the seconds and stores recorded data in the file_path.

After the recording is finished, the callback function is called.

Example

var cameraApi = require(process.env.ANT_BIN_DIR + '/api/camera-api');
var camObj = new cameraApi.ANTRecording();
camObj.recordingStart(0, process.env.ANT_DATA_DIR + "test.mp4”, 10, function() {
  console.log(“Recording is finished”);
});

recordingStop()

void recordingStop(Integer camera_id);

recordingStop() stops all recording of the camera specified by camera_id.

snapshot()

void snapshot(Integer camera_id, String file_path);

snapshot() takes a snapshot of the current camera view specified by camera_id.

It stores this snapshot in the file_path.

streamingStart()

void streamingStart(Integer camera_id, String ip_addr, Integer port);

streamingStart() starts streaming of the camera specified by camera_id.

It creates a tcp server with the ip_addr and port passed as parameters.

Example

var cameraApi = require(process.env.ANT_BIN_DIR + '/api/camera-api');
var camObj = new cameraApi.ANTRecording();
camObj.streamingStart(0, “192.168.49.1, 5000);

streamingStop()

void streamingStop(Integer camera_id);

streamingStop() stops streaming of the camera specified by camera_id.

sensorOverlayStart()

void sensorOverlayStart(Integer camera_id, String sensor_name);

sensorOverlayStart() starts the sensor(sensor_name) overlay on the camera video specified by camera_id.

Example

var cameraApi = require(process.env.ANT_BIN_DIR + '/api/camera-api');
var camObj = new cameraApi.ANTRecording();
camObj.sensorOverlayStart(0, “BUTTON”);

sensorOverlayStop()

void sensorOverlayStop(Integer camera_id, String sensor_name);

sensorOverlayStop() stops the sensor(sensor_name) overlay on the camera video specified by camera_id.

delayStreamingStart()

void delayStreamingStart(Integer camera_id, Integer delay_seconds);

delayStreamingStart() starts delayed streaming of the camera specified by camera_id for event recording.

It is similar to streamingStart(), but does not require ip_addr and port.

Because it is set automatically by the camera manager.

Instead, you should set the delay_seconds to how long the video will be delayed.

If delay is 0, eventRecStart() performs the same operation as recordingStart().

It must be called before using eventRecStart().

delayStreamingStop()

void delayStreamingStop(Integer camera_id);

delayStreamingStop() stops delayed streaming of the camera specified by camera_id.

It is similar to streamingStop().

eventRecStart()

void eventRecStart(Integer camera_id, String file_path, Integer seconds);

eventRecStart() starts event recording of the camera specified by camera_id.

To use it, delayStreamingStart() must be called first.

Unlike recordingStart(), it records from - delay_seconds to seconds - delay_seconds based on the current time.

It stores recorded data in file_path.

Example

var cameraApi = require(process.env.ANT_BIN_DIR + '/api/camera-api');
var camObj = new cameraApi.ANTRecording();
camObj.delayStreamingStart(0, 10);
setTimeout(function() {
  console.log(“Event generation (after 15 seconds));
  camObj.eventRecStart(0, process.env.ANT_DATA_DIR + "event_test.mp4”, 20);
  console.log(“Stores recorded video from -10sec to 10sec”);
}, 15000);

eventRecStop()

void eventRecStop(Integer camera_id);

eventRecStop() stops event recording of the camera specified by camera_id.