211 lines
2.7 KiB
C
211 lines
2.7 KiB
C
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "esp_camera.h"
|
|
|
|
#include "esp_err.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct httpd_req;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
VISION_METHOD_CONTOUR = 0,
|
|
|
|
VISION_METHOD_RECT,
|
|
|
|
} vision_method_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
bool found;
|
|
|
|
float cx;
|
|
|
|
float cy;
|
|
|
|
float radius;
|
|
|
|
int area;
|
|
|
|
uint32_t coarse_us;
|
|
|
|
uint32_t refine_us;
|
|
|
|
uint32_t morph_us;
|
|
|
|
uint32_t mask_us;
|
|
|
|
uint32_t jpeg_us;
|
|
|
|
uint32_t detect_us;
|
|
|
|
uint32_t total_us;
|
|
|
|
} vision_stats_t;
|
|
|
|
|
|
|
|
void vision_init(void);
|
|
|
|
|
|
|
|
bool vision_local_enabled(void);
|
|
|
|
bool vision_show_mask(void);
|
|
|
|
vision_method_t vision_get_method(void);
|
|
|
|
|
|
|
|
void vision_set_local_enabled(bool enabled);
|
|
|
|
void vision_set_show_mask(bool show);
|
|
|
|
void vision_set_method(vision_method_t method);
|
|
|
|
|
|
|
|
void vision_set_coarse_stride(int stride);
|
|
|
|
void vision_set_min_area(int area);
|
|
|
|
void vision_set_mask_full(bool full);
|
|
|
|
void vision_set_morph_roi(bool enable);
|
|
|
|
|
|
|
|
int vision_get_coarse_stride(void);
|
|
|
|
int vision_get_min_area(void);
|
|
|
|
bool vision_get_mask_full(void);
|
|
|
|
bool vision_get_morph_roi(void);
|
|
|
|
|
|
|
|
void vision_get_stats(vision_stats_t *out);
|
|
|
|
|
|
|
|
/* OpenCV-style H: 0-179, S/V: 0-255 */
|
|
|
|
void vision_set_hsv(uint8_t h, uint8_t s, uint8_t v);
|
|
|
|
void vision_get_hsv(uint8_t *h, uint8_t *s, uint8_t *v);
|
|
|
|
void vision_set_tolerance(uint8_t h_tol, uint8_t s_tol, uint8_t v_tol);
|
|
|
|
void vision_get_tolerance(uint8_t *h_tol, uint8_t *s_tol, uint8_t *v_tol);
|
|
|
|
|
|
|
|
void vision_set_color_bgr(uint8_t b, uint8_t g, uint8_t r);
|
|
|
|
|
|
|
|
esp_err_t vision_sample_hsv_from_frame(const camera_fb_t *fb, int x, int y);
|
|
|
|
|
|
|
|
void vision_format_ack(char *ack_buf, size_t ack_len);
|
|
|
|
|
|
|
|
esp_err_t vision_handle_update(
|
|
|
|
bool has_local, bool local,
|
|
|
|
bool has_show_mask, bool show_mask,
|
|
|
|
bool has_method, const char *method,
|
|
|
|
bool has_h, int h,
|
|
|
|
bool has_s, int s,
|
|
|
|
bool has_v, int v,
|
|
|
|
bool has_h_tol, int h_tol,
|
|
|
|
bool has_s_tol, int s_tol,
|
|
|
|
bool has_v_tol, int v_tol,
|
|
|
|
bool has_b, int b,
|
|
|
|
bool has_g, int g,
|
|
|
|
bool has_r, int r,
|
|
|
|
bool has_coarse_stride, int coarse_stride,
|
|
|
|
bool has_min_area, int min_area,
|
|
|
|
bool has_mask_full, bool mask_full,
|
|
|
|
bool has_morph_roi, bool morph_roi,
|
|
|
|
char *ack_buf, size_t ack_len);
|
|
|
|
|
|
|
|
esp_err_t vision_encode_capture_jpeg(
|
|
|
|
const camera_fb_t *fb,
|
|
|
|
int quality,
|
|
|
|
uint8_t **jpg_buf,
|
|
|
|
size_t *jpg_len,
|
|
|
|
vision_stats_t *stats_out);
|
|
|
|
|
|
|
|
esp_err_t vision_detect_on_frame(const camera_fb_t *fb, vision_stats_t *stats_out);
|
|
|
|
|
|
|
|
size_t vision_format_stats_json(const vision_stats_t *stats, char *buf, size_t len);
|
|
|
|
|
|
|
|
void vision_add_capture_headers(struct httpd_req *req, const vision_stats_t *stats);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|