A Flask Web App that permits the user use their Xbox 360 Kinect as a survilence camera for their home, room, or general purpose area.
- Flask
- Python
- libfreenect Source Code for Xbox 360 Kinect
- OpenCV2
- Kinect USB Adapater
- html/css
- Connect Kinect USB Adapter to your Kinect and your Computer/Laptop
- Install the libfreenect software and OpenCV2 from this website.
- Install Flask with
pip3 install flask - Clone this repository
- Run
python3 app.pyin your terminal to start Flask app - Open the link provided in your terminal after you run the Flask app to go the web app where you will see you're Kinect streaming real-time footage.
Over these past two weeks, I got the opportunity to learn how to turn my Xbox 360 Kinect into a web cam.
I first opted for a Raspberry Pi with a camera module, but my Pi only has 1 GB of ram, so the footage would crash and look like this:
raspberryPiweakCamera.mp4
However, I then remembed the Kinect being used in many applications in robotics before for guided assistance and 3D scanning.
So I thought why notstart using it as a security camera to observe when I am away from home. I got to working as soon as the Kinect USB adapter came in, but it was difficult finding any information on what libraries to install to have the Kinect working properly, but thankfully my answers were solved when I found this website.
Although the website seems outdated, the only change that must be made is when installing the wrappers to program the Kinect with Python the wrappers must be installed with Python3 or the appropriate version of Python you have installed or else the programs you run will not work properly. After installing OpenCV, I made my Flask App, which was just simple HTML, but when it came to using Flask I spent a whole four days learning how to have the video from the Kinect be streamed from the HTML index file I made.
Yet, I found a tutorial where the host streams live footage from his web cam onto a flask app. The only difference is I need to have the footage stream form the Kinect not my web cam.
To only access the Kinect I learned about the “/dev/video*” inputs in Ubuntu, which denote cameras that are plugged in/installed.
Moreover, to access my Kinect’s camera I just had use the videoCapture function to attain the footage, then I use the read command to process a frame, turn it into a JPEG format, and encode it to bytes.
I have to capture each frame in order to have the video output in web page (the HTML index file) and using Flask I create another route called “video,” but the route gives a response similar to how an API works because the response returns each frame of the footage as JPEG image, so that the video can properly display in index HTML file.
Here is a proper demontration of it working, but I just needed to center the video footage to the center of the screen using CSS:

