Giter Club home page Giter Club logo

pykinect2's Introduction

PyKinect2

python wrapper for kinect2 allow easier access of kinect2

Install from source

Install dependencies from libfreenect2

sudo apt-get install build-essential cmake pkg-config libturbojpeg libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev python3-dev swig
sudo apt-get install libturbojpeg0-dev
sudo apt-get install libusb-1.0-0-dev

Copy 90-kinect2.rules under /etc/udev/rules.d/ to grant permission for Kinect2 usb

Running pip should be enough:

pip install .

Examples

examples on how to fetch rgb images and depth map from kinect2 and the registered frame

from kinect2 import Kinect2
import cv2
import numpy as np


def main():
  kinect = Kinect2()
  if not kinect.IsOpened():  # check if kinect2 device is connected
    print('no kinect2 device found')
    return

  while True:
    kinect.NextFrame()  # grab the data from libfreenect2 frame
    rgb = kinect.RGB()
    ir = kinect.IR()
    depth = kinect.Depth()
    undistorted = kinect.Undistorted()
    registered = kinect.Registered()

    rgb = np.reshape(np.ravel(rgb, 'F'), rgb.shape)
    ir = np.reshape(np.ravel(ir, 'F'), ir.shape) / 1000.0
    depth = np.reshape(np.ravel(depth, 'F'), depth.shape)
    undistorted = np.reshape(np.ravel(undistorted, 'F'), undistorted.shape)
    registered = np.reshape(np.ravel(registered, 'F'), registered.shape)

    cv2.imshow('RGB', rgb)
    cv2.imshow('IR', ir)
    cv2.imshow('Depth', depth)
    cv2.imshow('Undistorted', undistorted)
    cv2.imshow('Registered', registered)
    key = cv2.waitKey(30)
    if key in [ord('q'), ord('Q')]:
      break
  kinect.Stop()


if __name__ == '__main__':
  main()

pykinect2's People

Contributors

kiddos avatar moskari avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.