All pages
Powered by GitBook
1 of 4

Loading...

Loading...

Loading...

Loading...

Create your own visualization

Sample Code - Vanilla Dashboard

Source code of Vanilla Dashboard to help you understand how Vanilla works. You can also customize it.

Get Restream Visualization

1. Exclude Crowd Estimation

Import visualstreamer.js, then apply nodeflux-streamer class on <div> component. This <div> component must have fixed width and height. Add stream URL to data-url attributes. Component example:

2. For Crowd Estimation

Import , then put with visualstreamer.js in the same folder.

How to Get Event Stream

  • Connect with WebSocket server that gets from API WebSocket

  • Response event websocket

Migration from Old Streamer to New Streamer

Library content :

How yo use new visual streamer :

  1. Get the new library from this link : https://github.com/nodefluxio/docker-stream-quickstart/tree/main/client/public/library/jsmpeg

  2. Copy the library to your public folder so the path will be ( public/library/jsmpeg )

  3. Open index.html on your public folder

  4. Import file jsmpeg.min.js inside head tag

  1. And then import file jsmegVisualStreamer.js after body tag

  1. After that you can use the component, component example :

Notes :

  • Class nodeflux-stremer is required

  • For MPEG1 we are using websocket protocol instead http protocol

  1. And then for starting visualisation you can use this command :

Library API :

Additional Visualization Query

Change resolution in dashboard

Separate visualization from multiple logics

Combine resolution and separation logics URL
ws://{ip}:{host}/mp1streamer/:node_num/:stream_id/:analytic_id

param: 
 - node_num = node number
 - stream_id = stream id 
 - analytic_id = analytic id
query:
- preset: only choose 1 preset
    - 240p
    - 360p
    - 480p
    - 720p
    - 1080p
ws://{ip}:{host}/mp1streamer/:node_num/:stream_id/:analytic_id

param: 
 - node_num = node number
 - stream_id = stream id 
 - analytic_id = analytic id
query: 
 - logic = can only choose 1 logic when showing the stream
  - counting
  - dweling
  - density
ws://{ip}:{host}/mp1streamer/:node_num/:stream_id/:analytic_id?preset=320p&logic=counting
heatmap.min.js
<script src="/library/jsmpeg/jsmpeg.min.js"></script>

showVisualisation

This function will be use for starting visualisation component

stopVisualisation

This function will be use for stop all visualisation component

Drawing Region of Interest

This page explains how to draw Region of Interest (ROI) for analytic Vehicle Counting, People Counting, License Plate Recognition, and Crowd Estimation.

How to Use ROI Lib

  1. Clone this library.

2. To be able to draw inside the canvas, make sure to copy the give canvas

<div 
    class="nodeflux-streamer" 
    data-url="http://127.0.0.1:4004/mjpeg/0/de2ea3d628ca1034/NFV4-FR" 
    style=" 
    width: 569px; 
    height: 320px">
</div>
{
  "analytic_id":"NFV4-FR",
}
<script src="/library/jsmpeg/jsmpegVisualStreamer.js"></script>
<div
   class="nodeflux-streamer"
   data-url="ws://127.0.0.1:4004/mpeg1/0/de2ea3d628ca1034/NFV4-FR?preset=720p"
   style="width: 569px; height: 320px">
</div>
 showVisualisation();
as an id to the component.

3. Make sure to copy all the #canvas styling, image for preview can be but inside of the canvas element as children component. for example:

4. Call initialCanvas function on windows onload, or when there are any ROI Type change

Function Explanation

initialCanvas ( callback, roi_type )

initialCanvas needs two parameters, namely for callback and roi_type respectively. callback will be called after region or line created, returning object with values:

onResetROI ( callback )

this function will remove all the lines. accepting callback params for user to be able to call their own function when resetting all lines and region

onDeleteLine ( id ), onDeleteRegion (id)

receive id as params. this id can be filled with lineNumber from the initialCanvas callback. onDeleteLine will be used to delete lines, while onDeleteRegion will be used to delete area/region.

onReverseLine ( id )

receive id as params. this id can be filled with lineNumber from the initialCanvas callback. only applicable to roi_type line. will reverse the line direction

Result

<div id="canvas">
	<img src={source} />
</div>
{
	points:  array_of_coordinates,
	area:  name_of_area,
	color:  color_of_lines,
	lineNumber: index_of_roi (starts from 1)
}
GitHub - nodefluxio/docker-stream-quickstart: Built-in dashboard for Visionaire Docker StreamGitHub
Logo
docker-stream-quickstart/client/public/roilib at main · nodefluxio/docker-stream-quickstartGitHub
Library to draw ROI
docker-stream-quickstart/heatmap.min.js at main · nodefluxio/docker-stream-quickstartGitHub
Logo
https://www.youtube.com/watch?v=YGeHompoNFYwww.youtube.com
Library ROI Demo Usage
Logo
docker-stream-quickstart/visualstreamer.js at main · nodefluxio/docker-stream-quickstartGitHub
Logo