VideoOverlay : Video overlay
The videooverlay
module provides video overlay function.
videooverlay
is a sub object of MediaDecoder
.
Support
The following shows videooverlay
module APIs available for each permissions.
User Mode | Privilege Mode | |
---|---|---|
videooverlay.clear | ● | ● |
videooverlay.text | ● | ● |
videooverlay.point | ● | ● |
videooverlay.line | ● | ● |
videooverlay.rect | ● | ● |
videooverlay.circle | ● | ● |
videooverlay.draw | ● | ● |
videooverlay.font | ● | ● |
VideoOverlay Object
videooverlay.clear()
- Returns: {Boolean} Return true if success, otherwise false.
Clear all overlays.
videooverlay.text(x, y, text, color[, bcolor])
x
{Integer} x position.y
{Integer} y position.text
{String} Text which need draw.color
{Integer} Text color.bcolor
{Integer} Background color.- Returns: {Boolean} Return true if success, otherwise false.
Draw a text on overlay.
videooverlay.point(x, y, color)
x
{Integer} x position.y
{Integer} y position.color
{Integer} Point color.- Returns: {Boolean} Return true if success, otherwise false.
Draw a point on overlay.
videooverlay.line(x0, y0, x1, y1, color[, width])
x0
{Integer} x0 position.y0
{Integer} y0 position.x1
{Integer} x1 position.y1
{Integer} y1 position.color
{Integer} Line color.width
{Integer} Line width.- Returns: {Boolean} Return true if success, otherwise false.
Draw a line on overlay.
videooverlay.rect(x0, y0, x1, y1, color[, width[, r[, fill]]])
x0
{Integer} x position of upper left corner.y0
{Integer} y position of upper left corner.x1
{Integer} x position of lower right corner.y1
{Integer} y position of lower right corner.color
{Integer} Line color.width
{Integer} Line width.r
{Integer} The radius of fillet.fill
{Boolean} Does fill rectangle?- Returns: {Boolean} Return true if success, otherwise false.
Draw a rectangle on overlay.
videooverlay.circle(x, y, r, color[, width[, fill]])
x
{Integer} x position of center.y
{Integer} y position of center.r
Integer Line color.color
{Integer} Line color.width
{Integer} Line width.fill
{Boolean} Does fill circle?- Returns: {Boolean} Return true if success, otherwise false.
Draw a circle on overlay.
videooverlay.font(font)
font
{Integer} Font size.- Returns: {Boolean} Return true if success, otherwise false.
font
is a integer, can be:
Value | Description |
---|---|
F4X6 | 4X6 font. |
F5X8 | 5X8 font. |
F5X12 | 5X12 font. |
F6X8 | 6X8 font. |
F6X10 | 6X10 font. |
F7X12 | 7X12 font. |
F8X8 | 8X8 font. |
F8X12 | 8X12 font. |
F8X14 | 8X14 font. |
F10X16 | 10X16 font. |
F12X16 | 12X16 font. |
F12X20 | 12X20 font. |
F16X26 | 16X26 font. |
F22X36 | 22X36 font. |
F24X40 | 24X40 font. |
F32X53 | 32X53 font. |
videooverlay.draw(buf)
buf
{Buffer} Buffer which need to be draw.- Returns: {Boolean} Return true if success, otherwise false.
Draw all overlays to specified buffer.
Example
This example show how to draw something on the video overlay.
#!/bin/javascript
var MediaDecoder = require('mediadecoder');
var iosched = require('iosched');
var netcam = new MediaDecoder().open('rtsp://admin:admin@10.4.0.12');
netcam.destVideoFormat({width: 640, height: 360, fps: 1, pixelFormat: MediaDecoder.PIX_FMT_RGB24, disable: false});
netcam.destAudioFormat({disable: true});
netcam.previewFormat({enable: true, fb: 0, fps: 25});
var quited = false;
var ol = netcam.overlay();
ol.font(ol.F8X12);
ol.text(40, 20, 'EdgerOS', MediaDecoder.C_WHITE);
ol.point(40, 40, MediaDecoder.C_RED);
ol.line(40, 50, 80, 50, MediaDecoder.C_RED, 4);
ol.rect(40, 60, 80, 100, MediaDecoder.C_RED, 8, 2, true);
ol.circle(70, 140, 30, MediaDecoder.C_RED, 2);
netcam.on('video', (video) => {
});
netcam.on('eof', () => {
quited = true;
});
netcam.start();
while (!quited) {
iosched.poll(); // Event poll.
}
netcam.close();