Skip to content

Displays the undistorted IR images captured by a Leap Motion device and the RGB images captured by a webcam

License

Notifications You must be signed in to change notification settings

gruossomonica/LeapMotion_undistorted_image_visualizer

Repository files navigation

Leap Motion Undistorted Infrared Image Visualizer

This repo contains the source code of a visualizer built with Python 3.7.0 and OpenCV on Window 10. It is useful for displaying undistorted IR images captured by a Leap Motion device. A simple viewer for RGB images captured by a webcam is also provided.

GUI

Requirements

  • Wrapper of the Leap Motion SDK v3 for Python 3.7 (Windows), since it is available only for Python 2. The wrapper is available in the lib folder. If you need your wrapper for another version of Python or other OS, please follow this guide to built it.
  • Python 3.7.0
  • OpenCV (suggested 4.x)
  • NumPy
  • math
  • os
  • ctypes
  • threading

Usage and Info

Install all dependencies as indicated in the Requirements Section.

The main file is leap_camera_control.py. Run the following command to execute it:

python leap_camera_control.py

You can run the code in a virtual enviroment, e.g., venv, Anaconda or Miniconda.

Press q to stop execution and exit. Press s to save images in folders. The folder paths are set here.

Two threads starts: one is related to the Leap Motion controller and IR images acquisition, the other manages the webcam execution flow. The theard definition is provided in thread_definition.py. If you prefere to use listeners to manage the Leap Motion controller, please follow the example provided in leap_listener.py. There is an interesting discussion on using the listener on the Leap Motion developer guide.

A simple setting window is also defined using OpenCV. It can be used to change the gamma and contrast of the undistorted IR images. You can change the code in the ImageVisualizer class defined in image_utils.py to add more parameters to the settings window.

The image_utils.py file contains the image processing code. The distortion of the data acquired by the Leap Motion is corrected using bilinear interpolation. Other useful information about distortion maps can be found in the Leap Motion API documentation page. Examples of raw and undistorted images can be found in the images folder.

FAQ

Q: Why is the webcam preview not showing?

A: First, check the webcam is properly connected to your pc and is working. Then, try to change the device ID indicated in the code here. It is set to 0 by default.

Q: Why is the Leap Motion controller preview not showing?

A: Please, run the Leap Motion Visualizer to check your device is working properly. This can be found in the Leap Motion Control Panel (more info here). If it is working, make sure that the requirements are all met.

About

Displays the undistorted IR images captured by a Leap Motion device and the RGB images captured by a webcam

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages