Skip to main content

A package for calibrating standard webcams to enable 3d motion tracking

Project description

Introduction

Quick Start

Key Features

Limitations


About

Pyxy3D (pixie-3d) is an open-source Python package for converting 2D (x,y) point data to 3D estimates. It is intended to serve as the calibration and triangulation workhorse of a low-cost DIY motion capture studio. It's core functionality includes:

  • the estimation of intrinsic (focal length/optical center/distortion) and extrinsic (rotation and translation) camera parameters via a GUI
  • API for slotting various tracking solutions into the data pipeline
  • triangulation of tracked points

The package comes included with a sample tracker using Google's Mediapipe which illustrates how to use the tracker API. The camera management backend allows for recording of synchronized frames from connected webcams, though the frame rate/resolution/number of cameras will be limited by the bandwidth of the current system.

Quick_Demo

Quick Start

From a terminal (the code below is using Powershell), do the following:

  1. Create a new project folder
mkdir pyxy3d_demo
  1. Navigate into that directory
cd pyxy3d_demo
  1. Create a virtual environment with Python 3.10 or later:
C:\Python310\python.exe -m venv .venv
  1. Activate the environment
.\.venv\Scripts\activate
  1. Install Pyxy3D
pip install pyxy3d

Note that this will also install dependencies into the virtual environment, so complete download and installation may take several minutes..

  1. Launch Pyxy3D
pyxy3d

At this point, an application window should launch. It may take several seconds for this to load. Refer to the Quick Start Video Walkthrough to see how to calibrate, record and process data

Key Features

The project leans heavily upon OpenCV, SciPy, and PyQt to provide the following key features:

  • User-friendly graphical user interface (GUI)
  • Easy creation and modification of the charuco calibration board
  • Both extrinsic and intrinsic camera parameters are estimated
  • Optional double-sided charuco board for better positional estimates of cameras placed opposite each other
  • Visual feedback during the calibration process
  • World origin setting using the calibration board
  • Fast convergence during bundle adjustment due to parameter initializations based on daisy-chained stereopairs of cameras
  • Recording of synchronized frames from connected webcams for post-processing
  • Tracker API for future extensibility with included sample implementation using Mediapipe
  • Triangulation of tracked landmarks
  • Visualization of triangulated points for quick confirmation of output quality
  • Currently exporting to .csv and .trc file formats

Limitations

Please note that the system currently has the following limitations:

  • MediaPipe is only configured to run on Windows
    • while the camera calibration will likely work on other systems, the included sample markerless tracking will not (currently)
  • It does not support anything other than standard webcams at the moment
  • The frame capture backend presents a primary bottleneck that will limit the number of cameras/resolution/frame rates that can be used, which ultimately limits the size and precision of the capture volume.
  • Data export is currently limited to .csv, and .trc files. Use in 3D animation tools like Blender, which require character rigging, will require additional processing.

Reporting Issues and Requesting Features

To report a bug or request a feature, please open an issue. Please keep in mind that this is an open-source project supported by volunteer effort, so your patience is appreciated.

General Questions and Conversation

Post any questions in the Discussions section of the repo.

Acknowledgments

This project was inspired by FreeMoCap (FMC), which is spearheaded by Jon Matthis, PhD of the HuMoN Research Lab. The FMC calibration and triangulation system is built upon Anipose, created by Lili Karushchek, PhD. Several lines of FMC/Anipose code are used in the triangulation methods of Pyxy3D. I'm grateful to Dr. Matthis for his time developing FreeMoCap, discussing it with me, pointing out important code considerations, and providing a great deal of information regarding open-source project management.

I began my python programming journey in August 2022. Hoping to understand the Anipose code, I started learning the basics of OpenCV. Murtaza Hassan's computer vision course rapidly got me up to speed on performing basic frame reading and parsing of Mediapipe data. To get a grounding in the fundamentals of camera calibration and triangulation I followed the excellent blog posts of Temuge Batpurev. At the conclusion of those tutorials I decided to try to "roll my own" calibration and triangulation system as a learning exercise (which slowly turned into this repository). Videos from GetIntoGameDev helped me through projection transforms. The excellent YouTube lectures of Cyrill Stachniss provided a foundation for understanding the bundle adjustment process, and the SciPy Cookbook held my hand when implementing the code for this optimization. Debugging the daisy-chain approach to parameter initialization would not have been possible without the highly usable 3D visualization features of PyQtGraph.

ArjanCodes has been an excellent resource for Python knowledge, as has Corey Schafer whose videos on multithreading were invaluable at tackling early technical hurdles related to concurrent frame reading.

While Pyxy3D is not a fork of any pre-existing project, it would not exist without the considerable previous work of many people, and I'm grateful to them all.

License

Pyxy3D is licensed under AGPL-3.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxy3d-0.1.3.tar.gz (4.0 MB view hashes)

Uploaded Source

Built Distribution

pyxy3d-0.1.3-py3-none-any.whl (847.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page