Giter Site home page Giter Site logo

konstantinosang / pykinect2-pyqtgraph-pointclouds Goto Github PK

View Code? Open in Web Editor NEW
52.0 2.0 11.0 55.94 MB

Creating real-time dynamic Point Clouds using PyQtGraph, Kinect 2 and the python library PyKinect2.

License: MIT License

Python 100.00%
point-cloud pyqtgraph pykinect2 kinect2 python-library-pykinect2 pykinect2-pyqtgraph-pointclouds

pykinect2-pyqtgraph-pointclouds's Introduction

PyKinect2-PyQtGraph-PointClouds

Creating real-time dynamic Point Clouds using PyQtGraph, Kinect 2 and the python library PyKinect2.

Description

The PointCloud.py file contains the main class to produce dynamic Point Clouds using the PyKinect2 and the PyQtGraph libraries. The main file uses the numpy library that runs in C, thus it is fully optimized and can produce dynamic Point Clouds with up to 60+ frames, except for the point clouds produces by the RGB camera that run in 10+ frames. The library can also be used to create a PointCloud and save it as a .txt file containing the world point coordinates as: x, y, z . . . x, y, z It can also be used to view .ply or .pcd point cloud files or create PointClouds and save them as .ply or .pcd files. Instructions on how to use the main file are written in the Instructions chapter. In addition, there is a window with opencv track bars that can be used to dynamically change the color and the size of the points in the point cloud and the input flags.

Requirements

Install all requirements using the following command:

pip install requirement

Full list of all requirements.

* pyqtgraph==0.10.0
* numpy==1.18.2
* pykinect2==0.1.0
* opencv-python==4.2.0.34
* open3d-python==0.7.0.0
* time (already installed with Python3)
* sys (already installed with Python3)
* os (already installed with Python3)
* ctypes (already installed with Python3)

Another dependecy is the mapper file that I created and handles the ICoordanteMapper functions. Download the file and place it in the same directory as the PointCloud.py file. The main file is tested with Python 3.6.8.

Instructions

First import the main class as:

from PointCloud import Cloud

For viewing a point cloud text file with:
x, y, z
....
x, y, z
(world point coordinates)
If the file with the name does not exists it will create a point cloud with kinect and save it to that file.txt. It can also view .pcd and .ply files. I have uploaded some pointcloud files in the models/ directory for testing purposes.

# viewing a .txt file
pcl = Cloud(file='models/test_cloud_4.txt')
pcl.visualize()

# viewing .ply or .pcd files
# .pcd or .ply files open with the Open3D library
pcl = Cloud(file='models/model.pcd')

pcl = Cloud(file='models/Car.ply')

If the files doesn't exist then you have to specify from which sensor camera you want the pointcloud to be created and saved with that file name. The color point cloud is slower than the depth point cloud due to more points generated and written to the file.

# Creating a .txt PointCloud with the depth camera
pcl = Cloud(file='models/cloud_test_1.txt', depth=True)
pcl.visualize()

# Creating a .ply PointCloud with the depth camera
pcl = Cloud(file='models/cloud_test_1.ply', depth=True)

# Creating a .pcd PointCloud with the depth camera
pcl = Cloud(file='models/cloud_test_1.pcd', depth=True)

# Creating a .txt PointCloud with the color camera
pcl = Cloud(file='models/cloud_test_2.txt', color=True)
pcl.visualize()

# Creating a .ply PointCloud with the color camera
pcl = Cloud(file='models/cloud_test_3.ply', color=True)

# Creating a .pcd PointCloud with the color camera
pcl = Cloud(file='models/cloud_test_3.pcd', color=True)

For dynamically creating and viewing the PointCloud.

# rgb camera
pcl = Cloud(dynamic=True, color=True)
pcl.visualize()

# depth camera
pcl = Cloud(dynamic=True, depth=True)
pcl.visualize()

# body index
pcl = Cloud(dynamic=True, body=True)
pcl.visualize()

# skeleton cloud
pcl = Cloud(dynamic=True, skeleton=True)
pcl.visualize()

You can also visualize the clouds simultaneously in any order.

# example 1 with color and depth point clouds
pcl = Cloud(dynamic=True, simultaneously=True, color=True, depth=True, body=False, skeleton=False, color_overlay=False)
pcl.visualize()

# example 2 with all the point clouds enabled (scroll out to see the point cloud)
pcl = Cloud(dynamic=True, simultaneously=True, depth=True, color=True, body=True, skeleton=True, color_overlay=True)
pcl.visualize()

# example 3 with depth and body index point cloud
pcl = Cloud(dynamic=True, simultaneously=True, depth=True, color=False, body=True, skeleton=False, color_overlay=True)
pcl.visualize()

In addition, there is a window with trackbars to change the input flags, the color and point size of the cloud without closing the app.

Examples

Run the main file, to see the functionality, as:

python PointCloud.py

pykinect2-pyqtgraph-pointclouds's People

Contributors

konstantinosang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pykinect2-pyqtgraph-pointclouds's Issues

In mapper.py -> color_point_2_depth_point() error

In color_point_2_depth_point() function, [depth_x, depth_y] ->[-inf, -inf]
So it leads to the following result:

line 123, in color_point_2_depth_point
return [int(depth_x), int(depth_y)]
OverflowError: cannot convert float infinity to integer

If it is convenient for you, please tell me how can I solve this problem?

an issue with overlay

As you can see in this picture, the depth frame does not match the rgb frame, so there are two frames showing at the same time.
image
the main code is as followed:

    pcl = Cloud(dynamic=True, simultaneously=True, depth=True, color=False, body=False, skeleton=True, color_overlay=True)
    pcl.visualize()

I have read the code, and did not find the matching function. Do you have any idea? Thanks very much.

pykinect2

Traceback (most recent call last):
File "D:\Software\PyCharm2023\PycharmProjects\PyKinect2-PyQtGraph-PointClouds-master\PointCloud.py", line 11, in
from pykinect2.PyKinectV2 import *
File "D:\Software\anaconda3\envs\py36\lib\site-packages\pykinect2\PyKinectV2.py", line 2216, in
assert sizeof(tagSTATSTG) == 72, sizeof(tagSTATSTG)
AssertionError: 80

Kinect restart over and over while trying to acces point cloud of the body.

Hi,
First, thanks a lot for this usefull code.
The feature I need the most is to extract a pointcloud of the body and save it. Unfortunately, this is the only one that does not work more than 5sec. Everything is starting, I can play with the taskbars, and then if I try to show the point cloud of the body, it last a few seconds, then the windows turns black and the kinect start to reboot over and over.

I joined a video so you can check it yourself. I don't know if you have any idea on how to solve this ? Or any advice on how to save on a file the body of an user ? The lack of documentation on the pykinect2 library is making this task really hard for me.
Thank you in advance.

video-1618327101.mp4

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.