People Count

Counts the number of people that are captured by the camera.

This data point is suppported only in PanaCast and PanaCast 50:

  • The PanaCast works with face recognition. Face recognition is not able ro recognize a face when the person is wearing a face mask or turning the face away from the camera.
  • The PanaCast 50 works with head recognition. Head recognition works even when the face is covered or turned away from the camera.

For these reasons, the people count may vary depending on the camera.

Data Point

   
Name in Jabra SDK DeviceLoggingEventArgs.Data["People_count"]
Trigger Whenever the number of people captured by the camera changes.
Event Subscription IDeviceService.DeviceLoggingInput
Value Range 0 or more

Jabra SDK for Windows: Code Sample for Jabra PanaCast 50

The code sample demonstrates the event subscription. It shows how to parse the event to get back the data for the data point.

using System;
using JabraSDK;
using Newtonsoft.Json.Linq;

namespace Jabra.TelemetryExample
{
    public class TelemetryPrinter
    {
        public TelemetryPrinter(IDeviceService deviceService)
        {
            deviceService.DeviceAdded += OnDeviceAddedEvent;
            deviceService.DeviceLoggingInput += OnDeviceLoggingInputEvent;
        }

        private void OnDeviceAddedEvent(object sender, DeviceAddedEventArgs e)
        {
            // Return if device logging is _not_ supported by devices
            if (!e.Device.IsFeatureSupported(DeviceFeature.Logging))
                return;

            // Return if device logging is already enabled for device
            if (e.Device.IsDeviceLogEnabled)
                return;

            try
            {
                var status = e.Device.DeviceLoggingConfiguration(true);
                if (status == DeviceStatus.ReturnOk)
                    Console.WriteLine($"Device logging enabled for: {e.Device.Name}");
            }
            catch (Exception)
            {
                // Exception raised when enabling device logging
            }
        }

        private void OnDeviceLoggingInputEvent(object sender, DeviceLoggingEventArgs e)
        {
            var eventPayload = JObject.Parse(e.Data);
            var peopleCountToken = eventPayload["People_count"];
            if (peopleCountToken != null)
            {
                Console.WriteLine($"People count: {peopleCountToken}");
            }
        }
    }
}

PanaCast SDK: Code Sample for Jabra PanaCast

The code sample demonstrates the event subscription. It shows how to parse the event to get back the data for the data point.

using System;
using System.Runtime.InteropServices;

namespace Jabra.TelemetryExample
{
    public class TelemetryPrinter : IDisposable
    {
        private const string DllPath = "WinPanaCastWrapperDll.dll";
        private const int BufferLength = 1024;
        private const bool EnableFaceBox = false;
        private const int PeopleCountCallbackIntervalSeconds = 5;

        private readonly IntPtr _panaCastManager;
        private readonly byte[] _deviceId;
        private readonly byte[] _peopleCountErrorMessageBuffer = new byte[BufferLength];

        public TelemetryPrinter(IntPtr panaCastManager, byte[] deviceId)
        {
            _panaCastManager = panaCastManager;
            _deviceId = deviceId;
        }

        public void StartPeopleCountPrinterOrExit()
        {
            SetUpCallbacks();
            try
            {
                RegisterPeopleCountListener();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to start people count printer: " + e.Message);
                destroyPanaCast(_panaCastManager);
                Environment.Exit(1);
            }
        }

        private void SetUpCallbacks()
        {
            setPeopleCountAvailableCallback(PeopleCountCallback);
            setPeopleCountErrCallback(PeopleCountErrorCallback, _peopleCountErrorMessageBuffer, BufferLength);
        }

        private void PeopleCountCallback(int numPeople, bool isCameraStreaming)
        {
            Console.WriteLine($"Camera is streaming: {isCameraStreaming}. People count is: {numPeople}.");
        }

        private void PeopleCountErrorCallback()
        {
            var errorMessage = System.Text.Encoding.ASCII.GetString(_peopleCountErrorMessageBuffer, 0, _peopleCountErrorMessageBuffer.Length);
            Console.WriteLine($"Failed to get people count: {errorMessage}");
            destroyPanaCast(_panaCastManager);
            Environment.Exit(1);
        }

        private void RegisterPeopleCountListener()
        {
            var errorMessageBuffer = new byte[BufferLength];

            // Start people count monitor without exclusion zones and no distance limit
            var successful = startPeopleCountMonitor(_panaCastManager, _deviceId, 0, Array.Empty<int>(), 0, 0,
                PeopleCountCallbackIntervalSeconds, EnableFaceBox, errorMessageBuffer, BufferLength, -1);

            if (!successful)
            {
                var errorMessage = System.Text.Encoding.ASCII.GetString(errorMessageBuffer, 0, errorMessageBuffer.Length);
                throw new Exception(errorMessage);
            }
        }

        public void Dispose()
        {
            var errorMessageBuffer = new byte[BufferLength];
            if (!stopPeopleCountMonitor(_panaCastManager, _deviceId, errorMessageBuffer, BufferLength)){
                var errorMessage = System.Text.Encoding.ASCII.GetString(errorMessageBuffer, 0, errorMessageBuffer.Length);
                Console.WriteLine($"Failed to stop people count printer: {errorMessage}");
            }
        }

        private delegate void PeopleCountCallbackDelegate(int numPeople, bool isCameraStreaming);
        private delegate void PeopleCountErrorCallbackDelegate();

        [DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
        private static extern bool startPeopleCountMonitor(IntPtr mgr, byte[] deviceID, int sen, int[] exZonesBuf, int exZonesBufBytes, int numExZones,  int cbFreqSecs, bool enableFaceBox, byte[] errMsg, int numErrorMsgBytes, int maxDistanceFeet);

        [DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
        private static extern bool stopPeopleCountMonitor(IntPtr mgr, byte[] deviceID, byte[] errMsg, int numErrorMsgBytes);

        [DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
        private static extern void destroyPanaCast(IntPtr mgr);

        [DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
        private static extern void setPeopleCountAvailableCallback(PeopleCountCallbackDelegate callback);

        [DllImport(DllPath, CallingConvention = CallingConvention.Cdecl)]
        private static extern void setPeopleCountErrCallback(PeopleCountErrorCallbackDelegate callback, byte[] cbErrMsgBuf, int cbErrMsgBufSize);

    }
}