Can I Use My Xbox Kinect As A Security Camera
- Download KinectProtocol executable files - 45.2 KB
- Download KinectProtocol project source code - three.eight MB
Introduction
Some months ago, I posted in this site an article titled A complete anti-theft bootleg surveillance arrangement. As the title indicates, it is a software intended to home security, which tin employ one or more than 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 alert.
The system is extensible, and so that you lot can hands write your own drivers for each of these protocols and add together them to the awarding almost without effort.
Microsoft Kinect sensor is specially appropriate for this application. Information technology provides a color camera and an infrared sensor, which can exist used as surveillance cameras, forth with a human trunk detection organisation and a depth sensor, which allow implementing the presence detection protocol to trigger the alert using 2 different approaches.
At that place exist different versions of the sensor, along with different versions of Kinect SDK. The code provided with this article uses the version ii.0 of the SDK, which works with the Kinect Sensor for Xbox Ane, but not for the Xbox 360 version (at least in my case), then that, if you want or need to use another SDK version, you will accept to modify i of the classes of the projection in order to adapt information technology 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 archive into the path where the ThiefWatcher
awarding is installed. The ThiefWatcher
application tin exist downloaded from the article referenced above.
To compile the KinectProtocol
project, you have to add together a reference to the WatcherCommons
project in the ThiefWatcher
main 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, you simply have to use the Install Protocol selection in the File card to select the file KinectProtocol.dll, and the KinectCamera and KinectTrigger p
rotocols will exist added to the configuration files.
As the sensor can provide infrared and color images at once, you can add one camera of each type with a unmarried device, so that you tin can have images both with light or in the night. To configure a Kinect camera, use the New Camera option in the File menu, and select Kinect Camera in the drop downwards list:
Leave blank all the data in the Photographic camera Admission dialog box, equally there is no demand in this case.
In Camera Settings, you lot only have two options, color or infrared images, select one of them and shut the dialog box.
The last step is to provide a name for the camera and to press the save push button to store it in the configuration files.
You tin exam the camera by using the play button in this same window.
Regarding the trigger protocol, it is configured in the control console:
In the driblet down list, select Kinect Trigger as the trigger protocol. So, y'all take to provide a connexion cord to ready upwardly the performance mode and settings.
You have ii options in this case. Using the trunk detection is perfect if you have pets at home, as only the presence of human beings will be detected. The string connection in this case is just source=body
.
On the other hand, you tin can also apply the depth sensor to detect a broad range of changes in the environment. With this option, the data obtained from Kinect are, for each pixel of the paradigm, their distance in millimetres to the sensor. The algorithm used to detect changes is to calculate the divergence between two consecutive frames, subtracting each pixel of 1 paradigm from the respective one in the other. If the distance if greater than some threshold, the difference is taken into account. When the count of differences exceeds a given percent of the total pixels of the image, the trigger is fired.
In the string
connexion, you have to indicate source=depth
, and the threshold (thres
parameter) and the percentage of differences (sens
parameter), for instance: source=depth;thres=100;sens=15
.
Using the Code
The implementation of the camera and trigger protocol is explained in the principal article about ThiefWatcher
application. Then let'due south focus on the Sensor static
grade, which encapsulates all the lawmaking necessary to collaborate with the Kinect Sensor and which is the only one you have to alter to adjust the code to other Kinect SDK versions.
The SensorCaps enum
is used to indicate the type of inputs that must be candy, in lodge to optimize the work:
[ Flags] public enum SensorCaps { None = 0, Color = 1, Infrared = 2, Depth = four, Body = eight }
In the Sensor.Caps
holding, you can bespeak the advisable combination of these values.
You have two backdrop for color images, Sensor.ColorFrameSize
, which is read-only, which returns the size of the image as a Size struct
, and the Sensor.ColorFrame
property, which returns a Bitmap
object with the last epitome captured.
Infrared images are handled with two homologous properties: Sensor.InfraredFrameSize
and Sensor.InfraredFrame
.
The body detection is performed through the Sensor.BodyTracked
Boolean belongings, and the depth sensor data is obtained, in the form of an ushort
array, from the Sensor.DepthFrame
belongings.
The sensor is put into operation using the OpenSensor
method, which receives a parameter of SensorCaps
type. Every bit this method is chosen by each camera and by the trigger protocol and it is only necessary to beginning the sensor one time, nosotros keep an account of instances that take 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(); } Initialize(); _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Trunk); _reader.MultiSourceFrameArrived += new EventHandler<MultiSourceFrameArrivedEventArgs>(OnNewFrame); } else { _instances++; } }
The global variable _sensor
, of KinectSensor
type, will exist null
the beginning fourth dimension this method is chosen. In this example, we as well create a MultiSourceFrameReader
frame reader, in the _reader
variable, which allows united states to configure several types of data to be read at the same time. In this case, we will always read color and infrared images, depth information and the list of detected bodies.
The style to read them will exist through the MultiSourceFrameArrived
result, which will trigger every time a new frame is available.
The method to terminate an instance opened with OpenSensor
is CloseSensor
, which will reduce the count of instances until it reaches the terminal one, leaving in this case the system in its initial land and releasing resource:
public static void CloseSensor() { _instances--; if (_instances <= 0) { if (_sensor != null) { if (_sensor.IsOpen) { _sensor.Close(); _reader.Dispose(); _reader = null; _sensor = zip; } } _instances = 0; Caps = SensorCaps.None; } }
And that's all, thanks for reading!!
Source: https://www.codeproject.com/Articles/1235037/Homemade-Surveillance-using-Kinect-Sensor
Posted by: cresswellthaton1982.blogspot.com
0 Response to "Can I Use My Xbox Kinect As A Security Camera"
Post a Comment