Quellcode adaptiert #11

Closed
opened 2024-04-09 07:35:17 +00:00 by niggo · 3 comments
Owner
No description provided.
niggo added this to the MS2 milestone 2024-04-09 07:35:17 +00:00
niggo added this to the Projekt Plannung project 2024-04-09 07:39:13 +00:00
Author
Owner
Quellcode template https://www.viralsciencecreativity.com/post/esp32-cam-face-detection-door-lock-system
niggo closed this issue 2024-04-23 06:31:33 +00:00
Collaborator

#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> #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(); }
Collaborator

#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

#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
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: BKRheine/ETSmarthome#11
No description provided.