Skip to content

ThathsaraDassanayake/Depth-Camera-Using-Computer-Vision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Depth-Camera Using Computer Vision

image The project focuses on designing a Depth Camera using computer vision techniques, object detection, and feature matching to create a portable and cost-effective solution for accurate depth measurement. The key aspects of the project include:

  1. Hardware Design:
  • The project involved selecting and configuring components such as a stepper motor, microcontroller (ATmega328P), and a USB Type-C adapter.
  • A 3D-printed cylindrical enclosure was designed to house the components, ensuring structural integrity and ease of assembly.
  1. Software Integration:
  • Algorithms were developed for image capturing, camera calibration, object detection using YOLOv8, feature detection using SIFT algorithm, feature matchig using BFMatcher with NORM L2 norm., and depth calculation.
  • The camera calibration process involved both mono and stereo calibration, providing the necessary parameters for accurate depth measurement.
  1. System Optimization:
  • The project included power management strategies and optimization of overall system performance.
  • Integration of the stepper motor allowed the camera to capture images from multiple angles, aiding in depth calculation.
  1. Testing and Evaluation:
  • Extensive testing was conducted to ensure the accuracy and robustness of the system, including calibration, object detection, feature matching, and motor control.
  • The YOLOv8 model was custom-trained to improve object detection accuracy, a critical component of the system.
  1. Group Collaboration:
  • The project was a team effort where each member contributed their expertise to different aspects of the design, implementation, and testing.
  • Team members collaborated on problem-solving, particularly in areas like camera calibration, motor integration, and algorithm optimization.
Final.Working.Depth.Camera.mp4

Software Integration and Programming Analysis

This section provides a comprehensive overview of the programming aspects of our depth camera project, detailing the implementation and testing processes involved in capturing images, calibrating cameras, detecting objects, matching features, and calculating depth.

  1. Capturing the Image
  • Implement a code to capture a photo from the USB webcam when the ’S’ key is pressed.
  • Used OpenCV to interact with the USB webcam and capture images. The code allows capturing images by pressing the ’S’ key and exits on pressing ’Q’ or interrupt.

Image Capture Code

  1. Camera Calibration
  • Calibrated the camera to obtain intrinsic and extrinsic parameters.
  • Mono Camera Calibration
    • Used a chessboard pattern for calibration.
    • Detected chessboard corners in multiple images.
    • Computed the camera matrix and distortion coefficients
  • Stereo Camera Calibration
    • Calibrated two cameras simultaneously to obtain the rotation and translation matrices between them.

Camera Calibration Code

  • Results
    • The calibration process provided the camera matrix and distortion coefficients for each camera.
    • The stereo calibration provided the rotation and translation matrices between the two cameras.

image

  1. Object Detection with YOLOv8
  • Implemented object detection using the YOLOv8 model, custom-trained to detect specific objects.

  • Model Training

    • Used a custom dataset created using RoboFlow.
    • Trained the YOLOv8 model on this dataset, adjusting parameters like learning rate and batch size for optimal performance.
  • Object Detection

    • Implemented the object detection code to output bounding boxes

Object Detection Code

  • Results image
  1. Feature Matching
  • Feature Detection Algorithms
    • Experimented with SIFT, ORB, and SURF for feature detection
    • Chose SIFT for its robustness and accuracy.
  • Feature Matching
    • Implemented feature matching using the BFMatcher with NORM L2 norm.

Feature Matching Code

  • Results image
  1. Depth Calculation
  • Calculated the depth of points using triangulation based on the matched features and camera parameters.
  • It was done using triangulation
    • Used the camera matrix, rotation matrix, and translation matrix to triangulate matched features and calculate depth.

Depth Calculation Code

  1. Stepper Motor Integration Using C++
  • Rotate the camera to two positions using a stepper motor controlled by an ATmega microcontroller.
  • Motor Control
    • Implemented motor control to rotate the camera.
    • Used an ATmega microcontroller to control the stepper motor.

StepperMotor

  • Results
    • Successfully rotated the camera to capture two images from different positions.

Circuit Analysis

  1. Power supply
  • Our power supply is a fairly simple setup. As the input, we use a 12v power supply (provided through a power-regulated power supply) and then inside the device by using a L7812 voltage regulator we also make our own 5v power supply inside the circuit. Then we use this to power up the atmega328 chip and servo motor driver. The primary components include a voltage regulator, capacitors for filtering, and connectors for input and output.

image

  1. Stepper motor driver carrier The stepper motor driver drives the stepper motor, converting digital signals from the microcontroller into precise movements. It features the A4988 stepper motor driver, which controls the current flow to the motor windings, enabling accurate positioning

image

  1. Microcontroller Unit This module incorporates the ATmega328P microcontroller, which serves as the central processing unit for the circuit. It receives power from the power supply, controls the motor driver, and interfaces with other peripherals. The tactile switch SW2 could be used to start or stop the motor, change modes of operation, or initiate specific functions in the program running on the microcontroller. Here, we use it as a reset button. Other key components include the ATmega328P, crystal oscillator for clock generation, and decoupling capacitors.

image

  1. Type C adapter The Type C adapter circuit facilitates communication between the microcontroller and external devices through a USB Type C connector. It includes an RS232 transceiver for serial communication, capacitors for stabilization, and connectors for the USB interface. In this adapter circuit, the CH340 serves as an interface for serial communication. It converts USB signals from a host device (such as a computer) into UART signals that the microcontroller can understand and vice versa.

image

PCB Design

Using the above schematics, we designed a PCB that will fit to be implemented as a rotating sensor. We carefully chose the dimensions and shape for the PCB. We also carefully planned the power supply method for the PCB. Since the stepper motor driver needs a 12V power supply, we designed the power module and the paths to be suitable to carry the needed voltage. The enclosure will have a barrel jack, and from that, the power will be supplied to the designated headers on the PCB. We also implemented the USB-C port and its connection such that we can control the rotation of the stepper motor from our PC. We placed mounting holes on the PCB to support the structure during movements.

image image image

Enclosure analysis

All design of the enclosure was done by SolidWorks.

image image image image image image

Complete Integrated Design

The complete 3D printed design integrates the main body, rotating component, and back lid seam�lessly. The assembly clearly shows the PCB and stepper motor, highlighting their well-considered placement and integration within the enclosure. This comprehensive design ensures that all com�ponents work together cohesively, providing a robust and efficient solution for the depth camera system.

image

About

Measuring depth using Computer Vision techniques

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors