PyKinect (Yep, Python and Kinect, in Visual Studio yet!)
- Posted: Nov 09, 2011 at 6:00 AM
- 9,589 Views
- 1 Comment
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Credit for today's entry goes to Develop with Python in Visual Studio, connect with Kinect and Excel. I don't follow Python news much and so might have missing this if it wasn't for Dan's post.
Not only do does this highlight the latest version of the Python Tools for Visual Studio release, but shows off using Python to develop Kinect for Windows SDK games and applications.
PyKinect – write Kinect games using Python!
We are very excited to announce PyKinect with PTVS [Python Tools for Visual Studio] 1.1. PyKinect enables writing awesome games and interfaces using Python:
Prerequisites:
- CPython 2.7
- PyGame (http://www.pygame.org/download.shtml)
- Kinect SDK (http://kinectforwindows.org/ 32-bit only!)
- Speech support (Kinect for Windows Runtime Language Pack, version 0.9)
- A kinect sensor (note you don’t need an Xbox 360 to use PyKinect)
- A kinect Power/USB Adaptor (eg: Sample from Amazon.com)
Installation:
Assuming you’ve already installed PTVS & a CPython interpreter, install PyGame, Kinect SDK and PyKinect (order doesn’t matter). To verify the installation, you can check: Tools/Python Tools/Samples/PyKinect -- you should be able use this to install PyKinect into a 32-bit Python distribution:
...
Project Information URL: http://pytools.codeplex.com/wikipage?title=PyKinect
Project Download URL: http://pytools.codeplex.com/releases
Project Source URL: http://pytools.codeplex.com/SourceControl/list/changesets
if __name__ == '__main__':
full_screen = False
draw_skeleton = True
video_display = False
screen_lock = thread.allocate()
screen = pygame.display.set_mode(DEPTH_WINSIZE,0,16)
pygame.display.set_caption('Python Kinect Demo')
skeletons = None
screen.fill(THECOLORS["black"])
kinect = nui.Runtime()
kinect.skeleton_engine.enabled = True
def post_frame(frame):
try:
pygame.event.post(pygame.event.Event(KINECTEVENT, skeletons = frame.SkeletonData))
except:
# event queue full
pass
kinect.skeleton_frame_ready += post_frame
kinect.depth_frame_ready += depth_frame_ready
kinect.video_frame_ready += video_frame_ready
kinect.video_stream.open(nui.ImageStreamType.Video, 2, nui.ImageResolution.Resolution640x480, nui.ImageType.Color)
kinect.depth_stream.open(nui.ImageStreamType.Depth, 2, nui.ImageResolution.Resolution320x240, nui.ImageType.Depth)
print('Controls: ')
print(' d - Switch to depth view')
print(' v - Switch to video view')
print(' s - Toggle displaing of the skeleton')
print(' u - Increase elevation angle')
print(' j - Decrease elevation angle')
# main game loop
done = False
while not done:
e = pygame.event.wait()
dispInfo = pygame.display.Info()
if e.type == pygame.QUIT:
done = True
break
elif e.type == KINECTEVENT:
skeletons = e.skeletons
if draw_skeleton:
draw_skeletons(skeletons)
pygame.display.update()
elif e.type == KEYDOWN:
if e.key == K_ESCAPE:
done = True
break
elif e.key == K_d:
with screen_lock:
screen = pygame.display.set_mode(DEPTH_WINSIZE,0,16)
video_display = False
elif e.key == K_v:
with screen_lock:
screen = pygame.display.set_mode(VIDEO_WINSIZE,0,32)
video_display = True
elif e.key == K_s:
draw_skeleton = not draw_skeleton
elif e.key == K_u:
kinect.camera.elevation_angle = kinect.camera.elevation_angle + 2
elif e.key == K_j:
kinect.camera.elevation_angle = kinect.camera.elevation_angle - 2
elif e.key == K_x:
kinect.camera.elevation_angle = 2
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
geneal
Remove this comment
Remove this thread
close