@edgeros/jsre-camera-src

1.0.4 • Public • Published

Overview

CameraSource module is a media source of WebMedia framewrok. It has the following characteristics:

  • Connect rtsp audio and video stream, output flv live stream;
  • Integrated facenn module, which can recognize face information;
  • Built-in face-following algorithm to generate face-following coordinates (in accordance with the onvif protocol);
  • Face recognition and face follow functions can be controlled separately;
  • AI runs in a separate thread and does not block the main framework of WebMedia.

User can use the following code to import the CameraSource module .

var source = require('@edgeros/jsre-camera-src');

Support

The following shows CameraSource module APIs avaliable for each permissions.

  User Mode Privilege Mode
source.autoMove
source.openAI

CameraSource Object

source.autoMove

  • {Boolean} true - start face-following, the source control camera movement by emit camStop and camMove event. Otherwise set autoMove to false. default: false.

source.openAI([enable])

  • enable {Boolean} Open AI or not. default: false.

When AI is opened, source broadcasts the recognized face information to each client. face information to see Media Data.

FaceFlvSource Events

camStop

Stop move. Stop camera to see onvif camera.stop().

When source.autoMove is set, source will continuously generate camMove and camStop events until the recognized face is in the middle of the screen.

camMove

  • rx {Number} Move distance x.
  • ry {Number} Move distance y.

Move camera to see onvif camera.continuousMove().

Use CameraSource

To use CameraSource, you first need to register the media source on the WebMedia framework, em:

var WebMedia = require('webmedia');
var CameraSource = require('@edgeros/jsre-camera-src');

const sourceName = 'camera-flv';
WebMedia.registerSource(sourceName, CameraSource);

CameraSource object create by WebMedia framework, em:

var opts = {
	mode: 2,
	mediaSource: {
		source: 'camera-flv',
		inOpts: inOpts, // source input options
		outOpts: outOpts // source output options
	},
	streamChannel: {
		protocol: 'ws',
	},
	dataChannel: {
		protocol: 'ws',
	}
}
var ser = WebMedia.createServer(opts, app);

ser.on('open', (ser, media) => {
	// access source by media.source
}

You need to provide the CameraSource options when creating the WebMedia server. The CameraSource options are as follows:

  • inOpts {Ojbect}
    • host {String} Media source hostname.
    • port {Integer} Media source port. default: 10000.
    • path {String} Media source path. default: '/'.
    • user {String} default: 'admin'
    • pass {String} default: 'admin'
  • outOpts {Object}
    • faceDetecOpts {Object}
      • enable {Boolean} default: true.
      • faceLibs {Array} {id, keys} Face information retrieval db.
      • threshold {Number} threshold value of similarity, default: 0.6.
      • format {Object} Identify information output options, default: {male=false, age=false, emotion=false, area=true}.
      • fps {Integer} Detection frequency, default: 1.

Media Data

Media data is sent to the client by client.send(opts, data[, cb]) of MediaClient. For details, please refer to the WebMedia module.

CameraSource outputs two kinds of media data:

media

  • opts {Object} Must be: {type: 'media'}
  • data {Object}
    • width {Integer} Video width.
    • height {Integer} Video height.
    • fps {Integer} Video fps.

push media info data first.

face

  • opts {Object} Must be: {type: 'face'}
  • data {Array} Object array, options:
    • id {Integer} Detected face id.
    • male {Integer} Detected male.
    • age {Integer} Detected age.
    • emotion {Integer} Detected emotion.
    • x0 {Integer} Begin position x of face.
    • y0 {Integer} Begin position y of face.
    • x1 {Integer} End positon x of face.
    • y1 {Integer} End position y of face.

face detected output info. Data setting base outOpts.faceDetecOpts.format option.

NOTICE: id(0) meen detected face not match any one in libs.


Package Sidebar

Install

npm i @edgeros/jsre-camera-src

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

25.7 kB

Total Files

6

Last publish

Collaborators

  • clarkttfu
  • fu-starslights
  • epmbot
  • xieyuanbin
  • chengyonbin