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.
- 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.solvePnPwith IPPE method for stable results.- Calibrated camera matrix (for RealSense or webcam).
- Draws matches and overlay info live.
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.
- 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.
π object_tracker/
βββ tracker.py
βββ function.py
βββ README.md
βββ camera_calibration/
β βββ zhang.py
β βββ capture_img_for_zhang.py
- Python 3.x
- OpenCV (
cv2) - NumPy
- PyRealSense2 (optional for RealSense camera)
Install dependencies:
pip install opencv-python numpy pyrealsense2