Quellcode adaptiert #11
Labels
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: BKRheine/ETSmarthome#11
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Quellcode template
https://www.viralsciencecreativity.com/post/esp32-cam-face-detection-door-lock-system
#include "esp_camera.h"
#include <WiFi.h>
#include <WebServer.h>
// WLAN-Konfiguration
const char* ssid = "IHR_SSID";
const char* password = "IHR_PASSWORT";
// Kamera-Konfiguration für das AI-Thinker Modell
#define CAMERA_MODEL_AI_THINKER
#include "camera_pins.h"
WebServer server(80);
void handleRoot() {
camera_fb_t * fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Kameraaufnahme fehlgeschlagen");
return;
}
server.sendHeader("Connection", "close");
server.send(200, "image/jpeg", "", fb->len);
server.sendContent_P((char *)fb->buf, fb->len);
esp_camera_fb_return(fb);
}
void startCameraServer() {
server.on("/", HTTP_GET, handleRoot);
server.begin();
}
void setup() {
Serial.begin(115200);
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_JPEG;
config.frame_size = FRAMESIZE_UXGA;
config.jpeg_quality = 12;
config.fb_count = 2;
// Kamera-Modul initialisieren
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Kamera-Initialisierung fehlgeschlagen mit Fehler 0x%x", err);
return;
}
// WiFi verbinden
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("WiFi verbunden. IP-Adresse: ");
Serial.println(WiFi.localIP());
// Webserver starten
startCameraServer();
}
void loop() {
server.handleClient();
}
#include "esp_camera.h"
#include <WiFi.h>
// WLAN-Konfiguration
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
// Kamera-Konfiguration für das AI-Thinker Modell
#define CAMERA_MODEL_AI_THINKER
#include "camera_pins.h"
void startCameraServer();
void setup() {
Serial.begin(115200);
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_JPEG;
config.frame_size = FRAMESIZE_UXGA;
config.jpeg_quality = 12;
config.fb_count = 1;
// Init with face detection enabled
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
sensor_t * s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_QVGA); // smaller frame size for faster processing
s->set_quality(s, 10); // lower quality for faster processing
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
startCameraServer();
}
void loop() {
// Handle camera stream
}
// Implement startCameraServer with endpoints that can handle detection