banner



How To Use Kinect As A Surveillance Camera

  • Download KinectProtocol executable files - 45.2 KB
  • Download KinectProtocol project source code - 3.8 MB

Introduction

Some months ago, I posted in this site an article titled A complete anti-theft homemade surveillance system. As the title indicates, it is a software intended to dwelling house security, which can utilize one or more cameras, intruder detectors to trigger the alarm, advice devices to notify alarms, and storage systems to access the photos taken by the cameras in the instant of the alarm.

The arrangement is extensible, and so that you can easily write your own drivers for each of these protocols and add them to the application almost without attempt.

Microsoft Kinect sensor is especially appropriate for this application. It provides a colour camera and an infrared sensor, which can be used equally surveillance cameras, along with a human body detection system and a depth sensor, which allow implementing the presence detection protocol to trigger the alarm using 2 different approaches.

There exist different versions of the sensor, along with dissimilar versions of Kinect SDK. The code provided with this article uses the version 2.0 of the SDK, which works with the Kinect Sensor for Xbox I, but not for the Xbox 360 version (at least in my case), and so that, if you want or need to utilize another SDK version, you will have to change i of the classes of the project in order to conform it to these version.

You can download the source code of the KinectProtocol project, or you can download the necessary executable files only, and unzip the content of the annal into the path where the ThiefWatcher application is installed. The ThiefWatcher application tin can exist downloaded from the commodity referenced above.

To compile the KinectProtocol project, you lot have to add a reference to the WatcherCommons projection in the ThiefWatcher principal solution.

The code is written in C# using Visual Studio 2015.

Installing the Protocols

In one case the Microsoft.Kinect.dll, KinectProtocol.dll files and the es directory, with the Spanish resources, are copied in the ThiefWatcher directory, y'all only have to use the Install Protocol option in the File carte to select the file KinectProtocol.dll, and the KinectCamera and KinectTrigger protocols volition be added to the configuration files.

Equally the sensor can provide infrared and color images at once, you can add 1 camera of each type with a single device, so that you can take images both with light or in the dark. To configure a Kinect camera, employ the New Camera option in the File menu, and select Kinect Photographic camera in the drop down list:

Select Kinect Camera protocol

Leave blank all the data in the Photographic camera Admission dialog box, as at that place is no need in this case.

Camera Access dialog box

In Camera Settings, yous merely have two options, color or infrared images, select one of them and close the dialog box.

Camera Settings dialog box

The last step is to provide a name for the camera and to printing the relieve push button to shop information technology in the configuration files.

Give a name and save camera

You lot can test the photographic camera past using the play push button in this aforementioned window.

Regarding the trigger protocol, it is configured in the control panel:

Control Panel Window

In the drop downward listing, select Kinect Trigger as the trigger protocol. And so, you take to provide a connection string to set upwardly the operation mode and settings.

You have 2 options in this instance. Using the body detection is perfect if you have pets at home, every bit only the presence of human beings volition be detected. The string connection in this example is just source=torso .

On the other hand, you tin can also use the depth sensor to detect a wide range of changes in the surround. With this choice, the data obtained from Kinect are, for each pixel of the image, their distance in millimetres to the sensor. The algorithm used to discover changes is to summate the divergence between 2 consecutive frames, subtracting each pixel of one image from the corresponding one in the other. If the altitude if greater than some threshold, the deviation is taken into account. When the count of differences exceeds a given percentage of the total pixels of the prototype, the trigger is fired.

In the string connection, yous accept to indicate source=depth, and the threshold (thres parameter) and the percentage of differences (sens parameter), for case: source=depth;thres=100;sens=15.

Using the Code

The implementation of the camera and trigger protocol is explained in the master article about ThiefWatcher application. So let's focus on the Sensor static class, which encapsulates all the code necessary to interact with the Kinect Sensor and which is the just i you have to modify to adapt the code to other Kinect SDK versions.

The SensorCaps enum is used to indicate the type of inputs that must exist processed, in order to optimize the piece of work:

          [          Flags]          public          enum          SensorCaps {     None =          0,     Color =          1,     Infrared =          2,     Depth =          four,     Torso =          viii          }

In the Sensor.Caps property, you lot can indicate the advisable combination of these values.

You have two properties for colour images, Sensor.ColorFrameSize, which is read-only, which returns the size of the image equally a Size struct, and the Sensor.ColorFrame property, which returns a Bitmap object with the last image captured.

Infrared images are handled with two homologous properties: Sensor.InfraredFrameSize and Sensor.InfraredFrame.

The trunk detection is performed through the Sensor.BodyTracked Boolean belongings, and the depth sensor data is obtained, in the form of an ushort assortment, from the Sensor.DepthFrame property.

The sensor is put into functioning using the OpenSensor method, which receives a parameter of SensorCaps type. Equally this method is called by each camera and by the trigger protocol and it is only necessary to start the sensor once, we proceed an account of instances that have called the method in the global variable _instances:

          public          static          void          OpenSensor(SensorCaps caps) {     Caps |= caps;          if          (_sensor ==          null)     {         _instances =          1;         _sensor = KinectSensor.GetDefault();          if          (!_sensor.IsOpen)         {             _sensor.Open up();         }         Initialize();         _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color             | FrameSourceTypes.Depth             | FrameSourceTypes.Infrared             | FrameSourceTypes.Body);         _reader.MultiSourceFrameArrived +=          new          EventHandler<MultiSourceFrameArrivedEventArgs>(OnNewFrame);     }          else          {         _instances++;     } }

The global variable _sensor, of KinectSensor type, will be cypher the first time this method is called. In this case, we also create a MultiSourceFrameReader frame reader, in the _reader variable, which allows us to configure several types of data to exist read at the same time. In this instance, we volition always read color and infrared images, depth data and the list of detected bodies.

The style to read them will be through the MultiSourceFrameArrived event, which will trigger every fourth dimension a new frame is available.

The method to stop an instance opened with OpenSensor is CloseSensor, which volition reduce the count of instances until it reaches the terminal one, leaving in this example the system in its initial state and releasing resources:

          public          static          void          CloseSensor() {     _instances--;          if          (_instances <=          0)     {          if          (_sensor !=          null)         {          if          (_sensor.IsOpen)             {                 _sensor.Close();                 _reader.Dispose();                 _reader =          goose egg;                 _sensor =          goose egg;             }         }         _instances =          0;         Caps = SensorCaps.None;     } }

And that'southward all, thanks for reading!!

Source: https://www.codeproject.com/Articles/1235037/Homemade-Surveillance-using-Kinect-Sensor

Posted by: mcdonaldroure1972.blogspot.com

0 Response to "How To Use Kinect As A Surveillance Camera"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel