Most viewed recipes tagged "vision" Code RecipesOpenKinect Mouse Control Using Python (Python) 2012-04-15T18:49:00-07:00Alexander James Wallar <p style="color: grey"> Python recipe 578104 by <a href="/recipes/users/4179768/">Alexander James Wallar</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/computer_vision/">computer_vision</a>, <a href="/recipes/tags/depth/">depth</a>, <a href="/recipes/tags/hand_tracking/">hand_tracking</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/mouse/">mouse</a>, <a href="/recipes/tags/opencv/">opencv</a>, <a href="/recipes/tags/openkinect/">openkinect</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tracking/">tracking</a>, <a href="/recipes/tags/vision/">vision</a>). Revision 2. </p> <p>This is a simple code that lets a user control the mouse and left-click using the Microsoft Kinect, Python, and OpenKinect. </p> <pre class="prettyprint"><code>Computer Prerequisites: -OpenKinect -Python Wrapper for OpenKinect -A Linux machine using Ubuntu -OpenCV 2.1 -OpenCV 2.3 -Python 2.7.2 -A Microsoft Kinect -A Microsoft Kinect USB Adapter -PyGame -Xlib for Python </code></pre> <p>To run this code you either need to start it in the terminal or you need to write a short bash script that runs the code. This is necessary because it requires super-user privileges.</p> <p>The Bash script is (Assuming the code is saved by the name 'Hand' in /home/$USER directory:</p> <pre class="prettyprint"><code>#!bin/bash cd 'home/$USER' gksudo python 'Hand' </code></pre> <p>The code is heavily commented and most of what you will need to know is there. </p> Incremental PCA (Python) 2010-05-01T18:04:39-07:00Micha Kalfon <p style="color: grey"> Python recipe 577213 by <a href="/recipes/users/4173851/">Micha Kalfon</a> (<a href="/recipes/tags/incremental/">incremental</a>, <a href="/recipes/tags/klt/">klt</a>, <a href="/recipes/tags/learning/">learning</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/pca/">pca</a>, <a href="/recipes/tags/scipy/">scipy</a>, <a href="/recipes/tags/svd/">svd</a>, <a href="/recipes/tags/vision/">vision</a>). </p> <p>An incremental PCA algorithm in python. </p> <p>Incremental PCA allows computing an approximation of the principal components on large data sets as observations are given sequentially.</p> Control your mouse with the Microsoft Kinect using OpenKinect (Python) 2012-03-19T21:28:08-07:00Alexander James Wallar <p style="color: grey"> Python recipe 578082 by <a href="/recipes/users/4179768/">Alexander James Wallar</a> (<a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/control/">control</a>, <a href="/recipes/tags/freenect/">freenect</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/microsoft/">microsoft</a>, <a href="/recipes/tags/mouse/">mouse</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/openkinect/">openkinect</a>, <a href="/recipes/tags/vision/">vision</a>, <a href="/recipes/tags/xlib/">xlib</a>). </p> <p>This is a simple code that uses the Kinect in order to simulate the mouse on the screen. In order for this code to work you must have a Linux machine, the freenect module from OpenKinect, NumPy, and Xlib. The last three can be downloaded and installed by running sudo apt-get install {PROGRAM NAME HERE}. Freenect needs to be downloaded and installed for python using the terminal and there are good instructions here how to do it <a href="" rel="nofollow"></a>. You will also need to install the python wrapper. This can be done by following the instructions on this site: <a href="" rel="nofollow"></a>. To run the code you must first cd into the directory in which the code resides and then in the terminal run the command sudo python {THE NAME YOU STORED THE CODE BELOW AS}.py. This should run the code. The code needs superuser privileges. Also if you wonder why the mouse will stop tracking your hand, there are two reasons. 1) This code is not super sophisticated, all it does is find the minimum point in the depth image and scales the coordinates to the size of the screen and moves the mouse there so if your stomach is the closest thing to the screen it will track it and place the mouse there. The other reason the mouse might stop tracking is because there is a counter in the that will only let it run 10000 iterations. This is just a safety precaution in case you are not able to control the mouse and the computer freaks out. The last thing you need to know to run this code is that the main_mouse() function takes to arguments, the first is the x dimension of your screen and the second is the y dimension. THE CODE WILL NOT FUNCTION PROPERLY ON MULTIDISPLAY COMPUTERS. Thank You</p>