WALL-E Version 1.0
The "WALL-E" Project is a ME 507 quarter term project inspired to recreate the robot WALL-E. The WALL-E robot is a fully 3D printed robot with modified components in order to fit the needs of the chosen peripherals and electronics. WALL-E contains a custom made PCB which is housed in the main body of WALL-E. WALL-E's peripherals and components include 2 pololu Romi Motors with encoders, 4 MG90s servos, BNO055 IMU, and a OV2640 ArduCam camera. The objective of WALL-E is to scan the surrounding area for the closest object to it. Once that object is detected, WALL-E drives up to the object, attempts to pick up or hold the object and detect the color of the object.
Loading...
Searching...
No Matches
camera.h
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
19#ifndef INC_CAMERA_H_
20#define INC_CAMERA_H_
21
22#include "stm32f4xx_hal.h"
23#include <cstring>
24#include <cstdio>
25
26#define BLUE_THRESHOLD 200 // Adjust based on lighting and distance
27#define STEP 4 // Read every 2 bytes = 1 pixel, STEP=4 = every other pixel
28#define ROW_WIDTH 160
29#define SAMPLE_WIDTH (ROW_WIDTH / 2) // Because we skip every other pixel
30
40
45public:
46 OV2640Camera(I2C_HandleTypeDef* i2c, SPI_HandleTypeDef* spi, GPIO_TypeDef* cs_port, uint16_t cs_pin);
47
48 bool initialize();
49 bool captureFrame();
50 void printCaptureReport(UART_HandleTypeDef* huart);
51 void printBlueDetectionMap(UART_HandleTypeDef* huart);
54
55private:
59 I2C_HandleTypeDef* i2c_;
60
64 SPI_HandleTypeDef* spi_;
65
69 GPIO_TypeDef* cs_port_;
70
74 uint16_t cs_pin_;
75
79 static constexpr size_t FRAME_SIZE = 160 * 120 * 2; // QQVGA RGB565
80
85
86 void writeRegister(uint8_t reg, uint8_t val);
87 void csHigh();
88 void csLow();
89};
90
91
92
93#endif /* INC_CAMERA_H_ */
DominantColor
Enumeration for Color Detection.
Definition camera.h:34
@ COLOR_BLUE
Definition camera.h:38
@ COLOR_RED
Definition camera.h:36
@ COLOR_UNKNOWN
Definition camera.h:35
@ COLOR_GREEN
Definition camera.h:37
SPI_HandleTypeDef * spi_
Definition camera.h:64
static constexpr size_t FRAME_SIZE
Definition camera.h:79
bool captureFrame()
Function captures a single frame from the camera storing the RGB and data from the photo for parsing ...
Definition camera.cpp:81
bool initialize()
Function initializes the camera for photo capturing by using the OV2640 register and values list in t...
Definition camera.cpp:66
void csHigh()
Function sets the Chip Select GPIO pin high for SPI Communication.
Definition camera.cpp:38
DominantColor analyzeColor()
Function is the analysis/parsing function to analyze the colors in frame by pixels.
Definition camera.cpp:172
DominantColor analyzeColorCenter()
Function is the analysis/parsing function focusing solely on the pixels closer to the center of the C...
Definition camera.cpp:210
uint16_t cs_pin_
Definition camera.h:74
I2C_HandleTypeDef * i2c_
Definition camera.h:59
void printCaptureReport(UART_HandleTypeDef *huart)
Function is designed to parse the photo data captured by the camera. The data is the transmitted via ...
Definition camera.cpp:114
OV2640Camera(I2C_HandleTypeDef *i2c, SPI_HandleTypeDef *spi, GPIO_TypeDef *cs_port, uint16_t cs_pin)
Constructor function for the Camera Class.
Definition camera.cpp:29
void printBlueDetectionMap(UART_HandleTypeDef *huart)
Function is designed to parse the photo data captured by the camera focusing on blue color pixels and...
Definition camera.cpp:258
void csLow()
Function sets the Chip Select GPIO pin low for SPI Communication.
Definition camera.cpp:46
uint8_t frame_buffer_[FRAME_SIZE]
Definition camera.h:84
void writeRegister(uint8_t reg, uint8_t val)
Function takes in a register and value utilizing I2C to write to the desired register.
Definition camera.cpp:57
GPIO_TypeDef * cs_port_
Definition camera.h:69