Camlytics user guide

Overview of Camlytics Camera Software, and how to get started with it.

This section is intended for developers who want to write an add-in for this application.

This API is deprecated. Consider using REST API.

The API allows handling analytical events such as motion detected, camera obstructed, etc. in a custom way. For example, you might want to store events in a remote database, send them to a web service or start an external application.

Download sample VS project

In order to create an add-in complete the following steps:

  1. Create AddInEventReceiverXXX project in Visual Studio 2013 from the Class Library template (C#). The project should target .NET Framework 4.5.
  2. Add a reference to [ROOT]/Pipeline/AddInViews/EventReceiverAddInView.dll. [ROOT] is the path to the installed application.
  3. In the reference properties set Copy Local to False.
  4. Add a reference to System.Addin assembly which is included in .NET Framework.
  5. Change the projects's output path to [ROOT]/Pipeline/Addins/EventReceiverXXX/. If your [ROOT] directory points to Program Files or any folder that requires elevated permissions, you should start Visual Studio as Administrator.
  6. Create AddInEventReceiverXXX class that must:
    • implement Camly.AddIns.EventReceiverAddInViews.IEventReceiver interface (XML documentation can be found in [ROOT]/Pipeline/AddInViews/EventReceiverAddInView.XML),
    • be marked with System.AddIn.AddInAttribute attribute,
    • have a parameterless constructor,
    • be thread-safe,
    • dispose itself properly.
  7. Build the project.
  8. Start the application. Your add-in will be loaded automatically. If your [ROOT] directory points to Program Files or any folder that requires elevated permissions, you should start the application as Administator once so that the add-in is registered.

For additional support contact us at info@camlytics.com.

The sample add-in is enabled by default and writes events to a logger (folder %appdata%\Camlytics\Events).

using Camly.AddIns.EventReceiverAddInViews;
using System.AddIn;

namespace Camly.AddIns.AddInEventReceiverSample
{
  [AddIn("AddInEventReceiverSample"
    , Description = "Sample add-in that writes events to a logger"
    , Version = "1.0.0.0", Publisher = "Camlytics")]
  public class AddInEventReceiverSample : IEventReceiver
  {
    private InitInfo _initInfo;
    
    public void Init(InitInfo initInfo)
    {
      _initInfo = initInfo;
      _initInfo.Logger.LogInfo(string.Format(
        "AddInEventReceiverSample::Init({0})", initInfo));
    }
    
    public void OnEvent(EventInfo eventInfo)
    {
      _initInfo.Logger.LogInfo(string.Format(
        "AddInEventReceiverSample::OnEvent(eventInfo={0})", eventInfo));
    }
    
    public void Ping()
    {
      _initInfo.Logger.LogInfo("AddInEventReceiverSample::Ping()");
    }
    
    public void Dispose()
    {
      _initInfo.Logger.LogInfo("AddInEventReceiverSample::Dispose()");
    }
  }
}

The interfaces and classes listed below are the part of the Native API.

using System;
using System.AddIn.Pipeline;

namespace Camly.AddIns.EventReceiverAddInViews
{
  /// <summary>
  /// Add-in that intends to handle analytical events 
  /// must implement this interface 
  /// </summary>
  [AddInBase]
  public interface IEventReceiver: IDisposable
  {
    /// <summary>
    /// Called once at startup
    /// </summary>
    void Init(InitInfo initInfo);

    /// <summary>
    /// Called on every new event
    /// </summary>
    void OnEvent(EventInfo eventInfo);

    /// <summary>
    /// Called every [PingInterval_secs] seconds. 
    /// You can set the PingInterval_secs parameter
    /// in the configuration file of the app. 
    /// </summary>
    void Ping();
  }

  /// <summary>
  /// Info which is passed to the add-in at statup
  /// </summary>
  public class InitInfo
  {
    /// <summary>
    /// Version of the app
    /// </summary>
    public readonly string Version;

    /// <summary>
    /// Unique user identifier. Reserved. 
    /// </summary>
    public readonly string UserId;

    /// <summary>
    /// Writes a message to a log file 
    /// which is located here 
    /// %APPDATA%\Roaming\Camlytics\Logs\BasicLog.txt
    /// </summary>
    public readonly IAddInLogger Logger;
  }
  
  /// <summary>
  /// Describes a logger which allows to write
  /// a message to a log file 
  /// </summary>
  public interface IAddInLogger
  {
    void LogError(string message);
    void LogWarning(string message);
    void LogInfo(string message);
  }

  /// <summary>
  /// Info which is passed on an event
  /// </summary>
  public class EventInfo
  {
    /// <summary>
    /// Event type. Possible values: 
    ///     MotionStarted,
    ///     MotionFinished,
    ///     Sabotage,
    ///     MotionInRegionOn,
    ///     MotionInRegionOff,
    ///     RegionJoin, 
    ///     RegionLeave,
    ///     CrowdOn,
    ///     CrowdOff,
    ///     ObjectAppear,
    ///     ObjectDisappear,
    ///     Running,
    ///     Loitering,
    ///     AbandonedObject,
    ///     TripwireCrossed,
    ///     CameraDisconnected
    /// </summary>
    public readonly string Type;

    /// <summary>
    /// Event time 
    /// </summary>
    public readonly DateTimeOffset Timestamp;

    /// <summary>
    /// Unique identifier of a channel
    /// </summary>
    public readonly string ChannelId;

    /// <summary>
    /// Channel name
    /// </summary>
    public readonly string ChannelName;

    /// <summary>
    /// Unique identifier of the detected object
    /// in the current app session
    /// </summary>
    public readonly string ObjectId;

    /// <summary>
    /// Unique identifier of the triggered rule
    /// of the channel
    /// </summary>
    public readonly string RuleId;

    /// <summary>
    /// User-defined name of the rule
    /// </summary>
    public readonly string RuleName;

    /// <summary>
    /// Absolute path to a snapshot
    /// </summary>
    public readonly string SnapshotPath;
  }
}