Nothing Special   »   [go: up one dir, main page]

Eocortex API SDK Guide en

Download as pdf or txt
Download as pdf or txt
You are on page 1of 58

Eocortex API and SDK

Technical Support Service contacts:


Phones: 8-800-555-0043 (free of charge within Russia)
+7 (342) 215-09-78
E-mail: support@eocortex.com
Skype: eocortex.support

© Satellite LLC, 2011–2019


Issued 11.07.2019
Eocortex API and SDK 2

Table of Contents

1. General information on Eocortex SDK ............................................... Ошибка! Закладка не определена.


2. Quick start – typical tasks ...................................................................................................................... 5
3. Plugins ............................................................................................. Ошибка! Закладка не определена.
3.1 Plugin registration in Eocortex ........................................................................................................................ 6
3.2 Action plugin ................................................................................................................................................... 8
3.3 Video analytics plugin ................................................................................................................................... 10
3.4 Motion detector plugin ................................................................................................................................. 15
3.5 Tracker plugin ............................................................................................................................................... 17
3.6 Visualizer plugin ............................................................................................................................................ 17
3.7 Menu item plugin .......................................................................................................................................... 19
3.8 Event processor plugin .................................................................................................................................. 21
3.9 Frame receiver plugin ................................................................................................................................... 23
4. Eocortex API with HTTP and RTSP interfaces ........................................................................................ 34
4.1 HTTP interface for video reception ............................................................................................................... 34
4.1.1 Real-time video and archive reception ...................................... Ошибка! Закладка не определена.
4.1.2 Transcoded MJPEG video reception. ................................................................................................. 35
4.2 HTTP interface for data aquisition ................................................................................................................ 36
4.2.1 Receiving system configuration ......................................................................................................... 36
4.2.2 Receiving profiles (preinstalled grids)................................................................................................ 41
4.2.3 Receiving a list of available grids in Eocortex Client .......................................................................... 42
4.2.4 Receiving current grid data in Eocortex Client .................................................................................. 42
4.2.5 Receiving computer time of the server on which Eocortex operates ............................................... 43
4.2.6 Receiving information regarding archive availability at a stated point of time ................................. 43
4.2.7 Receiving channel status information ............................................................................................... 43
4.2.8 Receiving PTZ capabilities of a device................................................................................................ 45
4.2.9 Receiving PTZ device presets ............................................................................................................. 46
4.2.10 Receiving recognized car number plates archive .............................................................................. 46
4.2.11 Receiving a list of all events registered in the system ....................................................................... 47
4.2.12 Receiving a list of special archive events ........................................................................................... 47
4.3 HTTP interface for event reception............................................................................................................... 48
4.4 HTTP interface for sending commands to Eocortex server........................................................................... 49
4.4.1 Switching channel recording on and off ............................................................................................ 49
4.4.2 Time synchronization with another computer in the network.......................................................... 49
4.4.3 Profile reception (preinstalled grids) ................................................................................................. 49
4.4.4 Profile installation in client ................................................................................................................ 49
4.4.5 Change of grid in client ...................................................................................................................... 49
4.4.6 Clearing the grid .............................................................................................................................. 49
4.4.7 Installation of a channel in a cell of a grid ........................................................................................ 50

Issued 11.07.2019
Eocortex API and SDK 3

4.4.8 Deleting a channel from the grid’s cell .............................................................................................. 50


4.4.9 PTZ command for continuous motion ............................................................................................... 50
4.4.10 PTZ command for continuous changing of focus............................................................................... 50
4.4.11 PTZ command for continuous zoom .................................................................................................. 50
4.4.12 PTZ stop command for permanent commands ................................................................................. 50
4.4.13 PTZ command for setting a preset ..................................................................................................... 50
4.4.14 PTZ command for automatic focusing ............................................................................................... 50
4.4.15 PTZ command for centering .............................................................................................................. 51
4.4.16 PTZ command for step-by-step motion ............................................................................................. 51
4.4.17 PTZ command for step zoom ............................................................................................................. 51
4.4.18 PTZ command for zooming in the selected area (AreaZoom) ........................................................... 51
4.4.19 Arming a channel ............................................................................................................................... 51
4.4.20 Sending sound to camera .................................................................................................................. 51
4.4.21 Generation of an event from an external system.............................................................................. 52
4.5 RTSP interface for obtaining video and sound .............................................................................................. 53
5. Eocortex API with XML interface.......................................................................................................... 55
5.1 People Counter data reception ..................................................................................................................... 55
6. Organization of video broadcast to a site ............................................................................................. 57
6.1 Flash video broadcast ........................................................................... Ошибка! Закладка не определена.
6.2 JavaScript video broadcast to site (out of date) ................................... Ошибка! Закладка не определена.

Issued 11.07.2019
Eocortex API and SDK 4

1. General Information on EOCORTEX SDK


Eocortex SDK is a tool that allows you to develop software called plugins, which can extend
functionality of existing Eocortex software system.
This tool is designed for .NET programmers who want to create plugins for Eocortex.
All source files of the tool and examples are coded for .NET in the C# language. Microsoft
Visual Studio is assumed as a development environment. For understanding the document
working knowledge of Eocortex terminology at the experienced user level is required. If
necessary, you can refer to the operator and administrator instructions provided along with
the Eocortex.
Within the Eocortex SDK framework, each plugin software is a descendant of one of the
available base classes (interfaces) from the tools, and solves a specific range of tasks. At the
moment the main base classes (interfaces) in the tools, which can be used by external
software designers, are as follows:
Plugin name Designation Description

ExternalAction Action Base class that allows adding new actions for
scripts and task scheduler
VideoAnalyst Video Base class used for video analytics on the server
analytics
plugin
MotionDetector Motion Base class used for motion detector
detector implementation
plugin
Tracker Tracker plugin Base class used for tracker creation
RTVisualiser Visualizer Visualizer base class used for graphic display of
plugin specific information on the Eocortex Client
application channel
ClientMenuItem Menu item Base class that allows to create proper sub-item
plugin in Setup menu of Eocortex Client
EventProcessor Event Event processor base class that allows to register
processor and generate its own events, get events from
plugin Eocortex, and execute commands in the
channel. Plugins of this type are used to perform
integration with other systems.
IRealTimeFrameReceiver Frame IP devices’ frame receiving interface that allows
receiver plugin to get video, audio and motion detection data
and control PTZ cameras.

• All the above specified base classes (interfaces) types, as well as some other
supporting entities, are the subjects of related chapters of the document. All the
plugins exist and operate within the Eocortex channel. Thus, all plugin instances are
isolated from each other by default, but, if necessary, relevant data can be shared
within plugin static fields. As a rule, plugins that solve the same complex task are in
one .NET assembly. Such assembly is a dynamic link library (DLL) which operates
within Eocortex. Assemblies connection and plugin registration is carried out at the
stage of startup of software system separate components (see Plugin registration in
Eocortex, page 6).

Issued 11.07.2019
Eocortex API and SDK 5

2. Quick start – typical tasks


1. IP camera integration
To connect an IP device (a camera), just implement the Frame Receiver plugin. All
the necessary information about this type of plugin can be found in the Frame Receiver
Plugin section (page 23). The plugin framework is in the folder with examples, in the
Camera.csproj project.
2. Integration with Access Control Systems, Security and Fire Alarm, POS
terminals, etc.
The integration can be performed through the Event Processor plugin, which is able
to receive events from Eocortex, generate its own events in Eocortex in the process
of interaction with other systems, execute commands in Eocortex (recording on / off,
setting presets, I/O from the cameras etc.) in the channel, getting access to Eocortex
archive. For information about this plugin type, see Event processor Plugin section
(page 21). The plugin example can be found in the examples folder in the
EventProcessor.cproj project. If Eocortex is required only to receive video and
audio, there is an easier option, discussed in the section HTTP interface for acquiring
video (page 34); the example of acquiring video over HTTP is in the examples folder
in the HttpVideo.cproj project.
3. Video Analytics
Any video processing algorithm can be implemented using the Video Analytics
plugin. All the analyst results are represented as events that can be further interpreted
by Menu Item and Visualizer plugins. These plugins are discussed in sections Video
Analytics Plugin (page 10), Visualizer Plugin (page 17)
and Menu Item Plugin (page 19); the example of usage can be found in the examples
folder in the Analyst.csproj project.

Issued 11.07.2019
Eocortex API and SDK 6

3. Plugins
The present chapter deals with the process of plugin registration. It also discusses in detail
each type of plugin. The most important code fragments are shown in the text.

3.1 Registration of plugins in Eocortex


As Eocortex software system separate components (Server/Client/Configurator,
hereinafter - host) start up, .NET assemblies are searched in the Plugins folder of the
starting application. The IPlugin interface must be implemented in each found assembly, as
follows:
public interface IPlugin
{
/// <summary>
/// Returns unique module identifier
/// </summary>
Guid Id { get; }

/// <summary>
/// Returns module name
/// </summary>
string Name { get; }

/// <summary>
/// Returns module manufacturer name
/// </summary>
string Manufacturer { get; }

/// <summary>
/// Module initialization.
/// It is called by the host during module registration in the system.
/// </summary>
/// <param name="host">Host interface</param>
void Initialize(IPluginHost host);
}
Example of the given interface implementation:
public class ModuleDef : IPlugin
{
public Guid Id
{
get { return new Guid("17EE3457-8FC2-4C0F-B133-EF11D0C4F38C"); }
}

public string Name


{
get { return "Abandoned object detection"; }
}

public string Manufacturer


{
get { return "Eocortex"; }
}

public void Initialize(IPluginHost host)


{
host.RegisterAnalyst(typeof(AnalystExample));
host.RegisterExternalEvent(typeof(ObjectLeftEvent));
}
}

Issued 11.07.2019
Eocortex API and SDK 7

Once the specified interface has been detected by the host, the initialization member
(Initialize) is called. As an argument IPluginHost interface, providing host service methods,
is transferred to the initialization member:
public interface IPluginHost
{
/// <summary>
/// Gets log management interface
/// </summary>
/// <returns></returns>
IMcLogMgr GetLogManager();

/// <summary>
/// Device registration.
/// </summary>
void RegisterDevType(DevType_RegInfo regInfo);

/// <summary>
/// Frame receiver registration.
/// </summary>
void RegisterRTFR(RTFR_RegInfo regInfo);

/// <summary>
/// Registers external event
/// </summary>
void RegisterExternalEvent(Type eventType);

/// <summary>
/// Registers external action
/// </summary>
void RegisterExternalAction(Type actionType);

/// <summary>
/// Registers a menu item in the Eocortex client
/// </summary>
void RegisterMenuItem(Type menuItemType, List<Guid> requiredPluginIDs);

// ... Other registration functions not shown here


}

Host service methods provide the following possibilities:


• Plugin actions logging with the IMcLogMgr interface, received by the GetLogManager()
relevant method.
• Registration of plugins in the system for solving various problems.

Issued 11.07.2019
Eocortex API and SDK 8

To specify the conditions of the plugin registration it is required to create the text file with
*.dep extension and the name coincident with the name of the dll-library containing plugin
implementation. The file which describes interactions can have, for example, the following
contents:
<?xml version="1.0"?>
<PluginDependence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Files>
<DependenceFilename>core.dll</DependenceFilename>
<DependenceFilename>..\..\..\EocortexSDK.dll</DependenceFilename>
<DependenceFilename>..\..\abc*.dll</DependenceFilename>
</Files>
<DependenceRegistryKey>
HKEY_LOCAL_MACHINE\SOFTWARE\Eocortex
</DependenceRegistryKey>
<DependenceRegistryValue>Path</DependenceRegistryValue>
</PluginDependence>

In revisions earlier than Eocortex 1.9 the given file is compulsory for plugin registration, in
later revisions it is not compulsory. It must be in the same folder as a plugin to be in use.
<Files> tag can contain multiple files. Symbol * is supported as a notation of any quantity
of any symbols. <DependenceRegistryKey> and <DependenceRegistryValue> tags are
meaningful only when used together.

3.2 Action plugin


An action plugin allows to extend the list of functions in scripts and in the task scheduler. It
is necessary to make a class ExternalAction descendant to create this plugin type:
/// <summary>
/// Base action class.
/// </summary>
[Serializable]
public abstract class ExternalAction : IAction
{
[NonSerialized]
protected IActionHost actionHost;

/// <summary>
/// Initialization. It is called by host before starting work.
/// </summary>
/// <param name="host"></param>
public virtual void Initialize(IActionHost host)
{
actionHost = host;
}

/// <summary>
/// User action setting element. It is called by configurator.
/// Must return UserControl type (WPF).
/// </summary>
public abstract object GetGUISettingsControl();

Issued 11.07.2019
Eocortex API and SDK 9

/// <summary>
/// Displays if the current action
/// is configured properly
/// </summary>
public abstract bool IsConfigurated
{
get;
}

/// <summary>
/// The feature shows if the action is related to
/// the specific channel. In other words, whether the action affects
/// the channel in any way.
/// </summary>
public virtual bool IsChannelIndependent
{
get
{
//the action is not related to channel in any way by default
return true;
}
}

/// <summary>
/// Starting action to be executed
/// </summary>
public abstract void Run(RawChannelEvent channelEvent);

/// <summary>
/// Command execution in the channel. It is completed by server, can be used in
/// the Run method (see above)
/// </summary>
[NonSerialized]
public ExecuteCommandDelegate ExecuteCommand;
}
In the descendant class the following attributes must be created:
• ActionGUIName – name of action, used in graphic interface in the configurator.
• GuidAttribute – action identification.
ActionNeedsEventArgument attribute can be determined as an option to define that the
event object must be transmitted from the server to call Run plugin method. It also means
that the action is executed only at an event, and cannot be executed in the scheduled tasks
when events do not occur in these tasks.
Also, the base class methods must be defined (redefined). Let’s consider in detail the
initialization member in which IActionHost interface is passed from the host. The interface
is as follows:

