Computer Vision with Arduino: Lecture Summary

Jul 11, 2024

Computer Vision with Arduino: Lecture Summary

Course Introduction

  • Learn to create real-world computer vision applications using Arduino.
  • Start with basics and move to advanced projects:
    • Lab gesture control
    • PID face tracking
    • Angle finder
    • Hand gesture control
    • Color sorter with conveyor belts
  • Aim: Understand fundamentals and gain enough experience to build your own projects.
  • Course includes a clear pathway from basics to advanced with many examples.
  • Course available on CV Zone platform.

Understanding Arduino

  1. Example: Automated Headlights in Smart Car

    • Components Needed:
      • Headlight (output)
      • Light sensor (ambient light sensor as input)
      • Microcontroller Unit (MCU) to process input and output
    • MCU – the brain of the system, processes small amounts of info quickly.
  2. Arduino Boards

    • Arduino Uno: Commonly used, 14 digital pins, 6 analog pins.
    • Arduino Mega: Larger capacity, 54 digital pins, 16 analog pins.
    • Arduino does not produce microcontrollers, but microcontroller boards with added features.
  3. Arduino Software

    • Simplifies programming process.
    • High-level language reducing intricate coding.
    • Programs are uploaded via USB and run continually with power input.

Components and Signals

  1. Arduino Uno Components

    • MCU
    • USB connection
    • Power jack for external batteries
    • Reset button
    • Pins: 14 digital, 6 analog, power pins (5V, ground)
  2. Digital vs Analog Pins

    • Digital: On/Off (0 or 1). Example: Controlling a fan, LED light.
    • Analog: Range of values (e.g., 0-255 for 8-bit value). Example: Controlling fan speed.
  3. Signal Values and Bit Depth

    • Analog input: 10-bit (0-1023)
    • Analog output: 8-bit (0-255)
    • Compare bit values (example: phone storage).
  4. Examples of Input/Output Devices

    • Distance sensor (analog input)
    • Push button (digital input)
    • Motor (analog output)
    • LED (digital output)

Practical Project Examples and Connections

  1. Connecting Components to Arduino

    • Use jumper wires (male to female, male to male, female to female).
    • Analog and digital pin connections: Analog pins mostly for analog input.
  2. Breadboard Basics

    • Breadboard for connections: power pins (vertical) and component pins (horizontal).
    • Use of resistors to prevent burning out LEDs.
    • Connecting an LED: Positive pin to digital pin, negative pin to ground.
  3. Arduino Coding Basics

    • Code structure: Initializations, setup (runs once), loop (runs repeatedly).
    • PinMode for input/output definition.
    • DigitalWrite and delay functions to control components.
    • Using variables for easier pin management.
  4. Pulse Width Modulation (PWM)

    • Control analog output like motor speed without changing power supply.
    • Explain duty cycle (percentage of on-time in a cycle).
    • Arduino: AnalogWrite for PWM.
    • Examples: LED dimming, motor speed control.

Advanced Projects Preview

  1. Face Detection with Arduino

    • Using MediaPipe and OpenCV for face detection.
    • Controlling an RGB LED based on face detection (red or green).
    • Python code to interface with Arduino using CV Zone library.
  2. Potentiometer Readings

    • Using potentiometers as variable resistors.
    • Reading analog values with Arduino (0-1023 range).
    • Sending potentiometer data to Python to display or use in projects.
  3. Creating Graphics in Python

    • Using OpenCV to create visual feedback on potentiometer readings.
    • Drawing ellipses and putting text on images.
    • Integrating with Arduino for real-time control and monitoring.

Installation and Setup

  1. Installing Arduino IDE and Libraries

    • Download and install from Arduino.cc.
    • Include required libraries like CV Zone and MediaPipe.
    • Setting up Arduino board and port in tools menu.
  2. Writing and Uploading Code

    • Example sketches and basic coding practices.
    • Testing connections with example codes.
    • Serial communication setup between Arduino and Python.

Conclusion

  • Get hands-on and experiment with different components and projects.
  • Create custom Arduino boards for specific projects.
  • Explore endless possibilities with Arduino and computer vision.