Skip to content

ctrlxharsh/object_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Object Tracker - Pose Estimation with PnP and SIFT

This project estimates the 6DoF (position + orientation) pose of a planar object (e.g., gate) using a webcam or RealSense camera. It uses SIFT feature matching, homography, and Perspective-n-Point (PnP) pose estimation.


🧩 Modules Overview

πŸ“· tracker.py - Real-Time Object Pose Estimation

  • Allows user to select 4 corners of a planar object (e.g., gate).
  • Extracts SIFT keypoints from selected region.
  • Matches keypoints in real-time against webcam input.
  • Uses Homography + PnP to compute:
    • Rotation (Yaw, Pitch, Roll)
    • Translation (Tx, Ty, Tz)
  • Displays:
    • Projected object outline on current frame.
    • Orientation and position (in cm) on screen.
    • Matched features between frames.

πŸ“Œ Uses:

  • cv2.solvePnP with IPPE method for stable results.
  • Calibrated camera matrix (for RealSense or webcam).
  • Draws matches and overlay info live.

πŸ› οΈ function.py - Utility Functions

Contains helper functions:

  • rotational_to_euler(R): Converts 3x3 rotation matrix to Euler angles.
  • draw_quadrilateral(): Overlays selected corners as a quadrilateral.
  • get_four_points(): GUI-based point selector for user to click 4 corners.

πŸ§ͺ camera_calibration/zhang.py - Camera Calibration (Zhang's Method)

  • Detects checkerboard corners in calibration images.
  • Uses OpenCV's calibrateCamera() to compute:
    • Intrinsic matrix (Camera Matrix)
    • Distortion coefficients
    • Rotation & translation vectors for each image.
  • Outputs all matrices and vectors.

πŸ“ Note:

  • You can use the camera_calibration/capture_img_for_zhang.py to capture checkerboard images.

πŸ“‚ Folder Structure

πŸ“‚ object_tracker/
β”œβ”€β”€ tracker.py
β”œβ”€β”€ function.py
β”œβ”€β”€ README.md
β”œβ”€β”€ camera_calibration/
β”‚   β”œβ”€β”€ zhang.py
β”‚   └── capture_img_for_zhang.py

βœ… Requirements

  • Python 3.x
  • OpenCV (cv2)
  • NumPy
  • PyRealSense2 (optional for RealSense camera)

Install dependencies:

pip install opencv-python numpy pyrealsense2

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages