Child pages
  • Examples of scripts in JScript language

Documentation for Intellect 4.9.8. Documentation for other versions of Intellect is available too.

Skip to end of metadata
Go to start of metadata
On the page:
 

To illustrate available fields of application of scripts in Jscript see the following examples which can be used to create additional functions in the system on the basis of the Script object.

Example 1. Visualisation of operating the Queue length detection in the Video Surveillance monitor

The Queue length detection object (is part of the Detector Pack package), Camera and Captioner objects (instead of N, M, L symbols set the corresponding numbers of the Queue length detection, Camera and Captioner objects) are to be created and configured for correct script working in the Intellect software.

//Event reading by the queue length
if (Event.SourceType == "OCCUPANCY_COUNTER" && Event.SourceId == "N" && Event.Action == "OCCUPANCY")  //N - Number of Queue length detection
{
  var n=Event.GetParam("occupancy");
//Displaying the queue number by the Captioner in the Monitor
  DoReactStr("CAM","M","CLEAR_SUBTITLES","title_id<L>"); //M - Number of Camera  L - Number of Captioner
  DoReactStr("CAM","M","ADD_SUBTITLES","command<Queue length: "+n+" person(s).\r>,page<BEGIN>,title_id<L>"); //M, L - the same
}

As a result the text message about the current queue length will be imposed on the video image while displaying the corresponding camera in the Video Surveillance monitor.

Settings of the font, color and position of text is configured on the settings panel of the Captioner object.

Example 2. Visualisation of operating the People Counter detection in the Video Surveillance monitor

The People Counter Detection object (is part of the Detector Pack package), Camera, Captioner and Macro objects (instead of N, M, L, P symbols set the corresponding numbers of the People counter detection, Camera, Captioner and Macro objects) are to be created and configured for correct script working in the Intellect software.

//Event reading and counting of entered people 
if (Event.SourceType == "PEOPLE_COUNTER" && Event.SourceId == "N" && Event.Action == "IN") //N - Number of People Counter detection  
  {
    i = Itv_var("counter_i");
    k = Itv_var("counter_k");  
    i++;  
    Itv_var("counter_i")=i;
//Displaying the number of people by Captioner in the Monitor
     
    DoReactStr("CAM","M","CLEAR_SUBTITLES","title_id<L>"); //M - Number of Camera  L - Number of Captioner
    DoReactStr("CAM","M","ADD_SUBTITLES","command<Number of people (entering/exiting): "+i+" / "+k+"\r>,page<BEGIN>,title_id<L>"); //M, L - the same
      
  }
//Event reading and counting of exitng people
if (Event.SourceType == "PEOPLE_COUNTER" && Event.SourceId == "N" && Event.Action == "OUT") //N - Number of People Counter detection
  {
    i = Itv_var("counter_i");
    k = Itv_var("counter_k"); 
    k++;  
    Itv_var("counter_k")=k;
//Displaying the number of people by Captioner in the Monitor  
   
   DoReactStr("CAM","M","CLEAR_SUBTITLES","title_id<L>"); //M - Number of Camera  L - Number of Captioner
   DoReactStr("CAM","M","ADD_SUBTITLES","command<Number of people (entering/exiting): "+i+" / "+k+"\r>,page<BEGIN>,title_id<L>"); //M, L - the same
  }
//Null the counter by Macro (previously the Macro is to be created in the Intellect)
if (Event.SourceType == "MACRO" && Event.SourceId == "P" && Event.Action == "RUN") //P - Number of Macro
  {
    Itv_var("counter_i")=0;
    Itv_var("counter_k")=0;
    i=0;
    k=0;
//Displaying number of people by Captioner in the Monitor
      
    DoReactStr("CAM","M","CLEAR_SUBTITLES","title_id<L>"); //M - Number of Camera  L - Number of Captioner
    DoReactStr("CAM","M","ADD_SUBTITLES","command<Number of people (entering/exiting): "+i+" / "+k+"\r>,page<BEGIN>,title_id<L>"); //M, L - the same
  }

As a result the text message about number of entering and exiting people will be imposed on the video image while displaying the corresponding camera in the Video Surveillance monitor.

Settings of the font, color and position of text is configured on the settings panel of the Captioner object (see the Configuring captions display on a video image section of the Administrator’s Guide document).

Previously create the Macro object on the Programming tab to null the counter of visitors. The name of the object can be changed to “Null of people counter” for ease of using.

Macro of setting to zero can be run manually by main menu of the Intellect software package or automatically in any specified time (use the Events table on the settings panel of the Macro object where the previously configured Time zone object is to be specified). Detailed information about using the Macro and Time zone objects is given in the Administrator's Guide document).

Example 3. Setting the text for displaying on the map

It is possible to select the type of Text displaying while attaching object to the map (see Administrator Guide, the Attaching objects to the layers of interactive map section). Also the script on the JScript language can be used for changing the displayed text.

Example. The Text type of display on the map is selected for the Camera 1. It's required to display value of the MyVar value read from the C:\test.ini file on the map and debug window while processing the Macro 1.

if(Event.SourceType == "MACRO" && Event.Action == "RUN") 
{ 
 var result = parseInt(ReadIni("MyVar","C:\\test.ini"));
 result += 2;
 NotifyEventStr("CAM","1","ANALOG_PARAMS","text<Variable value = \n" + result + ">, blink_state<1>");
 DebugLogString(result); 
}

Example 4. Displaying camera on the monitor by clicking the button on the remote control

The following example is valid only for cameras in configuration of which there is PTZ control panel. When configuring Video surveillance monitor select the Go to preset action with 1,2,3...,0 parameters for ten joystick buttons (see  Assigning commands to joystick buttons using the Monitor section of Installing and configuring security system components guide).

Example. When the button is clicked on the control panel, display corresponding camera in the active monitor. The script is to timer trigger with ID=1.  

Note.

The Timer object is to be created and configured beforehand and the current year is to be set. Information on how to configure the Timer object can be found in  Creating and configuring the Timer object section of  Administrator's Guide.

After each button click on the control panel wait for 2 seconds until clicking another button. If there is no button click, then the camera with dialed number is to be displayed.

if (Event.SourceType=="TIMER" && Event.SourceId=="1" && Event.Action=="TRIGGER")
{
  mon="1";
  DebugLogString("на монитор "+ Itv_var("cam"));
  DoReactStr("MONITOR",mon,"ACTIVATE_CAM","cam<"+Itv_var("cam")+">");
  Itv_var("cam")="";
}
 
if (Event.GetParam("source_type")=="TELEMETRY" && Event.GetParam("action")=="GO_PRESET")
{
  DoReactStr("TIMER","1","START","bound<2>");
  var key=Event.GetParam("param4_val");
  DebugLogString("Key:"+key);
  Itv_var("cam")=Itv_var("cam")+key;
  DebugLogString(Itv_var("cam"));
}

 

Example 5. Sending command to camera using the camera HTTPAPI

Example. Camera IP address is 192.168.0.13.

The command enables the camera wiper:

192.168.10.101/httpapi/SendPTZ?action=sendptz&PTZ_PRESETSET=85

The command disables the camera wiper:

192.168.10.101/httpapi/SendPTZ?action=sendptz&PTZ_PRESETSET=86

These commands are to be sent to camera using the Jscript script.

function DoPreset(preset)
{
    xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
    if(xmlhttp == null)
    {
           return;
    }
    xmlhttp.open("GET", "http://192.168.0.13/httpapi/SendPTZ?action=sendptz&PTZ_PRESETSET="+preset, false,"admin","1234");
 
    xmlhttp.send();
    DebugLogString(xmlhttp.status);
}
if (Event.SourceType == "MACRO" && Event.SourceId == "6" && Event.Action == "RUN") 
{
 DoPreset("85");
}
 
if (Event.SourceType == "MACRO" && Event.SourceId == "7" && Event.Action == "RUN") 
{
 DoPreset("86");
}

 Example 6. Script for framing abandoned objects in live video

If the object tracking function is in use (see  Creating and configuring the Timer object section of Administrator's Guide), then detected objects will be framed in video when viewing the archive. To frame abandoned objects in live video use the script aimed to frame an abandoned object when receiving alarm from VMDA detection tool:

if (Event.SourceType=="CAM_VMDA_DETECTOR")
{
 cam=GetObjectParentId("CAM_VMDA_DETECTOR",Event.SourceId,"CAM");
 if (Event.Action=="ALARM")
 {
   var x1,x2,y1,y2;
   x1=Event.GetParam("x");
   x2=Event.GetParam("w");
   y1=Event.GetParam("y");
   y2=Event.GetParam("h");
   x2=parseInt(x1)+parseInt(x2);
   y2=parseInt(y1)+parseInt(y2);
   DoReactStr("MONITOR","","SET_MARKRECT","cam<"+cam+">,color<255>,id<"+cam+">,x1<"+x1+">,x2<"+x2+">,y1<"+y1+">,y2<"+y2+">");
   DebugLogString("x1:"+x1+" x2:"+x2+" y1:"+y1+" y2:"+y2);
 }
 else
 {
   DoReactStr("MONITOR","","DEL_MARKRECT","cam<"+cam+">,id<"+cam+">");
 }
}

  • No labels