Skip to content

Python only Structure-from-Motion and 3D Computer Vision (with SOTA models)

Notifications You must be signed in to change notification settings

sithu31296/pysfm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Only 3D Computer Vision

teaser

Supported Features

WARNING: Some features or methods may be missing for now. They will be implemented slowly. The codebase may have significant changes.

A lot of 3D computer vision tasks will be supported with a simple inference script with SOTA models. However, the following tasks will not be supported:

  • Object-Level 3D Tasks (Classification, Detection, Segmentation)
  • Scene Flow & Motion (Optical Flow)
  • Learning-based SfM (DUSt3R, MASt3R, VGGSfM, etc.) (may be later)
  • Visual SLAM (may be later)
  • Absolute Pose Regression
  • Scene Coordinate Regression

Installation

bash install.sh

Monocular Depth Estimation

The goal is to get the pixel-wise depth values (and bonus: focal length).

Supported Metric-Depth Models:

Supported Relative-Depth Models:

Run this command to get the estimated depth and focal length (if not exist in metadata):

python scripts/estimate_depth.py

monodepth_results

Notes: For outdoor images, mask the sky.

Stereo Depth Estimation

The goal is to get the pixel-wise depth values given stereo images. Usually the depth values are in metric-scale and accurate compared to monocular depth methods.

Supported Models:

Notes: For FoundationStereo, download the pre-trained model from official repo and put them in checkpoints/ folder.

Run this command to get the estimated depth for the left image:

python scripts/estimate_stereo_depth.py
Ground-truth Estimated
gt_stereo est_stereo

Image from MiddleBury 2005 Dataset.

Global Image Retrieval

The goal is to search for the most similar image from a database with respect to the given image.

Supported Models:

Local Feature Detection and Matching

Given two images, to find the matches (pixel locations) based on features correspondences.

Supported Feature Detectors/Matching Models:

Run this command to match the two images:

python scripts/match_views.py
Matched Keypoints Matched 3D Effect
matched_kpts matched_3d

Notes: You can also specify the number of matches for dense methods.

Pose Estimation (Relative/Absolute)

Given 2D correspondences, to find the relative or absolute pose between two images.

Relative Pose Estimation

  • Up to an unknown scale
  • 2D-2D Correspondences
  • Pose relative to an another image

Absolute Pose Estimation or Camera Relocalization

  • Up to a real scale
  • 2D-3D Correspondences
  • Pose relative to a world/map

With relative pose from 2D-2D correspondences, you can only recover the direction of motion (translation vector is only correct up to scale), but not how far you moved. So the resulting pose is in an arbitary scale.

Pose Solvers:

  • 2D-2D Correspondences
    • Essential Matrix (if you know the camera intrinsics)
    • Fundamental Matrix (if you don't know the camera intrinsics)
    • Homography
  • 2D-3D Correspondences
    • PnP (if you know the camera intrinsics and depth of the first image)
  • 3D-3D Corrspondences
    • Procrustes (if you know the camera intrinsics and depth of both images)

No matter which algorithm you choose, the initial correspondences will be pixel correspondences.

Run this command to match the two images:

python scripts/find_pose.py
Relative Pose Estimation Absolute Pose Estimation
relative_pose absolute_pose

Point Cloud Registration

Rigid Registration

Given two point clouds, find the global transformation and align them.

Global Registration:

  • Procrustes or Kabsch

Local Registration:

  • ICP

Feature-based Registration:

Run this command to align the point clouds:

python scripts/align_pcd.py
Gloabl Registration Local Registration
before_regist after_regist

Before registration/alignment, the two point clouds are in their own coordinate system.

Non-Rigid or Deformable Registration

Given two point clouds, find the transformation of each point and align them.

Supported Methods:

  • CPD (TPAMI 2010)

Run this command to align the point clouds:

python scripts/align_pcd_non_rigid.py
Gloabl Registration Non-Rigid Registration
global_regist deform_regist

References

About

Python only Structure-from-Motion and 3D Computer Vision (with SOTA models)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published