/// <summary>
/// Interface providing the host capabilities
/// when initializing the action plugin.
/// </summary>
public interface IActionHost
{
/// <summary>
/// Getting information about the channel,
/// in which the current action plugin
/// runs.
/// </summary>
RawChannelInfo GetChannelInfo();

Issued 11.07.2019
Eocortex API and SDK 10

/// <summary>
/// Saves any serialized object in the
/// Eocortex configuration. It is used in the configurator.
/// </summary>
/// <param name="id">Object identifier</param>
/// <param name="obj">Object</param>
void SaveObject(Guid id, object obj);

/// <summary>
/// Gets a previously serialized object from the configuration.
/// It is used in the configurator.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
object GetObject(Guid id);
}
The interface allows to get the information on the channel to which the plugin instance is
attached. The information includes the channel name and identification. The identification
must be used at command execution in the channel (ref. ExecuteCommand delegate).
For more detailed information on available commands refer to Section Event Processor Plugin
(page 21). In addition, with the help of SaveObject and GetObject methods the given
interface allows to save and download any serializable object using its identifier when
Eocortex configuration is set. This technique allows to save and retrieve settings that are the
same for all plugin instance configurations.
GetGUISettingsControl method must return the UserControl type element, which contains
a graphic interface for the plugin instance configuration in the configurator. The whole graphic
interface must be executed with WPF (Windows Presentation Foundation). IsConfigurated
property shows if the action is configured correctly in the graphic interface. If anything is
wrong, the configuration cannot be applied unless the mistakes are corrected.
For Action registration in the system, it is required to call RegisterExternalAction host
interface method (see Рlugin registration in Eocortex, page. 6) when downloading the assembly
and plugin in the IPlugin initialization class method.

3.3 Video Analytics Plugin


This plugin type analyses video stream frame-by-frame, and allows to create service
detectors, such as abandoned objects detector, sabotage detector and others. To create this
plugin type, the VideoAnalyst base class descendant must be created:

/// <summary>
/// Video analytics class. It is used for frame and motion map processing.
/// </summary>
public abstract class VideoAnalyst : IDisposable
{
/// <summary>
/// Analyst initialization. It is called by host before starting processing.
/// </summary>
/// <param name="Id">A channel identifier</param>
/// <param name="archiveEventsReader">Archive access interface</param>
/// <param name="mdZones">Motion detection zones.</param>
/// <param name="settings">Analyst settings.</param>
public abstract void Initialize(Guid Id, IArchiveEventsReader archiveEventsReader,
List<MDZone> mdZones, PluginSettings settings);

Issued 11.07.2019
Eocortex API and SDK 11

/// <summary>
/// Frames and motion maps processing method. It is called by host.
/// </summary>
/// <param name="image">Frame</param>
/// <param name="motionMap">A motion map, can be null</param>
/// <param name="background">A motion detector background. Is equal to null, if
/// NeedBackground == false</param>
public abstract void Process(ImageData image, MotionMap motionMap,
BackgroundImage background);

/// <summary>
/// Generates a previously registered external event in the channel.
/// It is completed by host. It is called by analyst.
/// </summary>
public GenerateEventDelegate GenerateEvent;

/// <summary>
/// If the analyst supports work with partially decoded frames.
/// True means that zoomed out video frames can be transmitted to the input,
/// False means that video frames in original resolution are always transmitted
/// to the input.
/// </summary>
public virtual bool SupportsPartlyDecodedFrames
{
get
{
return false;
}
}

public virtual bool NeedBackground


{
get
{
return false;
}
}

/// <summary>
/// Pixel format supported
/// </summary>
public virtual VAPixelFormat PixelFormat
{
get
{
return VAPixelFormat.BGR24;
}
}

/// <summary>
/// Executes a command.
/// </summary>
/// <param name="cmdObj"></param>
public abstract object ProcessCommand(object cmdObj);

/// <summary>
/// Replaces a motion detector for a preset one in the channel.
/// Ii is completed by host. Can be null.
/// </summary>
public ReplaceMotionDetectorDelegate ReplaceMotionDetector;

Issued 11.07.2019
Eocortex API and SDK 12

/// <summary>
/// Resource deallocation
/// </summary>
public abstract void Dispose();

/// <summary>
/// Changes general or specific analyst settings, if necessary.
/// A calling of method shall result in opening of user setting window.
/// It is called by host (configurator).
public abstract PluginSettings SetSettings(ISettingsHost settingsHost,
PluginSettings settings);
}
Descendant class must redefine all base class abstract methods and, if necessary, virtual
properties. Also, a subclass must contain PluginGUINameAttribute, which contains the
name of the analyst displayed in Eocortex Configurator graphical shell. In case the analyst
can be set up in the configurator, implementing SetSettings adjustment method and
specifying PluginHasSettingsAttribute is required.
Video data is transmitted to the analyst input as a class described below:

public class ImageData


{
public DateTime Timestamp;
public byte[] Data;
public System.Drawing.Size Size;
public int Stride;
public int BitPerPixel;
}
As each analytic plugin is attached by the user to a channel, PluginSettings object of
configuration in Eocortex configurator consists of 2 parts:
1) Settings related to the current security channel
2) General analyst settings, unrelated to the selected security channel.

public struct PluginSettings


{
/// <summary>
/// Specific plugin settings related to the current channel. Can be null.
/// A setting object must be serializable.
/// </summary>
public object channelSpecificSettings;

/// <summary>
/// General plugin settings. Are not related to the current channel. Can be null.
/// A setting object must be serializable.
/// </summary>
public object generalSettings;
}

If analyst settings are unified for all channels, it is sufficient to complete only a general setting
object. Otherwise, if all the analyst settings are related to a specific channel, it is sufficient to
complete only a specific channel setting object. The objects of general and specific settings are
user-defined. The only requirement for them is the possibility of their serialization, as all the
analyst settings are kept in Eocortex general configuration.

Issued 11.07.2019
Eocortex API and SDK 13

Let us consider ProcessCommand method which allows the analyst to execute commands
from the Menu Item plugin (see Menu Item plugin, page 19). This method receives a
command as a serialized object formed on the Menu Item plugin side. As a result, this
method shall also return the serialized object, which will be received subsequently and
processed by the Menu Item plugin. This mechanism allows to implement client-server
interaction, as the Videoanalyst plugin operates on the server, and the Menu Item plugin
always operates in the client.
While processing video frames, the videoanalyst shall transmit the results of its analysis to
the server by means of event generating. To do so, it is required to register in advance on
the host side (see Plugin registration in Eocortex, page 6) the outside user event containing a
description of all fields required for interpreting the operating results of the analyst. The event is
registered by IPluginHost interface using RegisterExternalEvent method during the
module initialization stage. The user event must inherit RawChannelEvent base class:

/// <summary>
/// Parent class in event hierarchy on channel.
/// </summary>
[Serializable]
public abstract class RawChannelEvent
{
/// <summary>
/// Event time stamp.
/// </summary>
public DateTime EventTime;

/// <summary>
/// An event comment.
/// </summary>
public string Comment;

/// <summary>
/// If event is local.
/// Local events are not sent outside the current host.
/// </summary>
public bool IsLocal = false;

/// <summary>
/// If the event is to be saved in the database
/// </summary>
public bool Save = true;

/// <summary>
/// The event saving mode in the database.
/// </summary>
public abstract EventArchiveSaveMode SaveMode
{
get;
}

public RawChannelEvent()
{
EventTime = DateTime.UtcNow;
}
}
Each user event should have a number of mandatory attributes:
• GuidAttribute – explicitly defines a unique event
• Serializable - allows to complete event serialization

Issued 11.07.2019
Eocortex API and SDK 14

In addition, there are following optional attributes:


• EventNameGUI - names the event in the host graphic interface. Unless the attribute is
specified, the event is not displayed in scripts in the configurator;
• EventNameDatabase - a database table in which event instances are saved; the
attribute must be used if the event has fields that must be saved in the database (it is
important that SaveMode event property takes Special or Both values);
• EventGeneratesAlarmByDefault - a default event is an alarm, “Generate alarm” is
automatically attached to the event when new channel is created in Eocortex
configurator;
• EventGenerationFrequency - denotes event generation frequency, requires
EventGenerationFrequencyMode (ref. below). The attribute is recommended as it affects
server operation when events are saved in the database. Unless the attribute is not
defined, Middle mode is used by default. This mode is preferred. Low mode is not
advisable as events are recorded in the specific database, critical for functioning.
/// <summary>
/// Event generation frequency.
/// </summary>
public enum EventGenerationFrequencyMode
{
/// <summary>
/// Events are generated at frequency,
/// close to the frequency of frame analysis
/// </summary>
High = 0,
/// <summary>
/// Events are generated at frequency compared to
/// half of frame analysis frequency
/// </summary>
Middle
}
If the user event contains fields that must be saved in the database, the EventFieldSaveable
attribute should be denoted for each field. The attribute needs a field ordinal number - Order
(starting from 0) and IsIndexable flag, which denotes if the field index is required.
The following event field types with the following attributes int, bool, long, double,
DateTime, string, Guid, byte[] are supported.
SaveMode property defines if the event is to be saved in the database. The event can be
saved in a base table, that contains only RawChannelEvent class fields, and in a specific
one with all event fields. It is possible to save all events in both tables. The base table allows
to record the occurrence of the event in the system. Afterwards the user can read the events
from the base table with Eocortex tools.

Issued 11.07.2019
Eocortex API and SDK 15

Thus, the user event can be implemented as follows:

[GuidAttribute("389EDCE2-54BB-4C2C-9984-51B7516A5DDF")]
[EventNameGUI("The object is left")]
[EventDatabaseName("objectleft")]
[EventGeneratesAlarmByDefault]
[EventGenerationFrequency(EventGenerationFrequencyMode.Low)]
[Serializable]
public class ObjectLeftEvent : RawChannelEvent
{
[EventFieldSaveable(0, true)]
[EventFieldNameGUI("Object")]
private string objectName;

public ObjectLeftEvent(string objectName)


{
this.objectName = objectName;
}

public override EventArchiveSaveMode SaveMode


{
get { return EventArchiveSaveMode.Both; }
}
}
For VideoAnalyst plugin registration, the host interface RegisterAnalyst method must be
called at the stage of assembly and plugin loading in IPlugin interface using class initialization
method (see Рlugin registration in Eocortex, page 6).

3.4 Motion Detector plugin


The plugin type allows to create an alternative motion detector for Eocortex. To do so, the
MotionDetector class descendant needs to be created:

/// <summary>
/// A motion detector.
/// Base abstract class for all motion detectors.
/// </summary>
public abstract class MotionDetector
{
/// <summary>
/// Detection zones.
/// </summary>
protected List<MDZone> zones = new List<MDZone>();

/// <summary>
/// Adds zone 1 with a full frame mask.
/// </summary>
public void AddFullFrameZone()
{
MDZone zone = new MDZone();
zones.Add(zone);
}

Issued 11.07.2019
Eocortex API and SDK 16

/// <summary>
/// Adds zone 1 with a full frame mask, with the zone features.
/// </summary>
public void AddFullFrameZone(float minObjWidth, float minObjHeight)
{
MDZone zone = new MDZone(0, minObjWidth, minObjHeight);
zones.Add(zone);
}

/// <summary>
/// Zone adding.
/// </summary>
/// <param name="zone">A zone added.</param>
public void AddZone(MDZone zone)
{
zones.Add(zone);
}

/// <summary>
/// Amount of zones. Read only.
/// </summary>
public int ZonesCount
{
get
{
return zones.Count;
}
}

#region Parameters needed for a standard motion detector



#endregion

/// <summary>
/// Motion detection in the preset frame.
/// </summary>
/// <param name="width">Frame width.</param>
/// <param name="height">Frame hight.</param>
/// <param name="bgr24bytes"> Array of bytes in video frame in bgr24
///format.
/// </param>
/// <param name="timestamp">Time stamp.</param>
/// <returns>Returns the motion map. Index > 0 means that motion occurs
/// in controlled pixel. Index value in the motion map
/// corresponds to index of a moving object.
///</returns>
public abstract MotionMap Detect(int width, int height, int offset,
int stride, byte[] bgr24bytes, DateTime timestamp);
}
Zones field is server completed before the plugin type operation starts by means of
AddFullFrameZone and AddZone methods. All fields in “Essentials for standard motion
detector” are used by a built-in motion detector only and must not be altered.
Main plugin logic is in Detect method, which receives bgr24 video frame (Blue, Green, Red
channels, 8 bytes each channel). The method results in MotionMap. To create a motion map
two arrays are required:
1) Occurrence of the motions map is two-dimensional array of integral numbers. Each
nonzero number of the array (index) identifies a moving object. Zero 0 means absence
of motion.
2) Objects in the motion array. Access to elements of the array is fulfilled through the
motion map indexes.

