CI / Lint e auditorias (push) Successful in 1m10s
CI / Trivy (dependências e segredos) (push) Successful in 12s
CI / Imagem Docker (linux/arm64) (push) Successful in 2m39s
Release / Plano (reaproveitar a imagem?) (push) Successful in 6s
Release / ci (push) Skipped
Release / Publica a imagem (linux/arm64) (push) Successful in 18s
Release / Cria a release no Gitea (push) Successful in 5s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
72 lines
2.1 KiB
C
72 lines
2.1 KiB
C
#include "esp_camera.h"
|
|
#include "fd_forward.h" // Face Detection
|
|
#include "fr_forward.h" // Face Recognition
|
|
#include "human_face_detect_msr01.hpp"
|
|
#include "human_face_detect_mnp01.hpp"
|
|
|
|
#define CAMERA_MODEL_AI_THINKER // 或你的开发板型号
|
|
|
|
#include "camera_pins.h"
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
Serial.setDebugOutput(true);
|
|
Serial.println("Starting camera...");
|
|
|
|
camera_config_t config;
|
|
config.ledc_channel = LEDC_CHANNEL_0;
|
|
config.ledc_timer = LEDC_TIMER_0;
|
|
config.pin_d0 = Y2_GPIO_NUM;
|
|
config.pin_d1 = Y3_GPIO_NUM;
|
|
config.pin_d2 = Y4_GPIO_NUM;
|
|
config.pin_d3 = Y5_GPIO_NUM;
|
|
config.pin_d4 = Y6_GPIO_NUM;
|
|
config.pin_d5 = Y7_GPIO_NUM;
|
|
config.pin_d6 = Y8_GPIO_NUM;
|
|
config.pin_d7 = Y9_GPIO_NUM;
|
|
config.pin_xclk = XCLK_GPIO_NUM;
|
|
config.pin_pclk = PCLK_GPIO_NUM;
|
|
config.pin_vsync = VSYNC_GPIO_NUM;
|
|
config.pin_href = HREF_GPIO_NUM;
|
|
config.pin_sscb_sda = SIOD_GPIO_NUM;
|
|
config.pin_sscb_scl = SIOC_GPIO_NUM;
|
|
config.pin_pwdn = PWDN_GPIO_NUM;
|
|
config.pin_reset = RESET_GPIO_NUM;
|
|
config.xclk_freq_hz = 20000000;
|
|
config.pixel_format = PIXFORMAT_RGB565;
|
|
config.frame_size = FRAMESIZE_QVGA;
|
|
config.fb_count = 1;
|
|
|
|
if (esp_camera_init(&config) != ESP_OK) {
|
|
Serial.println("Failed to start camera!");
|
|
return;
|
|
}
|
|
|
|
Serial.println("Camera initialized!");
|
|
}
|
|
|
|
void loop() {
|
|
camera_fb_t *fb = esp_camera_fb_get();
|
|
if (!fb) {
|
|
Serial.println("Failed to capture image!");
|
|
return;
|
|
}
|
|
|
|
// 检测图像中的人脸
|
|
box_array_t *faces = face_detect_msr01(fb->buf, fb->width, fb->height, fb->format);
|
|
if (faces) {
|
|
Serial.printf("Faces detected: %d\n", faces->len);
|
|
for (int i = 0; i < faces->len; i++) {
|
|
box_t *box = &faces->box[i];
|
|
Serial.printf("Face %d - x:%d y:%d w:%d h:%d\n", i, box->box_p[0], box->box_p[1],
|
|
box->box_p[2] - box->box_p[0], box->box_p[3] - box->box_p[1]);
|
|
}
|
|
dl_lib_free(faces);
|
|
} else {
|
|
Serial.println("No face detected.");
|
|
}
|
|
|
|
esp_camera_fb_return(fb);
|
|
delay(1000);
|
|
}
|