Popular recipes tagged "meta:loc=132"http://code.activestate.com/recipes/tags/meta:loc=132/2012-03-18T18:52:42-07:00ActiveState Code RecipesLibreenect (OpenKinect) Minimum Value Joystick With Display - Kinect Demo Using OpenKinect SDK (Python)
2012-03-18T18:52:42-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578080-libreenect-openkinect-minimum-value-joystick-with-/
<p style="color: grey">
Python
recipe 578080
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/computer_vision/">computer_vision</a>, <a href="/recipes/tags/depth/">depth</a>, <a href="/recipes/tags/joystick/">joystick</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/libfreenect/">libfreenect</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/opencv/">opencv</a>, <a href="/recipes/tags/programming/">programming</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/virtual_joystick/">virtual_joystick</a>).
Revision 3.
</p>
<p>This demo requires you to be using a Linux machine and to have libfreenect installed with the python wrapper. This demo also requires you to have opencv, numpy, and pygame. They can all be installed using sudo apt-get install {PROGRAM NAME HERE}. Here are instructions on installing libfreenect: <a href="http://openkinect.org/wiki/Getting_Started" rel="nofollow">http://openkinect.org/wiki/Getting_Started</a>. Okay, so what this demo does is finds the minimum point on the depth image and uses the index of this minimum point to create a four button joystick that codes for 'A', 'B', 'X', 'Y'. It also uses the minimum point and the RGB image to put a circle on the minimum point on the screen. So basically a dot will follow your hand on the RGB image. If the minimum value is larger than 600 (arbitrary units), the color of the dot will change from red to purple and the dot will remain stationary. Also, if the Kinect is not properly opened the first time, unplug it and plug it back in and run in the terminal sudo freenect-glview. After try running the program again. One more thing, this code requires super user privileges so run it through the terminal. Here is how to do this for linux n00bs.</p>
<ol>
<li>Change your directory the the directory the code is in (use cd {PATH})</li>
<li>Run the code using sudo python {FILENAME}</li>
<li>Don't forget to add the the .py at the end</li>
</ol>
ConntrackEventListener (Python)
2010-01-25T10:24:12-08:00Andrew Grigorevhttp://code.activestate.com/recipes/users/4172098/http://code.activestate.com/recipes/577011-conntrackeventlistener/
<p style="color: grey">
Python
recipe 577011
by <a href="/recipes/users/4172098/">Andrew Grigorev</a>
(<a href="/recipes/tags/conntrack/">conntrack</a>).
Revision 3.
</p>
<p>Using libnetfilter_conntrack (through ctypes) to catch conntrack events. Available on PyPI with <a href="http://pypi.python.org/pypi/Conntrack" rel="nofollow">http://pypi.python.org/pypi/Conntrack</a></p>
Mixing features of "tree" and of "md5sum" : tree_md5 :) (Python)
2008-03-29T09:12:09-07:00Guillaume Knispelhttp://code.activestate.com/recipes/users/4127202/http://code.activestate.com/recipes/552739-mixing-features-of-tree-and-of-md5sum-tree_md5/
<p style="color: grey">
Python
recipe 552739
by <a href="/recipes/users/4127202/">Guillaume Knispel</a>
(<a href="/recipes/tags/programs/">programs</a>).
</p>
<p>Have you ever wanted to describe a filesystem subtree with, as an extra bonus, the md5sum of each file ?</p>
<p>I have.</p>
<p>Here is a tiny Python script that mixes functions of "tree" and of "md5sum", just for your pleasure.</p>
<p>I wrote it with Python 2.4 under Linux.</p>
Computing permutations with duplicates (Python)
2006-07-07T00:06:16-07:00Christopher Dunnhttp://code.activestate.com/recipes/users/1683375/http://code.activestate.com/recipes/496869-computing-permutations-with-duplicates/
<p style="color: grey">
Python
recipe 496869
by <a href="/recipes/users/1683375/">Christopher Dunn</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 3.
</p>
<p>This handles duplicate values in the list. It could easily be made a generator, and it does not require recursion.</p>
Resettable Timer Class (Python)
2005-12-18T22:24:29-08:00James Stroudhttp://code.activestate.com/recipes/users/2658888/http://code.activestate.com/recipes/464959-resettable-timer-class/
<p style="color: grey">
Python
recipe 464959
by <a href="/recipes/users/2658888/">James Stroud</a>
(<a href="/recipes/tags/threads/">threads</a>).
Revision 6.
</p>
<p>The ResettableTimer class is a timer whose counting loop can be reset arbitrarily. Its duration is configurable. Commands can be specified for both expiration and update. Its update resolution can also be specified. Resettable timer keeps counting until the "run" method is explicitly killed with the "kill" method.</p>
GoogleCacheServer (Python)
2005-04-05T15:25:01-07:00Michael Foordhttp://code.activestate.com/recipes/users/1565518/http://code.activestate.com/recipes/408991-googlecacheserver/
<p style="color: grey">
Python
recipe 408991
by <a href="/recipes/users/1565518/">Michael Foord</a>
(<a href="/recipes/tags/web/">web</a>).
Revision 2.
</p>
<p>This is a simple implementation of a proxy server that fetches web pages
from the google cache. It allows you to view the internet through the eyes of google ! Fire it up and point your browser at localhost:8000</p>
Build section numbers for a table of contents (Python)
2004-08-28T16:54:50-07:00Dave Benjaminhttp://code.activestate.com/recipes/users/798272/http://code.activestate.com/recipes/302467-build-section-numbers-for-a-table-of-contents/
<p style="color: grey">
Python
recipe 302467
by <a href="/recipes/users/798272/">Dave Benjamin</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>This recipe shows a way to generate section numbers for a nested document structure. It can be used within a recursive algorithm to build a table of contents.</p>
winnowing data with a heap. (Python)
2004-08-11T05:52:17-07:00Douglas Bagnallhttp://code.activestate.com/recipes/users/1629020/http://code.activestate.com/recipes/299058-winnowing-data-with-a-heap/
<p style="color: grey">
Python
recipe 299058
by <a href="/recipes/users/1629020/">Douglas Bagnall</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 3.
</p>
<p>The winnow class uses a heap for finding the best few out
of several items. At this it is quicker and shorter than
python 2.3's heapq module, which is aimed at queuing rather
than sifting. OTOH, it is unlikely to have any advantage over
2.4's heapq, which (I hear) has expanded functionality and is
implemented in C.</p>
Using pycurl to automate filling out web forms (Python)
2004-02-07T21:32:19-08:00Christian Longhttp://code.activestate.com/recipes/users/1148472/http://code.activestate.com/recipes/267255-using-pycurl-to-automate-filling-out-web-forms/
<p style="color: grey">
Python
recipe 267255
by <a href="/recipes/users/1148472/">Christian Long</a>
(<a href="/recipes/tags/web/">web</a>).
</p>
<p>I wanted to get the list of rss feeds from AmphetaDesk (my desktop news aggregator <a href="http://www.disobey.com/amphetadesk" rel="nofollow">www.disobey.com/amphetadesk</a> ) into the aggregator in Drupal (web community site tool drupal.org).</p>
<p>I settled on automation of the Drupal web form using pycurl - the Python bindings to libcurl.</p>
pytunnel: tunneling w/threads (ssl thru proxy in this case) (Python)
2005-12-30T14:16:43-08:00John Nielsenhttp://code.activestate.com/recipes/users/135654/http://code.activestate.com/recipes/213238-pytunnel-tunneling-wthreads-ssl-thru-proxy-in-this/
<p style="color: grey">
Python
recipe 213238
by <a href="/recipes/users/135654/">John Nielsen</a>
.
Revision 4.
</p>
<p>This code shows an implementation of tunneling. Though this code uses ssl as an example. It would not be hard to modify it to work for other situations as well.</p>
<p>The reason I use ssl as an example is because the standard python libraries do not support tunneling ssl through a proxy. Import pytunnel and give it a function w/the code you want to tunnel and your off.</p>
<p>For the latest code try:
<a href="http://ftp.gnu.org/pub/savannah/cvs/pytunnel-cvs-latest.tar.gz" rel="nofollow">http://ftp.gnu.org/pub/savannah/cvs/pytunnel-cvs-latest.tar.gz</a></p>