Issued 11.07.2019
Eocortex API and SDK 17

For the Motion Detector plugin registration the host interface RegisterMotionDetector
method must be called at the stage of assembly and plugin loading in IPlugin interface using
class initialization method (see Plugin registration in Eocortex, стр. 6).

3.5 Tracker Plugin


A plugin of this type allows to create a tracker for Eocortex. To do so, the Tracker class
descendant must be created:
/// <summary>
/// Base class for all trackers.
/// <summary>
/// Base class for all trackers.
/// </summary>
public abstract class Tracker
{
/// <summary>
/// The frame and the motion map processing.
/// Processing result is changed motion map with correctly denoted
/// indexes of moving objects.
/// </summary>
/// <param name="width">Frame width.</param>
/// <param name="height">Frame height.</param>
/// <param name="offset"> Indent in bytes before the frame in byte array.</param>
/// <param name="stride">Stride.</param>
/// <param name="bgr24bytes">The frame pixel bytes.</param>
/// <param name="timestamp">Time stamp.</param>
/// <param name="detectedMap"> Detected motion map.
/// Value can be changed after processing.</param>
public abstract void Process(int width, int height, int offset, int stride,
byte[] bgr24bytes, DateTime timestamp, ref MotionMap detectedMap);
}
Main logic is implemented by Process, which receives bgr24 video frames (Blue, Green,
Red channels, 8 bytes each channel) and MotionMap, received by the Motion Detector
plugin. The plugin operation results are tracked objects identifiers that should be marked on
the motion map.

3.6 Visualiser Plugin


This plugin allows to display information from events that are received by Eocortex Client
channels in graphics (e.g., frames of moving objects, identified numbers, faces, etc.). For this
plugin type, the RTVisualiser class descendant is to be created:
/// <summary>
/// Visualiser class.
/// </summary>
public abstract class RTVisualiser
{
/// <summary>
/// Panel for primitive, text and another channel information drawing.
/// </summary>
protected IDrawingPanel drawingPanel;

/// <summary>
/// Graphical elements container. Allows to deposit separate
/// UserControl elements in the channel.
/// </summary>
protected Panel controlsContrainer;

protected IPluginToolSet pluginToolset;

Issued 11.07.2019
Eocortex API and SDK 18

/// <summary>
/// Visualiser initialization. It is called by host.
/// </summary>
/// <param name="Id">A channel identifier</param>
/// <param name="pluginToolset"> Archive access interface used for sending
commands
/// for event subscription in the system.</param>
/// <param name="drawingPanel"> A drawing panel.</param>
/// <param name="controlsContrainer"></param>
public virtual void Initialize(Guid Id, IPluginToolSet pluginToolset,
IDrawingPanel drawingPanel, Panel controlsContrainer)
{
this.pluginToolset = pluginToolset;
this.drawingPanel = drawingPanel;
this.controlsContrainer = controlsContrainer;
}

/// <summary>
/// Visualiser event processing. Specific drawing of event results.
/// </summary>
/// <param name="channelId">A channel identifier</param>
/// <param name="chEv">Event.</param>
/// <param name="isAlarm">If event is alarm</param>
public abstract void ProcessEvent(Guid channelId, RawChannelEvent chEv,
bool isAlarm);

/// <summary>
/// Delegate for sub-item registration in channel pop-up menu
/// in Eocortex client.
/// It is completed by host. It is called by visualiser.
/// </summary>
/// <param name="item"></param>
public RegisterChannelMenuItemHandler RegisterChannelMenuItem;

/// <summary>
/// Clearing all the visualizer drawings.
/// </summary>
public abstract void Clear();

/// <summary>
/// All resources deallocation. It is obligatory to call Release base class
/// in reloaded descendant methods.
/// </summary>
public virtual void Release()
{
drawingPanel = null;
controlsContrainer = null;
pluginToolset = null;
RegisterChannelMenuItem = null;
}
}
Each Visualiser plugin must define ProcessEvent method, which receives events from the
channel. All events are generated by Eocortex and other plugins. The plugin can visualize
events of any type, and they can be filtered using if operator and is key word, for example:

if (chEv is CounterEvent)
{
...
}

Issued 11.07.2019
Eocortex API and SDK 19

Visualiser can register its subitem in the pop-up menu (right click on the channel in the
Eocortex Client). This allows to alter visualiser logic according to the user preference. It is
provided by RegisterChannelMenuItem delegate.
For Visualiser plugin registration, the host interface RegisterRTVisualiser method must be
called at the stage of assembly and plugin loading in IPlugin interface using class initialization
method (see Registration of plugins in Eocortex, page 6).

3.7 Menu Item plugin


The plugin of this type allows to create a proper graphic interface in Eocortex Client, and
the user can call it by clicking the corresponding Configuration menu item.
Typical plugin application is organization of client-server interaction with other plugins. For
example, the plugin can process results of analytical plugin operation on the server.
ClientMenuItem class descendant must be created to make a menu item plugin:

/// <summary>
/// Menu item class. It is used in client for adding
/// sub-items on the Configuration button menu.
/// </summary>
public abstract class ClientMenuItem : IDisposable
{
private bool isEnabled = true;

/// <summary>
/// Plugin initialization.
/// </summary>
/// <param name="toolSet"></param>
public abstract void Initialize(IPluginToolSet toolSet);

/// <summary>
/// Menu item name.
/// </summary>
public abstract string Name
{
get;
}

/// <summary>
/// If the menu item is enabled.
/// </summary>
public bool IsEnabled
{
get
{
return isEnabled;
}
set
{
isEnabled = value;
}
}

/// <summary>
/// Processing method of click (keystroke) of the user
/// </summary>
public abstract void OnClicked();

Issued 11.07.2019
Eocortex API and SDK 20

/// <summary>
/// Resourses release method.
/// </summary>
public abstract void Dispose();
}
The initialization method should be defined in the descendant class, which receives interface with
service functions from the host (Eocortex Client). The functions allow to receive channel
identifiers and their names in current configuration. In addition, they provide access to Eocortex
archive and possibility to send commands to analytical plugins and receive results of their
execution. It is possible to subscribe for all events occurring in the system. The interface is as
follows:

/// <summary>
/// A host provided interface for
/// archive access, sending commands,
/// system events subscription.
/// </summary>
public interface IPluginToolSet
{
/// <summary>
/// Receives archive access interface
/// </summary>
/// <returns></returns>
IArchiveEventsReader GetArchiveReader();

/// <summary>
/// Sends a command to plugin
/// running in the server.
/// </summary>
/// <param name="pluginId">Plugin identifier</param>
/// <param name="channelsId">Channel identifiers</param>
/// <param name="cmdObj">Command</param>
/// <returns> Returns each channel result.
/// The key is channel identifier.
/// Value is a result of the command execution.</returns>
Dictionary<Guid, object> SendChannelsCommand(Guid pluginId,
List<Guid> channelsId, object cmdObj);

/// <summary>
/// Installs/deletes the channel event handler.
/// </summary>
/// <param name="subscrId"> A subscriber identifier </param>
/// <param name="channelId"> A channel identifier </param>
/// <param name="eventsHandler"> Handler. If it is null, then
/// previously installed handler is deleted.</param>
void SetEventsHandler(Guid subscrId,
Guid channelId, EventsHandler eventsHandler);

/// <summary>
/// Receives plugin settings with a specified identifier for the channel.
/// </summary>
/// <param name="channelId">A channel identifier</param>
/// <param name="pluginId">Plugin identifier</param>
/// <returns></returns>
PluginSettings GetPluginSettings(Guid channelId, Guid pluginId);
}
GetArchiveReader method provides access interface to archive and current channels
information in the configuration. Detailed data about this interface are kept in Eocortex SDK
source codes.

Issued 11.07.2019
Eocortex API and SDK 21

SendChannelsCommand method sends commands to different plugin instances of the same


type according to the list of channels and receives results of command execution.
SetEventsHandler method sets up and deletes the channel event handler.
OnClicked method must implement the user logic through graphic interface. It is called by
client by clicking on the plugin-related menu item.
For Menu Item plugin registration the host interface RegisterMenuItem should be called at the
stage of assembly and plugin loading in IPlugin interface of class initialization method (see Plugin
registration in Eocortex, page 6).

3.8 Event Processor plugin


The Event Processor plugin allows to receive and process signals from external systems.
While processing signals, the plugin can execute commands and generate events in its
channel. The event processor is created by means of inheritance from EventProcessor base
class:

/// <summary>
/// Plugin class for system event processing, command and proper event generating.
/// </summary>
public abstract class EventProcessor
{
/// <summary>
/// Initialization. Called by host.
/// </summary>
/// <param name="archiveReader">Archive access interface</param>
/// <param name="channelSpecificSettings">Plugin settings</param>
public abstract void Initialize(IArchiveEventsReader archiveReader,
PluginSettings settings);

/// <summary>
/// Generates a registered external event in the channel. Is completed
/// by host. Called by plugin.
/// </summary>
public GenerateEventDelegate GenerateEvent;

/// <summary>
/// Sends a set command to be executed in the channel. Is completed by host.
/// Called by plugin.
/// </summary>
public ExecuteCommandExDelegate ExecuteCommand;

/// <summary>
/// Allows to subscribe for events on the channel. Completed by
/// plugin if necessary at the initialization stage.
/// </summary>
public ReceiveEventDelegate OnChannelEventReceived;

/// <summary>
/// Changes general or specific settings, if necessary.
/// Method calling must result in user setting window opening.
/// It is called by host (configurator).
/// </summary>
/// <param name="settings"> Current plugin settings.</param>
/// <returns>New plugin settings.</returns>
public abstract PluginSettings SetSettings(PluginSettings settings);
}

Issued 11.07.2019
Eocortex API and SDK 22

A subclass must contain an obligatory attribute PluginGUINameAttribute, which has the


analyst name displayed in Eocortex Configurator graphics. In case the analyst can be set
up in the configurator, SetSettings adjustment method must be implemented and
PluginHasSettingsAttribute identified.
Initialize method receives the interface for access to Eocortex archive from the host and plugin
setting object. As each plugin is attached to a channel, PluginSettings object of configuration
consists of 2 parts:
1) Settings related to the current security channel;
2) General analyst settings, unrelated to the selected security channel.

public struct PluginSettings


{
/// <summary>
/// Specific plugin settings related to the current channel. Can be null.
/// A setting object must be serializable.
/// </summary>
public object channelSpecificSettings;

/// <summary>
/// General plugin settings. Not related to the current channel. Can be null.
/// A setting object must be serializable.
/// </summary>
public object generalSettings;
}
If the analyst settings are unified for all channels, it will be enough to complete only general
settings object. Otherwise, if all the plugin settings are related to a single channel, it will be
enough to complete only a specific channel settings object. General and specific objects are
user-defined. The only requirement is the object serialization, as all the plugin settings are
kept in Eocortex general configuration.
If the plugin must execute a specific command as a result of its operation (such as, turn
recording on/off, set up a preset on a camera, turn a camera, etc.), a command object should
be created. Currently there are following commands:
• RawEnableRecordingCommand - turns on a record in the channel, record interval is
defined optionally;
• RawDisableRecordingCommand - turns off a record in the channel;
• RawGoToPresetPtzCommand - sets up a preset on a camera;
• RawGoHomePtzCommand - sets up home camera position;
• RawStopPtzCommand - stops ptz (panorama/tilt/zoom) command execution on a
camera;
• RawMovePtzCommand - one step movement;
• RawZoomPtzCommand – relative approximation (zoom);
• RawStartMovePtzCommand - continuous (preferred flowing) motion;
• RawMoveToPtzCommand - turns a camera so that a reference point is in the center
of the frame area;
• RawSetOutputIOCommand - adjusts a signal level on the camera output;
• RawSetOutputPulsesIOCommand - generates the impulse sequence on the camera
output
The Event Processor plugin can subscribe for events occurring at the channel. To do so the
event processor has to complete OnChannelEventReceived delegate when initializing. In
addition, the plugin can generate its own events at the channel.
For the Event Processor plugin registration, the host interface RegisterEventProcessor
should be called at the stage of assembly and plugin loading in IPlugin interface of class
initialization method (see Plugin registration in Eocortex, page 6).

Issued 11.07.2019
Eocortex API and SDK 23

3.9 Frame receiver plugin


The plugin of this type allows to receive video and sound from IP devices and motion detection
data, to control PTZ cameras and IP devices’ inputs/outputs (IO). To perform the subtask of
receiving frames, the IRealTimeFrameReceiver interface must be implemented:

