## **Lab 9** | Object Detection and Identification ### Design of Autonomous Systems ### CSCI 6907/4907 - Section 86 ### Prof. **Sibin Mohan** --- ## **Objectives** - Understand the concepts of **object detection and identification** - Learn how **computer vision and AI** enable machines to recognize objects - Install and configure a **Raspberry Pi camera** for object detection - Implement **stop sign and traffic light detection** using Raspberry Pi and OpenCV --- ## **1. Introduction to Object Detection and Identification** Object detection and identification is a fundamental task in **computer vision** that involves detecting objects in images or videos and assigning labels to them. --- this process consists of: - **Detection**: Locating objects within an image. - **Classification**: Assigning a label to each detected object --- By leveraging deep learning techniques such as **YOLO (You Only Look Once)** and **Faster R-CNN**, object detection has become highly efficient and accurate. --- #### **Applications:** - **Autonomous Vehicles**: Detecting pedestrians, traffic signs, and obstacles. - **Retail & Inventory**: Object tracking and product recognition. - **Healthcare**: Assisting in medical image diagnostics. --- ## **2. Installing a Raspberry Pi Camera for Object Detection** ### **2.a. Hardware Setup** To perform object detection, we need to install and configure the **Raspberry Pi Camera Module**. --- #### **Steps to Connect the Camera Module:** 1. **Ensure your Raspberry Pi is powered off.** 2. **Locate the camera port** on the Raspberry Pi board. 3. **Insert the ribbon cable** from the camera module into the port. 4. **Secure the connector** by pushing the plastic clip back into place. 5. **Power on the Raspberry Pi** to continue with the software configuration. --- ### **2.b. Software Configuration** 1. Open a terminal window and enter the following command: ```bash sudo raspi-config ``` 2. Navigate to **"Interface Options"** and select **"P1 Camera"**. 3. Choose **"Yes"** to enable the camera. 4. Reboot the Raspberry Pi for the changes to take effect. --- 5. Verify the camera is working: ```bash vcgencmd get_camera ``` - Output should be: `supported=1, detected=1` --- 6. Capture a test image: ```bash raspistill -o test_image.jpg ``` --- 7. Transfer the image to your computer using **SCP** or by running a local HTTP server on the Raspberry Pi: ```bash python3 -m http.server ``` Access it from a browser at: `http://
:8000` --- ## **3. Implementing Object Detection** ### **3.a. Installing Dependencies** ```bash sudo apt update sudo apt install -y libopencv-dev python3-opencv pip3 install opencv-python ``` --- Clone the required repository: ```bash git clone https://github.com/ubdussamad/DAS-utils.git ``` --- ### **3.b. Running Object Detection** Navigate to the **Lab_9_Object_Detection_and_Identification** directory and execute: ```bash python3 DetectStopSign_StopCar.py ``` ```bash python3 DetectTrafficLights.py ``` --- ## **4. Lab Assignment: Stop Sign and Traffic Light Detection** ### **4.a. Stop Sign Detection** 1. Run the stop sign detection script. 2. Display an image of a stop sign in front of the Raspberry Pi camera. 3. Record the detection results and system response. 4. Experiment with parameter adjustments to improve accuracy. 5. Document and submit the detection data and observations. --- ### **4.b. Traffic Light Detection** 1. Run the traffic light detection script. 2. Show a green or red light to the Raspberry Pi camera. 3. Observe and log system responses. 4. Adjust detection parameters if necessary. 5. Document and submit findings. --- ## **5. Summary** - Learned about **object detection** and its real-world applications. - Configured a **Raspberry Pi camera** for computer vision tasks. - Implemented **stop sign and traffic light detection** using OpenCV. - Understood how to **fine-tune parameters** to enhance object detection accuracy.