KangarooBot/Spring/2021
ESP32Cam QR Code Detection & Edge Detection
Author/s: Andre Troncoso
Table of Contents
Introduction
The ESP32-cam is a microcontroller that has a OV2640 camera that is built-in. It has 4 MB of PSRAM which is great for a small computer vision application. Essentially, the KangarooBot utilized the ESP32-cam for scanning of QR codes and the detection of the maze side walls. Additionally, the error of the robot between the left and right wall is calculated by the ESP32-cam and sent to the robot using a UART protocol set at 9600 baud rate and 8N1 serial format. This error is then translated to the control system of the motors where the appropriate speeds are applied to deter the robot from collision.
QR Code Detection
Figure 1 – Card Prototype
Edge Detection
Figure 1 – Vision Frame
Description: This figure refers to the gray scale frame indicated by the instructor.
Figure 2 – Error Calculation
Error Calculation Code
Description: The figure shows the side wall error calculation using the difference of two horizontal pixel distances. The error is later fed into a P-controller for motor control.
Motor Control
Conclusion
The most difficult task for this part of the project is testing/calibrating the camera sensor. Moreover, finding the correct grayscale threshold values that match with the green hue walls of the maze was challenging. The IDE that made the integration of several different API possible is VSCode with the PlatformIO extension.
References/Resources
- ESP32QRCodeReader: https://github.com/alvarowolfx
- Introduction to Edge Detection | What is Edge Detection: https://www.mygreatlearning.com/blog/introduction-to-edge-detection/
- Professor Hill Sketch of an Error Calculation
- Proportional-only Control: https://control.com/textbook/closed-loop-control/proportional-only-control/