/// <summary>
/// Interface of receiving real time frames.
/// Used for creation of plugins that receive frames
/// from IP cameras.
/// </summary>
public interface IRealTimeFrameReceiver
{
/// <summary>
/// Event handler on receiving a new frame.
/// It is called by the side that operates interface.
/// The host is subscribed for events.
/// </summary>
event NewRawFrameEventHandler NewRawFrame;

/// <summary>
/// Event handler. It is called by the side that operates interface.
/// The host is subscribed for the handler.
/// </summary>
event NewRawEventHandler NewEvent;

/// <summary>
/// Handler of a new record entering in the log. Informs the host that
/// Connection Log field has changed (ref. below).
/// The log is viewed in the Configurator after clicking the "Log History"
/// It is called by the side that operates interface.
/// The host is subscribed for the handler.
/// </summary>
event EventHandler NewLogRecord;

/// <summary>
/// A flag that denotes if it is necessary to enter a record in log.
/// It is changed by host.
/// </summary>
bool IsWritingConnectionLog
{
get;
set;
}

/// <summary>
/// Current content of the connection log.
/// </summary>
string ConnectionLog
{
get;
}

/// <summary>
/// If the stream is active
/// </summary>
/// <param name="streamType">Stream type</param>
/// <returns></returns>
bool IsStreamActive(ChannelStreamTypes streamType);

Issued 11.07.2019
Eocortex API and SDK 24

/// <summary>
/// Starts the specified stream to receive frames
/// </summary>
/// <param name="streamType"></param>
void StartStream(ChannelStreamTypes streamType);

/// <summary>
/// Stops the specified stream
/// </summary>
/// <param name="streamType"></param>
void StopStream(ChannelStreamTypes streamType);

/// <summary>
/// Sends sound to the device (duplex sound realization).
/// </summary>
/// <param name="soundData"></param>
void SendSound(byte[] soundData);

/// <summary>
/// Releases all resources. Closes all streams.
/// </summary>
void Release();
}
While implementing this interface, it is necessary to create a mechanism for working with
data streams, which can be a sequence of particular frame type, or a sequence of events.
Current Eocortex SDK version contains the following data stream types:

/// <summary>
/// Channel stream types.
/// </summary>
public enum ChannelStreamTypes : ulong
{
/// <summary>
/// Main video stream
/// </summary>
MainVideo = 1,

/// <summary>
/// Alternative video stream
/// </summary>
AlternativeVideo = 2,

/// <summary>
/// Camera sound stream.
/// </summary>
MainSound = 4,

/// <summary>
/// Alternative sound stream
/// </summary>
AlternativeSound = 8,

/// <summary>
/// Reverse sound stream.
/// </summary>
OutputSound = 16,

/// <summary>
/// Motion detection data stream.
/// </summary>
MotionDetection = 32,

Issued 11.07.2019
Eocortex API and SDK 25

/// <summary>
/// Camera I/O system data stream
/// </summary>
IO = 64,
}

The data streams of different types are to be generated depending on the device capabilities
and the channel settings in the configurator.
MainVideo and AlterntaiveVideo data streams consist of RawVideoFrame video frames,
received from the camera.
MainSound and AlternativeSound, and OutputSound data streams consist of
RawSoundFrame sound frame sequence. MotionDetection data stream consists of
RawChEv_MDresults and Raw ChEv_NoDetection events sequence.
I/O stream consists of RawChEv_InputSignalLevelChanged events.
StartStream method starts the data streams from the host, in which the next stream is
initialized. The method has to immediately return control to the host and implement long-
term operations (input/output operations) in separate streams. Stopping the streams and
control of their activities using StopStream and IsStreamActive methods is called by the
host, and these actions must be completed immediately without any long-term operations.
Streams return the results of their operation to the host by calling frame (NewRawFrame)
and event (NewEvent) handlers.
For example, if the IP-device sends MJPEG frames, MainVideo (or AlternativeVideo), the
data stream must call NewRawFrame and transmit RawMJPEGFrame video frame as one
of the arguments:

/// <summary>
/// MJPEG frame
/// </summary>
[Serializable]
public class RawMJPEGFrame : RawVideoFrame
{
public RawMJPEGFrame() { }

/// <summary>
/// The frame data
/// </summary>
/// <param name="data"></param>
public RawMJPEGFrame(byte[] data)
{
Data = data;
}
}

Issued 11.07.2019
Eocortex API and SDK 26

Likewise, for MainSound (or AlternativeSound) data stream and sound in the G.711U
format, the frame RawG711UFrame is to be transmitted:

/// <summary>
/// G.711U frame
/// </summary>
[Serializable]
public class RawG711UFrame : RawSoundFrame
{

/// <summary>
/// The frame data
/// </summary>
/// <param name="data"></param>
public RawG711UFrame(byte[] data)
{
this.Data = data;
this.samplesRate = 8000;
this.bitsPerSample = 16;
this.channels = 1;
this.bitrate = 64000;
}
}
After the creation of the appropriate type video frame, completing the following fields of
RawFrame base class is required:
• Id – the frame identifier consisting of 2 parts: a sequence identifier (is generated at
random before receiving the data stream) and a frame ordinal number.
• Timestamp – the frame timestamp, defined in UTC format.
In MPEG-4 and H.264 codecs:
• It is obligatory for P-frames to complete Dependencies field containing all frame identifiers
on which the given frame depends.
• The decoder initializing information is to be defined in SpecInitData field in each I-frame.
Example of MJPEG frame creating:

RawMJPEGFrame jpegFrame = new RawMJPEGFrame(frameData);


jpegFrame.Id.SeqId = videoSeqId;
jpegFrame.Id.NumInSeq = videoNumInSeq++;
jpegFrame.TimeStamp = DateTime.UtcNow;
where the initial settings are:
// video frame sequence identifier
Guid videoSeqId = Guid.NewGuid();
// Next video frame number in the sequence
long videoNumInSeq = 0;
Example of H.264 I frame:
RawH264_I_Frame iFrame = new RawH264_I_Frame(frameData);
iFrame.Id.SeqId = videoSeqId;
iFrame.Id.NumInSeq = videoNumInSeq++;
iFrame.TimeStamp = DateTime.UtcNow;
iFrame.SpecInitData = initData;
where initData is the initializing information for a decoder.

Issued 11.07.2019
Eocortex API and SDK 27

Example of H.264 P frame:


RawH264_P_Frame pFrame = new RawH264_P_Frame(frameData);
pFrame.Id.SeqId = videoSeqId;
pFrame.Id.NumInSeq = videoNumInSeq++;
pFrame.TimeStamp = DateTime.UtcNow;
pFrame.Dependencies = frameDependencies;
where frameDependencies is the array of frame identifiers the frame depends on. In other
words, it is a set of frames that must be decoded before the frame decoding.

Example of G.711U frame:


RawG711UFrame g711Frame = new RawG711UFrame(frameData);
g711Frame.Id.SeqId = audioSeqId;
g711Frame.Id.NumInSeq = audioNumInSeq++;
g711Frame.TimeStamp = DateTime.UtcNow;
If during the receiving of data streams a connection with the IP device becomes lost, Frame
Receiver plugin must inform the host by generating RawChEv_NoDataConnection event
with the obligatorily completed StreamTypes field which shows streams with the lost
connection).
For registering frame receiver in the system it is necessary to complete DevType_RegInfo
registration information of the device and the RTFR_RegInfo plugin registration information.
DevType_RegInfo class is described below:

/// <summary>
/// The device registration information.
/// is used during frame receiving plugin
/// registration.
/// </summary>
public class DevType_RegInfo
{
/// <summary>
/// Device identifier.
/// </summary>
public Guid DeviceTypeGuid;

/// <summary>
/// Name of manufacturer.
/// </summary>
public string DevTypeBrandName;

/// <summary>
/// Device name.
/// </summary>
public string DevTypeModelName;

/// <summary>
/// List of device capabilities.
/// </summary>
public DevType_Capabilities Capabilities;

/// <summary>
/// List of available resolutions for the device.
/// </summary>
public List<VideoResolutions> AvailableResolutions = new
List<VideoResolutions>();

Issued 11.07.2019
Eocortex API and SDK 28

/// <summary>
/// Delegate that allows host to change camera/ video server settings.
/// </summary>
public SetDeviceParametersDelegate SetDeviceParameters;

/// <summary>
/// Receiving IRealTimeFrameReceiver interface.
/// </summary>
public GetRTFRDelegate GetRTFR;

/// <summary>
/// Receiving PTZ interface.
/// </summary>
public GetPtzControllerDelegate GetPtzController;

/// <summary>
/// Receiving I/O interface.
/// </summary>
public GetIOControllerDelegate GetIOController;
}
GetRTFR delegate, called by host, must return a specific implementation of
IRealTimeFrameReceiver interface. The delegate receives connection parameters
(ConnectionParameters) and substream parameters (SubStreamParameters), which
have been defined by the user in the channel configuration as arguments.
Capabilities of IP device with which the Frame Receiver plugin operates are described in the
Capabilities field:

/// <summary>
/// List of device capabilities
/// </summary>
public enum DevType_Capabilities : ulong
{

/// <summary>
/// Device supports only cameras.
/// </summary>
SupportsCameras = 1,
/// <summary>
/// Device supports cameras and video servers.
/// </summary>
SupportsCamerasAndServers = 2,
/// <summary>
/// Device supports alternative stream.
/// </summary>
SupportsAlternativeVideoStream = 4,
/// <summary>
/// Parameters (resolution, fps, compression), described by
/// SupportedDeviceParameters/SupportedExtraParameters arrays, are
independent of the format
/// of the stream (are the same for mjpeg, mpeg4, h264).
/// </summary>
DeviceParametersFormatIndependent = 8,
}

Issued 11.07.2019
Eocortex API and SDK 29

If it is required to solve a task of controlling a tilting camera or its inputs/outputs (IO), the
IPtzController and/or IIOController interfaces need to be implemented:

/// <summary>
/// Unified interface of tilting camera control implementation.
/// </summary>
public interface IPtzController
{
#region ----------------- BASE PART ------------------

/// <summary>
/// A camera initialization.
/// </summary>
/// <returns></returns>
void Initialization();

/// <summary>
/// Returns the camera capabilities.
/// </summary>
/// <returns></returns>
PtzCapabilities GetCapabilities();

/// <summary>
/// Returns names of camera presets.
/// The number of elements in resulting array corresponds to the number of
/// presets.
/// Each preset corresponds to a number equal to the array index.
/// </summary>
/// <returns>Names of camera presets.</returns>
string[] GetPresetsNames();

/// <summary>
/// Defines a preset by its index.
/// </summary>
/// <param name="presetIndex"> The preset index.</param>
void SetPresetPosition(int presetIndex);

/// <summary>
/// Moves the camera to the home position.
/// </summary>
void MoveToHome();

/// <summary>
/// Stops any PTZ command executing.
/// </summary>
void Stop();

/// <summary>
/// One step movement.
/// </summary>
/// <param name="panSpeed"> Horisontal speed. Range from -100 to
/// 100.</param>
/// <param name="tiltSpeed">Vertical speed. Range from -100 to
/// 100.</param>
void StepMove(int panSpeed, int tiltSpeed);

Issued 11.07.2019
Eocortex API and SDK 30

/// <summary>
/// Continuous (preferred flowing) motion.
/// </summary>
/// <param name="panSpeed">Horisontal speed. Range from -100 to
/// 100.</param>
/// <param name="tiltSpeed">Vertical speed. Range from -100 to
/// 100.</param>
void ContiniousMove(int panSpeed, int tiltSpeed);

/// <summary>
/// Relative zooming in.
/// </summary>
/// <param name="step">Step from 1 to 100.</param>
void StepZoomIn(int step);

/// <summary>
/// Relative zooming out.
/// </summary>
/// <param name="step">Step from 1 to 100.</param>
void StepZoomOut(int step);

/// <summary>
/// Continuous (preferred flowing) zooming in.
/// </summary>
/// <param name="speed">Speed. Range from 1 to 100.</param>
void ContiniousZoomIn(int speed);

/// Continuous (preferred flowing) zooming out.


/// </summary>
/// <param name="speed">Speed. Range from 1 to 100.</param>
void ContiniousZoomOut(int speed);

/// <summary>
/// Returns the camera max. zooming in.
/// </summary>
/// <returns>The camera max. zooming in. If the function is not
/// supported, a negative number is returned.</returns>
double GetMaxZoomFactor();

/// <summary>
/// Returns the current camera zooming in.
/// </summary>
/// <returns> Current camera zooming in. If the function is not supported,
/// a negative number is returned.</returns>
double GetCurrentZoomFactor();

/// <summary>
/// Sets up absolute zooming in. No operation if camera does not support
/// the function. Ref. PtzCapabilities.
/// </summary>
void SetZoomFactor(double factor);

/// <summary>
/// Sets max. zooming in.
/// </summary>
void ZoomTele();

Issued 11.07.2019
Eocortex API and SDK 31

/// <summary>
/// Sets min. zooming in.
/// </summary>
void ZoomWide();

#endregion

#region ----------------- SUPPLEMENTARY PART ------------------

/// <summary>
/// Turns the camera so that reference point is
/// in the center of the frame area.
/// </summary>
/// <param name="point">Display point (in pixels) that is necessary to be put
/// in the center by turning the camera.
/// Starting point (0,0) is the upper-left corner of frame о</param>
/// <param name="frameSize">The frame size in pixels</param>
void MoveTo(System.Drawing.Point point, System.Drawing.Size frameSize);

/// <summary>
/// turns and zooms the camera so that
/// controlled rectangle takes a full frame area.
/// If rectangle aspect ratio does not correspond to that of the frame,
/// then zooming is executed so that the whole rectangle
///fits within the frame.
/// The rectangle center fits the frame center.
/// </summary>
/// <param name="rect">Rectangle is set in pixels</param>
/// <param name="frameSize">Frame size in pixels</param>
void ShowRect(System.Drawing.Rectangle rect, System.Drawing.Size frameSize);

#endregion
}

/// <summary>
/// Unified interface of camera input/output control implementation
/// </summary>
public interface IIOController
{
/// <summary>
/// Initialization
/// </summary>
/// <returns></returns>
void Initialization();

/// <summary>
/// Returns the camera capabilities.
/// </summary>
/// <returns></returns>
IOCapabilities GetCapabilities();

/// <summary>
/// Sets the defined value in the output
/// </summary>
/// <param name="portID">Output No.</param>
/// <param name="value">1 or 0</param>
void SetOutput(int portID, int value);

Issued 11.07.2019
Eocortex API and SDK 32

/// <summary>
/// Supplies pulse sequence (PWM) in indicated output.
/// It is not supported by all cameras.
/// </summary>
/// <param name="portID">Output No.</param>
/// <param name="pulses"> Pulse array </param>
void SetOutput(int portID, IOPulse[] pulses)
}
Pan-and-tilt (IO controller) capabilities must be returned using GetCapabilities() method to
inform the host about methods of optional capabilities implemented in the interface (if the
device supports them).
DevType_RegInfo registration information of the device must be defined at the stage of
loading the assembly and plugin in the class initialization metod which realizes IPlugin
interface by calling RegisterDevType host interface method (see Plugin registration in
Eocortex, page 6).
Besides DevType_RegInfo, it is also necessary to complete the RTFR_RegInfo frame
feceiver information:

/// <summary>
/// The frame receiver registration information
/// </summary>
public class RTFR_RegInfo
{
/// <summary>
/// Device identifier
/// </summary>
public Guid DeviceTypeGuid;

/// <summary>
/// Data stream format
/// </summary>
public VideoStreamFormats StreamFormat;

/// <summary>
/// Connection protocol used
/// </summary>
public NetworkConnectionTypes ConnectionType;

/// <summary>
/// The device capabilities using the set format StreamFormat
/// </summary>
public RTFR_Capabilities Capabilities;
}
This information must be specified as many times as many different stream formats the IP
device supports.
Simiar to DevType_RegInfo, RTFR_RegInfo information must be defined at the stage of
assembly and plugin loading in IPlugin interface of class initialization method. Call the host
interface RegisterDevType method to complete it. Example of completing the classes is
given below:

public void Initialize(IPluginHost host)


{
DevType_RegInfo KingNet_KS3002MJ_Device = new DevType_RegInfo();
KingNet_KS3002MJ_Device.DeviceTypeGuid =
new Guid("5C49C51D-B17B-40b0-9656-6DC71DD86D90");
KingNet_KS3002MJ_Device.DevTypeModelName = "KS3002MJ";
KingNet_KS3002MJ_Device.DevTypeBrandName = "KingNet";
KingNet_KS3002MJ_Device.AvailableResolutions = GetConcreteResolutions();
KingNet_KS3002MJ_Device.Capabilities = DevType_Capabilities.SupportsCameras;

Issued 11.07.2019
Eocortex API and SDK 33

KingNet_KS3002MJ_Device.GetPtzController = null;
KingNet_KS3002MJ_Device.GetRTFR = (conParam, subParams) =>
{
RealTimeFrameReceiver rtfr = new RealTimeFrameReceiver(conParam, subParams);
return rtfr;
};
KingNet_KS3002MJ_Device.SetDeviceParameters = (conParams, subParams) =>
{
return true;
};

host.RegisterDevType(KingNet_KS3002MJ_Device);

RTFR_RegInfo rtfrKingNet_KS3002MJ_Mjpeg = new RTFR_RegInfo();


rtfrKingNet_KS3002MJ_Mjpeg.DeviceTypeGuid =
new Guid("5C49C51D-B17B-40b0-9656-6DC71DD86D90");
rtfrKingNet_KS3002MJ_Mjpeg.StreamFormat = VideoStreamFormats.MJPEG;
rtfrKingNet_KS3002MJ_Mjpeg.ConnectionType = NetworkConnectionTypes.UDP;
rtfrKingNet_KS3002MJ_Mjpeg.Capabilities.SupportedStreamTypes =
ChannelStreamTypes.MainVideo;
rtfrKingNet_KS3002MJ_Mjpeg.Capabilities.SupportedExtraParameters =
new DeviceParameters[] { DeviceParameters.Null, DeviceParameters.Null };
rtfrKingNet_KS3002MJ_Mjpeg.Capabilities.SupportedDeviceParameters =
new DeviceParameters[] { DeviceParameters.Null, DeviceParameters.Null };

host.RegisterRTFR(rtfrKingNet_KS3002MJ_Mjpeg);
}

Issued 11.07.2019
Eocortex API and SDK 34

4. Eocortex API with HTTP and RTSP interfaces


Eocortex API allows the user to contact the server using either HTTP or RTSP interface
to receive real time and archived video streams. It is also possible to use HTTP interface to obtain
system information and to send commands to the system to perform certain actions. Various
types of requests are described below.

User password (password parameter) is sent as MD5 hash


in upper case.

4.1 HTTP interface for receiving video


4.1.1 Receiving real-time and archive video
The simplest way of receiving data stream from EOCORTEX is HTTP interface. Real-time video
is HTTP received with the following CGI-query:
<eocortex server address and port>/video?channel=<channel name>
&login=<user name>&password=<hash-line MD5 password>[&sound=on]
[&streamtype=alternative]
or
<eocortex server address and port>/video?channelid=<channel id>
&login={user name}&password=<hash-line MD5 password>
[&sound=on][&streamtype=alternative]
If the user has no password, the password parameter can be omitted or left blank. Sound is
an optional parameter, “sound on” allows to receive video and sound together in one
connection by frame sequence. Sound frames are received in G.711U format. An alternative
stream can be called optionally. As a rule, it has less resolution and can be used for
visualization.
As a result, server sends an infinite HTTP response with video and sound frames, divided by
titles. Example of typical server response:

HTTP/1.1 200 OK

Content-Type: multipart/x-mixed-replace; boundary=myboundary

-- myboundary
Content-Type: image/jpeg
Content-Length: 63125

<JPEG frame body>

or

-- myboundary
Content-Type: audio, PCMU
Content-Length: 1000

< G711U frame body>

If the stream format is MJPEG, Content-Type parameter contains «image/jpeg» line. In case
of MPEG4 format, Content-Type parameter has “video, mpeg4, I-frame” for I-frames and
“video, mpeg4, P-frame” for P-frames. Each key I-frame contains initializing information
for MPEG4 decoder. Likewise, if it is H.264 decoder, for I-frames Content-Type field contains
“video, h264, I-frame” and “video, h264, P-frame”. Similarly to MPEG4 format, before
each I-frame there is initializing information for H264 decoder.

Issued 11.07.2019
Eocortex API and SDK 35

Example of a quiery for receiving real-time video:


http://127.0.0.1:8080/video?channel=Channel%201&login=root&password=
It is recommended to send the channel identifier in channelid parameter instead of the channel
name to avoid collision:
http://127.0.0.1:8080/video?channelid=7f54efa4-e7d6-456e-ac1018215f2492d6
&login=root&password=
The channel ordinal number (starting from zero 0) can be used in configuration to specify the
channel:
http://127.0.0.1:8080/video?channelnum=1&login=root&password=
The channel number can be altered if there are changes in configuration (e.g. the channel is
moved and the channel order is changed in security objects), due to this point using the
channel identifier (channelid) is recommended.
It is necessary to execute the following query to receive configuration with the channel
identifiers and identifier settings:
<eocortex server address and port>/configex?login=<user name>
&password=<hash-line MD5 password>
Example of query:
http://127.0.0.1:8080/configex?login=root&password=
Configuration query is described in detail in the following section: Obtaining system
configuration (page 36).
It is necessary to execute the following CGI-query to access the archive by HTTP interface:
<eocortex server address and port>/video?mode=archive
&startTime=dd.mm.yyyy+hh:mm:ss[.fff][&speed=n]&channel=<channel name>
[&channelid=id]&login=<user name>&password=<hash-line MD5 password>[&sound=on]
startTime parameter is a starting position for archive plyback. Its value is a combination of
date and UTC time.
Optional speed parameter defines the speed of archive playback. The range of receivable
values is continuous and varies from 0.1 to 20.
Default value is 1.0.

Example of query:
http://127.0.0.1:8080/video?mode=archive&startTime=20.09.2011+11:49:12
&speed=1&channel=Channel 1&login=root&password=

4.1.2 Receiving transcoded MJPEG video.


Eocortex server returns video in original (obtained from the camera) format if /video
interface is called. For some applications and nonproductive devices H264, video transcoding
or MJPEG-video visualization in original resolution may be a problem. The CGI-handler
/mobile is used in these situations. After the query with analogous parameters /video
(login, password, name/number/channel identifier, sound, archive parameters) Eocortex
server returns video in MJPEG format (including H264 and MPEG-4 streams from the cameras)
in fixed resolution defined in Eocortex Configurator (Servers tab, Mobile devices
connection settings pack).
Settings of transcoding return to MobileServerInfo in xml-configuration obtained upon
/configex request).
Transcoded video receiving can be banned for the group to which the user belongs. In this
case in xml-configuration (by /configex query),
CanGetTranscodedVideoFromMobileServer in Usergroup gets false value.
The lowest resolution is returned by default. Query can be sent to get necessary resolution of
returned picture: define resolutionx parameters for width and resolutiony for height
(positive integer of pixels), for example,
http://127.0.0.1:8080/mobile?channelnum=1&login=root&resolutionx=640&resolutiony=480
In this case, the most appropriate resolution in server mobile connections settings is returned.

Issued 11.07.2019
Eocortex API and SDK 36

Each resolution corresponds to maximum frame rate (defined in settings). Client can send a
query for a lower frame rate by defining fps parameter (positive integer – necessary frame
rate per second). If fps exceeds maximum value or is not defined, video is returned with
maximum rate. For example:
http://127.0.0.1:8080/mobile?channelid=e9d42141-8f7f-4577-bb5e-4dd9f79331ab
&login=root&resolutionx=640&resolutiony=480&fps=10

4.2 HTTP interface for receiving data


Queries to receive data are generally as follows:
<eocortex server address and port>/<command>?login=<user name>
&password=<hash-line MD5 password>&<Parameter 1>&<Parameter 2>...
By default, the data is received in XML format. For some queries, however, there is a
possibility to return data in JSON format. To do that it is required to specify
responsetype=json parameter.
If there is no clear indication of the possibility to return data in JSON in a description below,
it is assumed that it is to be returned in XML only.

4.2.1 Obtaining system configuration


XML: http://127.0.0.1:8080/configex?login=root&password=
JSON: http://127.0.0.1:8080/configex?responsetype=json&login=root&password=
Parameters:
login – user name.
password – MD5-hash of password.
Response to XML format query:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration xmlns="http://www.Eocortex.com"
ServerVersion="2.0.15"
XMLProtocolVersion="2"
Timestamp="2015-05-20T12:19:21.8562773Z" Revision="71"
SenderId="23424773-aa6e-4088-a0d3-97d50fe76c5f"
Id="36b21916-1186-4ba0-8ad6-138f963140a6"
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Servers>
<ServerInfo Id="23424773-aa6e-4088-a0d3-97d50fe76c5f"
Url="192.168.100.61:8080"
Name="Server 1" />
</Servers>
<Channels>
<ChannelInfo Id="9bacefb4-4605-4813-940d-41c056248f8d"
Name="Channel 1"
ArchiveStreamType="Main"
ArchiveMode="MDandManual"
IsTransmitSoundOn="false"
IsPtzOn="false"
AllowedArchive="true"
AllowedRealtime="true"
IsSoundArchivingEnabled="false"
IsArchivingEnabled="true"
IsSoundOn="false"
IsDisabled="false"
AttachedToServer="23424773-aa6e-4088-a0d3-97d50fe76c5f"
DeviceInfo="LTV ICD(M,V)(x)-xxx"
Description="">

Issued 11.07.2019
Eocortex API and SDK 37

<Streams>
<StreamInfo RotationMode="None"
StreamFormat="H264"
StreamType="Main"/>
<StreamInfo RotationMode="None"
StreamFormat="MJPEG"
StreamType="Alternative"/>
</Streams>
</ChannelInfo>
</Channels>
<RootSecurityObject Id="9c7d175a-9c84-455e-b104-57cc12cb9d47">
<ChildSecurityObjects>
<SecObjectInfo Id="583f67a8-d173-4b59-8c49-5e774c99bcf9"
Name="Object 1">
<ChildSecurityObjects/>
<ChildChannels>
<ChannelId>9bacefb4-4605-4813-940d-41c056248f8d</ChannelId>
</ChildChannels>
</SecObjectInfo>
</ChildSecurityObjects>
<ChildChannels/>
</RootSecurityObject>
<UserGroup>
<Id>464daa9e-755d-4491-a616-5fbda4423ac8</Id>
<Name>Administrators</Name>
<CanConfigure>true</CanConfigure>
<CanConfigureWorkplace>false</CanConfigureWorkplace>
<CanShutdown>true</CanShutdown>
<CanChangeChannelMode>true</CanChangeChannelMode>
<CanManageRec>true</CanManageRec>
<CanAccessExpertMode>true</CanAccessExpertMode>
<CanPTZ>true</CanPTZ>
<CanReceiveSound>true</CanReceiveSound>
<CanTransmitSound>true</CanTransmitSound>
<CanAccessNewCamera>true</CanAccessNewCamera>
<CanGetTranscodedVideoFromMobileServer>
true
</CanGetTranscodedVideoFromMobileServer>
<CanAccessEditingAnalystPluginsInClient>
true
</CanAccessEditingAnalystPluginsInClient>
<CanAccessVideoViaWeb>true</CanAccessVideoViaWeb>
<CanAccessVideoViaSmartTV>true</CanAccessVideoViaSmartTV>
<CanExportVideoToAvi>true</CanExportVideoToAvi>
<CanReceiveMainStream>true</CanReceiveMainStream>
<AllowedArchiveDepth/>
<IsAllForbidden>false</IsAllForbidden>
<CanAccessUnifiedLog>true</CanAccessUnifiedLog>
<CanAccessToAllUsersInUnifiedLog>true</CanAccessToAllUsersInUnifiedLog>
<CanReceiveMobilePush>true</CanReceiveMobilePush>
</UserGroup>

Issued 11.07.2019
Eocortex API and SDK 38

<MobileServerInfo HighResolution="800 x 480"


MiddleResolution="240 x 180"
LowResolution="120 x 90"
FpsLimit="0"
UsePFrames="false"
Port="8089"
IsMobilePushEnabled="false"
IsProxyEnabled="true"
IsEnabled="true">
<Resolutions>
<ResolutionInfo FpsLimit="15"
UsePFrames="true"
IsEnabled="true"
Type="High"
Height="480"
Width="800"/>
<ResolutionInfo FpsLimit="4"
UsePFrames="false"
IsEnabled="true"
Type="Middle"
Height="180"
Width="240"/>
<ResolutionInfo FpsLimit="4"
UsePFrames="false"
IsEnabled="false"
Type="Low"
Height="90"
Width="120"/>
</Resolutions>
</MobileServerInfo>
<RtspServerInfo IsEnabled="true"
IsMjpegEnabled="false"
TcpPort="554"/>
</Configuration>
Response to a query in JSON format:
{
"Id": "36b21916-1186-4ba0-8ad6-138f963140a6",
"SenderId": "23424773-aa6e-4088-a0d3-97d50fe76c5f",
"RevNum": 70,
"Timestamp": "2015-05-20T12:13:37.6889429Z",
"XmlProtocolVersion": 2,
"ServerVersion": "2.0.15",
"Servers": [
{
"Id": "23424773-aa6e-4088-a0d3-97d50fe76c5f",
"Name": "Server 1",
"Url": "192.168.100.61:8080",
"ConnectionUrl": null
}
],
"Channels": [
{
"Id": "9bacefb4-4605-4813-940d-41c056248f8d",
"Name": "Channel 1",
"Description": "",
"DeviceInfo": "LTV ICD(M,V)(x)-xxx",
"AttachedToServer": "23424773-aa6e-4088-a0d3-97d50fe76c5f",
"IsDisabled": false,
"IsSoundOn": false,
"IsArchivingEnabled": true,

Issued 11.07.2019
Eocortex API and SDK 39

"IsSoundArchivingEnabled": false,
"AllowedRealtime": true,
"AllowedArchive": true,
"IsPtzOn": false,
"IsTransmitSoundOn": false,
"ArchiveMode": "MDandManual",
"Streams": [
{
"StreamType": 0,
"StreamFormat": 3,
"RotationMode": 0
},
{
"StreamType": 1,
"StreamFormat": 1,
"RotationMode": 0
}
],
"ArchiveStreamType": "Main"
}
],
"RootSecObject": {
"ChildSecObjects": [
{
"ChildSecObjects": [],
"ChildChannels": [
"9bacefb4-4605-4813-940d-41c056248f8d"
],
"Id": "583f67a8-d173-4b59-8c49-5e774c99bcf9",
"Name": "Object 1"
}
],
"ChildChannels": [],
"Id": "9c7d175a-9c84-455e-b104-57cc12cb9d47",
"Name": null
},
"UserGroup": {
"Id": "464daa9e-755d-4491-a616-5fbda4423ac8",
"Name": "Administrators",
"CanConfigure": true,
"CanConfigureWorkplace": false,
"CanShutdown": true,
"CanChangeChannelMode": true,
"CanManageRec": true,
"CanAccessExpertMode": true,
"CanPTZ": true,
"CanReceiveSound": true,
"CanTransmitSound": true,
"CanAccessNewCamera": true,
"CanGetTranscodedVideoFromMobileServer": true,
"CanAccessEditingAnalystPluginsInClient": true,
"CanAccessVideoViaWeb": true,
"CanAccessVideoViaSmartTV": true,
"CanExportVideoToAvi": true,
"CanReceiveMainStream": true,
"AllowedArchiveDepth": "416.16:00:00",
"IsAllForbidden": false,
"CanAccessUnifiedLog": true,

Issued 11.07.2019
Eocortex API and SDK 40

"CanAccessToAllUsersInUnifiedLog": true,
"CanReceiveMobilePush": true
},
"MobileServerInfo": {
"IsEnabled": true,
"IsProxyEnabled": true,
"IsMobilePushEnabled": false,
"Port": 8089,
"UsePFrames": false,
"FpsLimit": 0,
"LowResolution": "120 x 90",
"MiddleResolution": "240 x 180",
"HighResolution": "800 x 480",
"Resolutions": [
{
"Width": 800,
"Height": 480,
"IsEnabled": true,
"FpsLimit": 15,
"UsePFrames": true,
"Type": 2
},
{
"Width": 240,
"Height": 180,
"IsEnabled": true,
"FpsLimit": 4,
"UsePFrames": false,
"Type": 1
},
{
"Width": 120,
"Height": 90,
"IsEnabled": false,
"FpsLimit": 4,
"UsePFrames": false,
"Type": 0
}
]
},
"RtspServerInfo": {
"IsEnabled": true,
"TcpPort": 554,
"IsMjpegEnabled": false
}
}
Configuration element in the response contains the following:
• A version of XMLProtocolVersion protocol. The current protocol number is 2, it is
supposed to be changed when new elements and attributes in xml-response appear.
• Time stamp of the last Timestamp configuration application.
• Unique identifier Id of current configuration and its revision number Revision. After
each configuration change revision number increases by one.
• Identifier of SenderId server that sent the xml-response.

Issued 11.07.2019
Eocortex API and SDK 41

Servers element contains description of servers in current configuration. ServerInfo


element describes each server that contains the following attributes:
• Server unique identifier Id.
• Name of identifier in current configuration
• Server Url
Channels element contains description of channel settings of the current configuration.
ChannelInfo element describes each channel settings that contain the following attributes
and elements:
• Channel unique identifier Id used in video queries in channelid parameter.
• AttachedToServer server identifier to which the channel is attached.
• DeviceInfo information about the device selected
• IsArchivingEnabled parameter denotes if video data archiving is enabled on the
channel.
• IsSoundArchivingEnabled parameter denotes if sound data archiving is enabled.
• ArchiveMode parameter denotes the archive record mode on the channel (if enabled).
Possible values: AlwaysOn – record is always enabled, OnlyManual – record is
controlled manually, BySchedule – record is enabled by schedule, MDandManual –
record is enabled automatically by the motion detector and manually.
• IsSoundOn parameter denotes if sound is enabled on the channel. If the parameter is
false, IsSoundArchivingEnabled parameter can be ignored.
• AllowedRealtime parameter denotes if the current user is allowed to watch video in
real time on the channel.
• AllowedArchive parameter denotes if the user is allowed to watch video from archive
on the channel.
• IsDisabled parameter denotes if the channel is disabled in current configuration.
• Name parameter contains the channel name in configuration.
Streams element contains video Main Stream and Alternative Stream settings.
StreamInfo description contains one of three possible stream formats
H.264/MPEG4/MJPEG in StreamFormat field and stream type, main or alternative.
If Alternative Stream is disabled on the channel, its description is not included.
RootSecurityObject element contains information about safety object tree structure and
affiliation of channels to them.
UserGroup element contains information about group rights that the user requesting the
configuration belongs to.
MobileServerInfo contains information about parameters of video conversion by mobile
server.

4.2.2 Aquiring profiles (preinstalled grids)


Query examples:
XML: http://127.0.0.1:8080/command?type=getprofiles&login=root&password=
JSON:
http://127.0.0.1:8080/command?type=getprofiles&login=root&password=&responsetype=json
Response example in JSON fromat:
[
{
"Id": "13851f3d-c7d3-4ec6-b0ff-2d66873bf118",
"Name": "New profile 1"
}
]

Issued 11.07.2019
Eocortex API and SDK 42

4.2.3 Aquiring a list of available grids in Eocortex client


XML:
http://127.0.0.1:8080/command?type=getgrids&clientip=127.0.0.1&monitor=0&login=root
&password=
JSON:
http://127.0.0.1:8080/command?type=getgrids&clientip=127.0.0.1&monitor=0&login=root
&password=&responsetype=json
The response to a query results in a list of available grids on the particular client. Example:
[
"1",
"4",
"6_1",
"7",
"8_1",
"9",
"10",
"13",
"16",
"25"
]
The first digit (before “_” symbol) is a number of cells in a grid, the second (after “_”) a
number of a configuration. The configuration number is only for grids with equal cell quantity
but differing by cell size and location.

4.2.4 Acquiring information on current grid in Eocortex client


XML: http://127.0.0.1:8080/command?type=getcurrentgrid&login=root&clientip=127.0.0.1
&monitor=0
JSON: http://127.0.0.1:8080/command?type=getcurrentgrid&login=root
&clientip=127.0.0.1&monitor=0&responsetype=json
Parameters:
clientip — IP address or URI of a client.
monitor — number of monitor on a client (begins with zero (0)).
The query returns type of current grid and its contents. Example:
{
"GridType": "4",
"Cells":
[
{
"Index": 0,
"IsEmpty": false,
"ChannelId": "483cd419-c03c-47b1-a3bb-ef5bce82d588",
"Viewer": "Realtime"
},
{
"Index": 1,
"IsEmpty": false,
"ChannelId": "fe5e37d5-6da8-403c-ace8-10c4ba4c4b64",
"Viewer": "Realtime"
},
{
"Index": 2,
"IsEmpty": false,
"ChannelId": "edc2f629-4565-49a1-8c70-663e16ab0104",
"Viewer": "Realtime"
},

Issued 11.07.2019
Eocortex API and SDK 43

{
"Index": 3,
"IsEmpty": false,
"ChannelId": "1b6204af-f3ae-49ab-935f-878cbb3a9139",
"Viewer": "Realtime"
}
]
}
Where:
index — cell’s ordinal number (starting from zero);
isempty — is the cell empty;
channeled – channel identifier;
viewer — type of cell contents, adopts the following values:
• none — cell is empty;
• realtime — real time;
• archive — archive;
• other — other; at the present moment, it may only be a plan of the premises.
The type of grid coincides with the one described in Aquiring a list of available grids in Eocortex
client (page 42).

4.2.5 Acquiring time of computer on which Eocortex server is running


XML: http://127.0.0.1:8080/command?type=gettime&login=root&password=
JSON:
http://127.0.0.1:8080/command?type=gettime&login=root&password=&responsetype=json
The query returns UTC time. Example:
"22.09.2014 3:33:06"

4.2.6 Acquiring information regarding the availability of archive in a


given moment
XML: http://127.0.0.1:8080/command?type=findarchive&login=root&password=
&channelid=d96e8b67-3f13-44fd-b628-356d1f88a50c&searchTime=23.09.2014+06:10:00
JSON: http://127.0.0.1:8080/command?type=findarchive&login=root&password=
&channelid=d96e8b67-3f13-44fd-b628-356d1f88a50c&searchTime=23.09.2014+06:10:00
&responsetype=json
Time in searchTime parameter must be transmitted as UTC.
The query returns the flag of the availability of archive during the time defined and time stamp
of the nearest video frame. Example:
{
"HasArchive": false,
"NearestFrameTimestamp": null
}

4.2.7 Getting information on channel status


XML: http://127.0.0.1:8080/command?type=getchannelsstates&login=root&password=
JSON: http://127.0.0.1:8080/command?type=getchannelsstates&login=root&password=
&responsetype=json

Issued 11.07.2019
Eocortex API and SDK 44

Example of a response in JSON format:


[
{
"Id": "596ea82f-cf03-4e1f-9658-5aafbb1cb143",
"IsRecordingOn": false,
"StreamsStates":
[
{
"Type": "MainVideo",
"State": "Active"
},
{
"Type": "AlternativeVideo",
"State": "Stopped"
},
{
"Type": "MainSound",
"State": "Active"
},
{
"Type": "AlternativeSound",
"State": "Stopped"
},
{
"Type": "OutputSound",
"State": "Stopped"
},
{
"Type": "MotionDetection",
"State": "Stopped"
},
{
"Type": "IO",
"State": "Stopped"
},
{
"Type": "ArchiveVideo",
"State": "Stopped"
},
{
"Type": "ArchiveSound",
"State": "Stopped"
}
]
}
]
Where:
Id — channel identifier;
IsRecordingOn — if recording is on on a channel;
StreamStates — data stream acquisition condition. Every stream has its Type and State.

Issued 11.07.2019
Eocortex API and SDK 45

Type adopts the following values:


• MainVideo — video, main stream, high resolution;
• AlternativeVideo — video, alternative stream, medium resolution;
• MainSound — sound acquisition, main stream;
• AlternativeSound — sound acquisition, alternative stream;
• OutputSound — sound transmission;
• MotionDetection — built-in motion detector;
• IO — digital inputs/outputs;
• ArchiveVideo — archive video;
• ArchiveSound — archive sound.
State adopts the following values:
• Stopped — stream stopped because it is not required by the system;
• Active — stream is in a state of acquisition of frames and events;
• NoConnection — connection with device has been lost in stream.

4.2.8 Acquiring PTZ capabilities of a device


XML: http://127.0.0.1:8080/ptz?command=getcapabilities
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
JSON: http://127.0.0.1:8080/ptz?command=getcapabilities
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
&responsetype=json
Example of response in JSON format:
{
"PtzCapabilities":
{
"HomePositionSupports": true,
"MoveToSupports": false,
"AreaZoomSupports": false,
"ZoomSupports": true,
"ContiniousZoomSupports": true,
"AutoFocusSupports": true,
"ManualFocusSupports": true,
"ContiniousFocusSupports": true,
"SupportedStepMoveDirections": 0,
"SupportedContiniousMoveDirections": 255
},
"Resolution":
{
"Width": 1920,
"Height": 1080
}
}
Where:
HomePositionSupports — whether home position is supported;
MoveToSupports — whether centering is supported (camera turns to a predefined point);
AreaZoomSupports — whether selected area zooming is supported;
ZoomSupports — whether step zoom is supported (single zoom change by single
command);
ContiniousZoomSupports — whether continuous zoom is supported (zooming continues
after the corresponding command is given and until a stop command is received);
AutoFocusSupports — whether automatic focus feature is supported;
ManualFocusSupports — whether manual focus is supported;
ContiniousFocusSupports — whether continuous focus is supported;

Issued 11.07.2019
Eocortex API and SDK 46

SupportedStepMoveDirections — a mask describing available directions for stepping


movement;
SupportedContiniousMoveDirections — a mask describing available directions for
continuous movement;
Resolution — current main stream frame resolution (required for moveto and areazoom
commands, see below).

4.2.9 Receiving presets from PTZ device


XML: http://127.0.0.1:8080/ptz?command=getpresets
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
JSON: http://127.0.0.1:8080/ptz?command=getpresets
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
&responsetype=json
Example of response in JSON format:
[
"Preset 1",
"Preset 2",
"Preset 3",
"Preset 4",
"Preset 8"
]

4.2.10 Receiving archive of identified car number plates


The data from the archive of recognized car number plates always returns in JSON format.
Example of query:
http://127.0.0.1:8080/autovprs_export?login=root&password=
&channelid=2ae58228-bb85-490b-8053-a3bde125462c
&startTime=2015-05-20-15-36-00-000&finishTime=2015-05-20-15-45-59-999
startTime and finishTime parameters serve to define the time of start and finish of the interval
during which it is required to obtain the archive of recognized car number plates.
These parameters must be indicated in the local time of the server to which the request is
being sent.
Example of response in JSON format:
[
{
"TimeUtc" : "21.05.2015 05:53:17.537",
"Numberplate" : "С896АХ59",
"LastName" : "",
"FirstName" : "",
"PatronymicName" : "",
"Group" : ""
} ,
{
"TimeUtc" : "21.05.2015 05:53:34.467",
"Numberplate" : "Х497КО59",
"LastName" : "",
"FirstName" : "",
"PatronymicName" : "",
"Group" : ""
}
]
Where:
Timestamp — UTC-time, when the number is identified (it is necessary to take into account
time zone to convert UTC to local time; detailed information about UTC and local time
difference see in Wikipedia
Numberplate — identified car number plate.

Issued 11.07.2019
Eocortex API and SDK 47

4.2.11 Receiving the list of all events registered in the system


Implemented in Eocortex version 2.1 and later.
http://127.0.0.1:8080/command?type=getallregisteredevents&login=root
Parameters:
login – user name;
password – MD5 hash of the password.
XML format responce:
Timestamp: 27.07.2015 8:32:45
Error code: 0
Message: Success
Body-length: 3148
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfEventInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EventInfo>
<Id>00000000-0000-0000-0000-000000000033</Id>
<GuiName>Motion</GuiName>
</EventInfo>
</ArrayOfEventInfo>

4.2.12 Receiving the list of special archive events


Implemented in Eocortex version 2.1 and later.
Event quantity limit is 1000. To receive consecutive events, it is necessary to start the search
from the time of the last received event.
http://127.0.0.1:8080/specialarchiveevents?login=root&password=
&startTime=27.07.2015+07:39:05&endTime=27.07.2015+09:39:05
&eventid=9f5d8d14-e55d-4585-bb7f-c8c4bca1eeff
Parameters:
login — user name;
password — MD5 hash of the password;
starttime — archive start time (dd:mm:yyyy+HH:MM:SS);
endtime — archive end time (dd:mm:yyyy+HH:MM:SS);
channelid — Guid of the channel for filtering (optional);
filter — Guid of the event for filtering (optional).
Response in JSON format:
{
"EventId" : "00000000-0000-0000-0000-000000000033",
"Timestamp" : "27.07.2015 7:37:01",
"EventDescription" : "Motion",
"IsAlarmEvent" : "False",
"ChannelId" : "ed93a7d5-4e90-4ab0-bcb7-d0a4dad4782e",
"ChannelName" : "Channel 3",
"Zoneid" : "5d295125-cac6-448b-8cc9-efee4fe21cc1"
}
{
"EventId" : "00000000-0000-0000-0000-000000000033",
"Timestamp" : "27.07.2015 7:37:03",
"EventDescription" : "Motion",
"IsAlarmEvent" : "False",
"ChannelId" : "ed93a7d5-4e90-4ab0-bcb7-d0a4dad4782e",
"ChannelName" : "Channel 3",
"Zoneid" : "5d295125-cac6-448b-8cc9-efee4fe21cc1"
}

Issued 11.07.2019
Eocortex API and SDK 48

4.3 HTTP interface for receiving events in real time


The events can be received in JSON format in the “infinite” HTTP connection. To do that, it is
required to make the following query:
http://127.0.0.1:8080/event?login=root&password=&responsetype=json
Where:
login — user name;
password — MD5 hash of the password;
responsetype — response will be sent in JSON;
channelid — GUID of the channel for filtering (optional);
filter — GUID of the event for filtering (optional).
If it is required to receive events for only one channel and/or of only one known type, a
corresponding parameter is added to the query string
(filter with event identifier and/or channelid with channel identifier):
http://127.0.0.1:8080/event?login=root&password=
&filter=00000000-0000-0000-0000-000000000033&responsetype=json
For debugging, mode=demo parameter may be added, which will order the system to
generate virtual events of the type defined by the event identifier in filter parameter.
http://127.0.0.1:8080/event?login=root
&filter=00000000-0000-0000-0000-000000000033&responsetype=json&mode=demo
Response example in JSON format:
{
"EventId" : "00000000-0000-0000-0000-000000000033",
"Timestamp" : "27.07.2015 7:37:01",
"EventDescription" : "Motion",
"IsAlarmEvent" : "False",
"ChannelId" : "ed93a7d5-4e90-4ab0-bcb7-d0a4dad4782e",
"ChannelName" : "Channel 3",
"Zoneid" : "5d295125-cac6-448b-8cc9-efee4fe21cc1"
}
{
"EventId" : "00000000-0000-0000-0000-000000000033",
"Timestamp" : "27.07.2015 7:37:03",
"EventDescription" : "Motion",
"IsAlarmEvent" : "False",
"ChannelId" : "ed93a7d5-4e90-4ab0-bcb7-d0a4dad4782e",
"ChannelName" : "Channel 3",
"Zoneid" : "5d295125-cac6-448b-8cc9-efee4fe21cc1"
}
Event identifiers:
• 00000000-0000-0000-0000-000000000033 — motion detection;
• 8ee14b08-fc12-4b0f-a11b-3c859d4f4848 — establishing communication with the
device;
• e37ac864-824f-4848-bc25-7dc87fb145c7 — short time disruption of the
communication with the device;
• ec94ad4b-6df0-4cd7-b2f7-9b4eff7e6413 — long-term lack of connection with the
device;
• 0261ebee-fe03-4a13-8327-1b62d3b6f9e5 — change of signal at the alarm input of
the device;
• d117a331-7aca-4202-ac47-02d33402f7b6 — face detection;
• e019878b-b965-4e21-950b-45ed99f7369e — face detection or recognition by the
external recognition module;
• c9d6d086-c965-4cf8-aef6-85b3894e3a4a — detection or recognition of a car plate
number by the external recognition module;
• 8b5110f3-57d9-48f5-b3a2-ec698c9cff8d — user alarm.

Issued 11.07.2019
Eocortex API and SDK 49

4.4 HTTP interface for sending commands to Eocortex server


CGI queries described below are used to send commands to Eocortex server.

4.4.1 Switching recording on a channel on/off


To switch on the recording with obligatory stating of the recording time in minutes, it is
required to make the following query:
http://127.0.0.1:8080/command?type=recording&mode=start
&channelid=34512d50-c87e-4c75-a5a5-9b3a5aaa7d13&Interval=20&login=root&password=
Where:
channelid — GUID of the channel;
interval — recording time in minutes;
mode — adopts start and stop values.
To switch off the recording, it is required to make the following query:
http://127.0.0.1:8080/command?type=recording&mode=stop&channelid=34512d50-c87e-4c75-
a5a5-9b3a5aaa7d13&login=root&password=

4.4.2 Synchronization with another computer in the network


The query shown below will set the time in Eocortex server according to the time defined in time
parameter.
http://127.0.0.1:8080/command?type=settime&time=”02.02.2014+08:11:00”&login=root
&password=

4.4.3 Receiving profiles (preinstalled grids)


http://127.0.0.1:8080/command?type=getprofiles&login=root&password=&responsetype=json
Response example in JSON format:
[
{
"Id": "13851f3d-c7d3-4ec6-b0ff-2d66873bf118",
"Name": "New profile 1"
}
]

4.4.4 Installation of a profile in a client


http://127.0.0.1:8080/command?type=setprofile&clientip=127.0.0.1&monitor=0
&profileid=13851f3d-c7d3-4ec6-b0ff-2d66873bf118&login=root&password=
Where:
clientip — IP address of a computer with Eocortex client installed;
monitor — number of monitor (starting from zero);
pofileid — identifier of a profile which can be obtained from the response to the query for
reception of profiles.

4.4.5 Change of grid on channel


http://127.0.0.1:8080/command?type=setgrid&clientip=127.0.0.1&monitor=0&Cells=25
&login=root&password=
Installs the required grid transmitted in cells parameter. The grid must have a permission to
be used on the indicated client.

4.4.6 Clearing the grid


http://127.0.0.1:8080/command?type=cleargrid&clientip=127.0.0.1&Monitor=0&login=root
&password=
Closes all channels open in the cells of the current grid.

Issued 11.07.2019
Eocortex API and SDK 50

4.4.7 Installation of a channel in a cell of a grid


http://127.0.0.1:8080/command?type=setcell&clientip=127.0.0.1&monitor=0
&mode=archive&cell=0&channelid=34512d50-c87e-4c75-a5a5-9b3a5aaa7d13
&login=root&password=
Where:
mode – adopts realtime values (for real time viewing) or archive
(for accessing the archive);
cell – number of a cell where a channel is to be placed (starting from zero (0)).
Depending on the parameter, mode opens either a real time or an archive channel in the
indicated cell. It is optionally possible to indicate startTime time, which will be the time of
starting the playback of the archive, and the playback speed using the speed parameter (the
speeds available for playback: 0,1; 0,2; 0,5; 1; 2; 5; 10; 20; 60; 120).

4.4.8 Deleting a channel from the grid’s cell


http://127.0.0.1:8080/command?type=clearcell&clientip=127.0.0.1&Monitor=0&cell=0
&login=root&password=
where cell is a number of the cell in grid.

4.4.9 PTZ command for continuous motion


http://127.0.0.1:8080/ptz?command=startmove&panspeed=2&tiltspeed=2
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where:
panspeed — horizontal speed from -100 to 100;
tiltspeed — vertical speed from -100 to 100.

4.4.10 PTZ command for continuous changing of focus


http://127.0.0.1:8080/ptz?command=startchangefocus&speed=1
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where speed is a speed of focusing from -100 to 100.

4.4.11 PTZ command for continuous zoom


http://127.0.0.1:8080/ptz?command=startzoom&speed=1
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where speed is the speed between -100 and 100.

4.4.12 PTZ stop command for permanent commands


http://127.0.0.1:8080/ptz?command=stop
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=

4.4.13 PTZ command for setting a preset


http://127.0.0.1:8080/ptz?command=gotopreset&index=1
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where index is the ordinal number of a preset, counting from zero.

4.4.14 PTZ command for automatic focusing


http://127.0.0.1:8080/ptz?command=setautofocus
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=

Issued 11.07.2019
Eocortex API and SDK 51

4.4.15 PTZ command for centering


http://127.0.0.1:8080/ptz?command=moveto&x=10&y=50&width=640&height=480
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where x and y are coordinates on a frame with width and height size.

4.4.16 PTZ command for step-by-step motion


http://127.0.0.1:8080/ptz?command=move&tiltstep=1&panstep=1
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where:
tiltstep is a vertical step from -100 to 100;
panstep is a horizontal step from -100 to 100.

4.4.17 PTZ command for step zoom


http://127.0.0.1:8080/ptz?command=zoom&zoomstep=10
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where zoomstep is a step from -100 to 100.

4.4.18 PTZ command for zooming in the selected area (AreaZoom)


http://127.0.0.1:8080/ptz?command=showrect&x=10&y=50&width=640&height=480
&frameWidth=1920&frameHeight=1080
&channelid=20d9884f-ae8c-45d3-ac5a-505ec258f01b&login=root&password=
where x, y, width, height set a rectangular area in the frame, which will be zoomed;
frameWidth is the width of the frame;
frameHeight is the height of the frame.

4.4.19 Arming a channel


Implemented in Eocortex version 2.1 and later.
http://127.0.0.1:8080/command?type=setguardian&clientip=127.0.0.1&monitor=0&mode=real
time&login=root&password=&channelid=f67b3044-2fe2-451f-885a-
7d570f8d2e01&isguardianmodeenabled=false
Parameters:
clientip is the IP address of a client’s computer for which the command is being executed;
monitor — client computer monitor number;
isguardianmodenabled — true – arming / false – disarming.

4.4.20 Sending sound to camera


Implemented in Eocortex version 2.1 and later.
A POST request is used to send sound to a camera. In the header of the request the
parameters of the request are stated, and in the body - the audiodata.
Header:
http://127.0.0.1:8080/sendsound?login=root&password=&channelid=66abc0c4-d4b7-
4d71-8ed1-e7beadf0dc46&clientid=66abc0c4-d4b7-4d71-8ed1-e7beadf0dc46
Parameters:
clientid — GUID of the transmission session.
For the body of a request ContentType = "multipart/form-data;"
Description:
The request is intended to be used in third-party applications called clients.

Issued 11.07.2019
Eocortex API and SDK 52

Whithin one request, one portion of audiodata is sent, meaning the request is not a permanent
connection, and the server sends a portion of sound to the camera only after completing the
reception of the corresponding query from the client.
To generate a portion of audiodata (sound coding) one should use third-party data libraries
(for example, NAudio: https://github.com/naudio/NAudio, coding parameters: Samplesrate
= 8000; Bitspersample = 16; Number of channels = 1).
Transmission session is a series of queries sent from a certain client computer to a certain
camera. A unique clientID must be used for each transmission session. In order to decrease
server issues, it is recommended to use the same clientID for a series of queries within the
same session. The clientid is created by the client independently.

4.4.21 Generation of an event from an external system


Implemented in Eocortex version 2.1 and later.
The query generates a system event called “Event from the external system”. For example:
http://127.0.0.1:8080/command?type=generateexternalevent&login=root&password=
&channelid=af820905-3641-4448-a73a-eb5e91da73db
&systemname=TestSystem&information=record
Parameters:
systemname — name of external system;
information — line containing event info;
eventcode — event code (optional).
The query must obligatorily contain either the name of a system (systemname) or the event
name (information).
The event log of Eocortex client application for this event will look as below:

Issued 11.07.2019
Eocortex API and SDK 53

Also, for these events it is possible to assign actions in scenarios, using Eocortex Configurator
application:

4.5 RTSP interface for obtaining video and sound


RTSP interface is used for obtaining video and audio by the clients who use RTSP protocol.
This interface supports H.264 code and, optionally, MJPEG (MJPEG is turned off by default).
Before starting to use it, it is advisable to make sure that RTSP interface is on.
To switch it on, it is required to launch Eocortex Configurator, and make sure that the
checkbox Accept RTSP connections (to broadcast H.264) on the page of server settings
in Network server settings section is checked. The same tab also shows the RTSP port for
making connections.

Issued 11.07.2019
Eocortex API and SDK 54

To make a RTSP connection it is possible to use TCP (RTSP over TCP) or HTTP (RTSP over
HTTP) connections. UDP connections (RTSP over UDP)
are not supported.
By default, MJPEG broadcasting via RTSP protocol is off, because this protocol
supports only MJPEG frames coded in Baseline mode. Thus, recoding is required for
broadcasting video streams coded in other MJPEG modes, which in its turn will
increase server load. Additionally, MJPEG recoding may cause lower fps as
compared with the fps broadcast directly by the camera.
Connection to the server is made by an RTSP client, for example, VLC, with the following
connection string:
rtsp://<ip address of Eocortex server and rtsp port>/rtsp?channelid=<channel id>
&login=<user name>&password=<MD5 hash of password>[&sound=on]
[&streamtype=alternative]
channelid mandatory parameter assigns channel identifier for obtaining video. Also, for
channel assignment a channel ordinal number in the configuration (starting from zero) can
be used – to do so, channelnum parameter must be used instead of channelid (see
Obtaining real time and archive video, page Ошибка! Закладка не определена.).
login mandatory parameter assigns user name. The user must have rights for the requested
channel.
password parameter is obligatory if there is a password assigned for the user. If the user
has no password (blank password), then password parameter is optional and may be
ommited or left blank.
sound optional parameter with on value allows to get audio together with video. Audio frames
always come in G.711U format.
streamtype optional parameter with alternative value allows to request alternative (2nd)
video stream which normally has lower resolution.
Example of query:
rtsp://127.0.0.1:554/rtsp?channelid=D3039B22-3350-47C6-85FE-40F29B1C7FBD&login=root
To get access to the archive, it is required to set the parameters similar to those used for
HTTP connection (see Obtaining real time and archive video, page Ошибка! Закладка не
определена.).
rtsp://<ip address of Eocortex server and rtsp port>/rtsp?channelid=<channel id>
&login=<user name>&password=<hash-line MD5 password>&mode=archive
&starttime= <dd.mm.yyyy+ hh:mm:ss[.fff]>[&sound=on][&speed=<n>][&isforward=false]
channelid, login, password and sound parameters are similar to the parameters of a
request to obtain real time video via RTSP protocol.

mode mandatory parameter with archive value indicates the access to the archive.
starttime mandatory parameter indicates the time of recording when the archive playback
starts. This value is set as a combination of the date and UTC time.
speed optional parameter sets the speed of archive playback. The range of values accepted
is continuous and varies from 0.1 to 20. Default value is 1.0.
isforward optional parameter with false value indicates that the archive should be played
backwards.
Example of query:
rtsp://127.0.0.1:554/rtsp?channelid=D3039B22-3350-47C6-85FE-40F29B1C7FBD
&login=root&mode=archive&starttime=21.04.2015+ 12:05:01.125&sound=on&speed=1

Issued 11.07.2019
Eocortex API and SDK 55

5. Eocortex API with XML interface


XML interface allows to send requests to Eocortex server in XML format and receive
responses in the same format. The structure of the request should be as follows:
<?xml version="1.0" encoding="utf-8" ?>
<query>
<server_login>root</server_login>
<server_pass_hash></server_pass_hash>
<query_name>get_people_counters</query_name>
<query_params>

</query_params>
</query>
Parameter descriptions are provided below.
Parameter Description
server_login User name under which a command will be executed
server_pass_hash MD5 hash of user password
query_name Query type string name
query_params Inside of this tag there will be parameters specific for the type of
query indicated in query_name parameter
The server returns a response of the following type:
<?xml version="1.0" encoding="utf-8" ?>
<result>
<query_name></query_name>
<query_result>Ok</query_result>
<query_msg>Query successful.</query_msg>
<query_time>20.09.2012 10:58:15</query_time>
<query_time_local>20.09.2012 16:58:15</query_time_local>
</result>
Parameter descriptions are provided below.
Parameter Description
query_name Query type string name
query_result Ok — if query seccessful
Error — in case of any errors
query_msg String comment subsequent to query execution results
query_time UTC time of query
query_time_local Local time of query
In the response there may also be tags specific for the certain type of query.

5.1 People Counter data reception


To obtain people counter data, use get_people_counters query.
This query has the following parameters:
<channel_id>cacdd8e6-1c56-435c-86e3-6967d7494a50</channel_id>
<search_time>2012-09-17 09:50:00</search_time>
Parameter Description
channel_id Identifier of the channel on which People Counter is set up
search_time The moment of time for which it is required to show counter data. The
time is shown in yyyy-MM-dd HH:mm:ss format. GMT (UTC) time
must be indicated.

Issued 11.07.2019
Eocortex API and SDK 56

The server responds with the following parameters:


<in>434</in>
<out>378</out>
Parameter Description
in Number of people who entered for the given counter
out Number of people who exited for the given counter

Issued 11.07.2019
Eocortex API and SDK 57

6. Organization of video broadcast to a site


Video broadcast can be organized with the help of a mobile connections service of Eocortex server
and the components on the client’s side (in the browser).

6.1 Flash video broadcast


Video broadcast to a site can be organized with the help of a mobile connections service of
Eocortex server and a Flash component on the client’s side.
An example of a component used on the html-page can be found in Examples\SiteFlash folder.
It is necessary to indicate the parameters for connection to Eocortex server, as well as the
required codec (H264 or MJPEG) and the identifier (name/number) of a channel from which the
video will be broadcast, on HTML page (index.html).
Example of configuration:
var flashvars = {
server: "demo.Eocortex.com", // server address
port: "8080", // server port
login: "root", // user name
password_hash: "", // md5 password hash
mode: "MJPEG," // preferred video format
channel: "1" // channel name, number or identifier
};
Identifiers of all channels in the system can be received with a specific query (see Obtaining
system configuration, page 36).
Preferred video format (mode) parameter can be MJPEG, H264, or can be omitted. If
preferred video format is not set, an appropriate format will be set automatically. H264 value
can be defined only for the cameras which broadcast H264-coded streams. MJPEG can be
defined for all cameras, but it can cause increased server load if recoding from H.264 is
required.

6.2 JavaScript video broadcast to site (out of date)


This technique is out of date, because it causes increased load of Eocortex server
and provides inferior quality of broadcasing to site as compared with Flash-
component.

Broadcasting video to site can be organized with the help of Eocortex server and JavaScript
component on the client’s side. A script for the client’s side and the example of its usage on
the HTML page can be found in the Examples\Site\frameReceiver.js folder. In the script
it is necessary to indicate the parameters for connection to Eocortex server, as well as the
identifier (name/number) of a channel from which the video will be broadcast and the required
size of the area to which video frames will be output.
Example of script configuration:
var serverUrl = "http://95.23.84.1:8080" /*server URL*/
var login = "root" /*user with rights to watch channel being broadcast*/
var password = ""; /*MD5 hash of user password in upper case or empty string in case
of blank password*/
var channelnum = 0; /*ordinal number of channel in general configuration, counting
from 0*/
var drawWidth = 577; /*display area width in pixels*/
var drawHeight = 432; /*display area height in pixels*/
An example of script using the channel identifier instead of its ordinal number can be found
in Examples\Site\frameReceiver_id.js folder. There must be a tag
<imgname='frontImage'/> on the HTML page where MJPEG-coded video stream will be
displayed.

Issued 11.07.2019
Eocortex API and SDK 58

It is not recommended to change display area size dynamically, because it will cause a
substantial increase of resources used by mobile connections service since it
transcodes initial video stream into MJPEG and then divides the received stream
among many clients (sessions). The use of different resolutions will also cause
additional load to the mobile connections service.

Issued 11.07.2019

You might also like