У меня есть два esp, один — esp32, а другой — esp32s3_eye, у меня есть tft-дисплей, подключенный к esp32, и я хочу, чтобы камера с esp32s3_eye отправляла на экран живое видео с помощью espnow . У меня уже есть некоторый код для передатчика и приемника, однако я просто получаю случайные пиксели на экране, большая часть которых статична, но есть 3 строки вверху и 1 строка посередине, которые мигают случайными цветами. Когда я отключаю камеру, мигающие пиксели прекращаются и продолжаются, если она снова подключена. Другие данные передаются, такие как float и int, только для отладки. введите здесь описание изображения tft display
// receiver
#include
#include
#include
#include
#include
// Define the pins used
#define TFT_CS 5
#define TFT_RST 4 // Or set to -1 and connect to ESP32 RST
#define TFT_DC 2
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
// Structure example to receive data
// Must match the sender structure
typedef struct struct_message {
char a[32];
int b;
float c;
bool d;
} struct_message;
// Create a struct_message called myData
struct_message myData;
// Constants for image data handling
const int chunkSize = 1024; // Define a reasonable chunk size
uint8_t imgBuffer[chunkSize];
int imgOffset = 0;
int totalImgSize = 320 * 240; // QVGA image size
bool imgReceived = false;
// callback function that will be executed when data is received
void OnDataRecv(const esp_now_recv_info *info, const uint8_t *incomingData, int len) {
// If the received data length is the same as the struct, it's our struct
if (len == sizeof(myData)) {
memcpy(&myData, incomingData, sizeof(myData));
Serial.print("Bytes received: ");
Serial.println(len);
Serial.print("Char: ");
Serial.println(myData.a);
Serial.print("Int: ");
Serial.println(myData.b);
Serial.print("Float: ");
Serial.println(myData.c);
Serial.print("Bool: ");
Serial.println(myData.d);
Serial.println();
} else {
// Otherwise, it's image data
for (int i = 0; i < len; i++) {
imgBuffer[imgOffset++] = incomingData[i];
if (imgOffset == chunkSize) {
// Process this chunk of data
int x = 0; // Calculate x position
int y = 0; // Calculate y position
tft.drawRGBBitmap(x, y, (uint16_t*)imgBuffer, 320, 240); // Draw one line at a time
imgOffset = 0; // Reset offset for next chunk
}
}
if (imgOffset == totalImgSize) {
imgReceived = true;
Serial.println("image recived");
imgOffset = 0;
}
}
}
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
// Set device as a Wi-Fi Station
WiFi.mode(WIFI_STA);
// Initialize the TFT display
tft.init(240, 320); // Init ST7789 240x320
tft.setRotation(1);
tft.fillScreen(ST77XX_BLACK);
tft.setTextColor(ST77XX_WHITE);
tft.setTextSize(2);
tft.println("Waiting for image...");
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
// Register callback function for receiving data
esp_now_register_recv_cb(OnDataRecv);
}
void loop() {
if (imgReceived) {
tft.fillScreen(ST77XX_BLACK);
tft.setCursor(0, 0);
tft.println("Image received!");
}
}
//Transmitter
#include
#include
#include "esp_camera.h"
#define CAMERA_MODEL_ESP32S3_EYE
#include "camera_pins.h"
// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {0xfc, 0xe8, 0xc0, 0x7d, 0xff, 0x50}; // esp32 with spi screen
typedef struct struct_message {
char a[32];
int b;
float c;
bool d;
} struct_message;
// Create a struct_message called myData
struct_message myData;
esp_now_peer_info_t peerInfo;
// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
Serial.print("\r\nLast Packet Send Status:\t");
Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}
void setup() {
// Init Serial Monitor
Serial.begin(115200);
// Set device as a Wi-Fi Station
WiFi.mode(WIFI_STA);
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
// Register for Send CB to get the status of Transmitted packet
esp_now_register_send_cb(OnDataSent);
// Register peer
memcpy(peerInfo.peer_addr, broadcastAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
// Add peer
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
return;
}
// Initialize the 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_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.frame_size = FRAMESIZE_QVGA; // 320x240
config.pixel_format = PIXFORMAT_JPEG; // for streaming
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.jpeg_quality = 12;
config.fb_count = 1;
if (psramFound()) {
config.jpeg_quality = 10;
config.fb_count = 2;
config.grab_mode = CAMERA_GRAB_LATEST;
} else {
config.frame_size = FRAMESIZE_SVGA;
config.fb_location = CAMERA_FB_IN_DRAM;
}
// Camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
}
void loop() {
// Capture photo
camera_fb_t *fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
} else {
Serial.println("Camera capture successful");
// Send image in chunks
int chunkSize = 240; // ESP-NOW max payload size
int numChunks = fb->len / chunkSize + (fb->len % chunkSize != 0);
for (int i = 0; i < numChunks; i++) {
int offset = i * chunkSize;
int len = min(chunkSize, (int)(fb->len - offset));
esp_err_t result = esp_now_send(broadcastAddress, fb->buf + offset, len);
if (result == ESP_OK) {
Serial.printf("Chunk %d sent with success\n", i);
} else {
Serial.printf("Error sending chunk %d\n", i);
}
delay(30); // small delay to avoid overwhelming the receiver
}
esp_camera_fb_return(fb);
}
// Set values to send
strcpy(myData.a, "THIS IS A CHAR");
myData.b = random(1, 20);
myData.c = 1.2;
myData.d = false;
// Send message via ESP-NOW
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&myData, sizeof(myData));
if (result == ESP_OK) {
Serial.println("Sent with success");
} else {
Serial.println("Error sending the data");
}
}
Я пробовал использовать веб-сокеты, ble, esp сейчас, однако я не могу заставить ни один из них работать, в Интернете мало информации по этому поводу, и все, что есть, похоже, не работает .
У меня есть два esp, один — esp32, а другой — esp32s3_eye, у меня есть tft-дисплей, подключенный к esp32, и я хочу, чтобы камера с esp32s3_eye отправляла на экран живое видео с помощью espnow . У меня уже есть некоторый код для передатчика и приемника, однако я просто получаю случайные пиксели на экране, большая часть которых статична, но есть 3 строки вверху и 1 строка посередине, которые мигают случайными цветами. Когда я отключаю камеру, мигающие пиксели прекращаются и продолжаются, если она снова подключена. Другие данные передаются, такие как float и int, только для отладки. введите здесь описание изображения tft display [code]// receiver
#include #include #include #include #include
// Define the pins used #define TFT_CS 5 #define TFT_RST 4 // Or set to -1 and connect to ESP32 RST #define TFT_DC 2
// Structure example to receive data // Must match the sender structure typedef struct struct_message { char a[32]; int b; float c; bool d; } struct_message;
// Create a struct_message called myData struct_message myData;
// Constants for image data handling const int chunkSize = 1024; // Define a reasonable chunk size uint8_t imgBuffer[chunkSize]; int imgOffset = 0; int totalImgSize = 320 * 240; // QVGA image size bool imgReceived = false;
// callback function that will be executed when data is received void OnDataRecv(const esp_now_recv_info *info, const uint8_t *incomingData, int len) { // If the received data length is the same as the struct, it's our struct if (len == sizeof(myData)) { memcpy(&myData, incomingData, sizeof(myData)); Serial.print("Bytes received: "); Serial.println(len); Serial.print("Char: "); Serial.println(myData.a); Serial.print("Int: "); Serial.println(myData.b); Serial.print("Float: "); Serial.println(myData.c); Serial.print("Bool: "); Serial.println(myData.d); Serial.println(); } else { // Otherwise, it's image data for (int i = 0; i < len; i++) { imgBuffer[imgOffset++] = incomingData[i]; if (imgOffset == chunkSize) { // Process this chunk of data int x = 0; // Calculate x position int y = 0; // Calculate y position tft.drawRGBBitmap(x, y, (uint16_t*)imgBuffer, 320, 240); // Draw one line at a time imgOffset = 0; // Reset offset for next chunk } } if (imgOffset == totalImgSize) { imgReceived = true; Serial.println("image recived"); imgOffset = 0; } } }
void setup() { // Initialize Serial Monitor Serial.begin(115200);
// Set device as a Wi-Fi Station WiFi.mode(WIFI_STA);
// Initialize the TFT display tft.init(240, 320); // Init ST7789 240x320 tft.setRotation(1); tft.fillScreen(ST77XX_BLACK); tft.setTextColor(ST77XX_WHITE); tft.setTextSize(2); tft.println("Waiting for image...");
// Send image in chunks int chunkSize = 240; // ESP-NOW max payload size int numChunks = fb->len / chunkSize + (fb->len % chunkSize != 0);
for (int i = 0; i < numChunks; i++) { int offset = i * chunkSize; int len = min(chunkSize, (int)(fb->len - offset)); esp_err_t result = esp_now_send(broadcastAddress, fb->buf + offset, len);
if (result == ESP_OK) { Serial.printf("Chunk %d sent with success\n", i); } else { Serial.printf("Error sending chunk %d\n", i); }
delay(30); // small delay to avoid overwhelming the receiver }
esp_camera_fb_return(fb); }
// Set values to send strcpy(myData.a, "THIS IS A CHAR"); myData.b = random(1, 20); myData.c = 1.2; myData.d = false;
// Send message via ESP-NOW esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&myData, sizeof(myData));
if (result == ESP_OK) { Serial.println("Sent with success"); } else { Serial.println("Error sending the data"); }
} [/code] Я пробовал использовать веб-сокеты, ble, esp сейчас, однако я не могу заставить ни один из них работать, в Интернете мало информации по этому поводу, и все, что есть, похоже, не работает .
Мне нужно открыть локально сохраненное видео, обработать его покадрово и отправить в прямой RTMP-поток на YouTube. Я могу сделать это с помощью FFMPEG в терминале командной строки, но не могу сделать это с помощью Python. В Python на консоли...
Я новичок во всем этом. В настоящее время я работаю над проектом, в котором использую модуль picamera 3 noir и pi4 для обнаружения в реальном времени. Из-за использования версии OS Lite я использую Flask для потоковой передачи в своем веб-браузере....
Привет, ребята, спасибо за помощь!
Я хотел бы навсегда встроить прямую трансляцию YouTube с чатом на свой сайт.
Проблема в том, что , что YouTube не предоставляет постоянные URL-адреса. Каждая прямая трансляция имеет уникальный идентификатор...
Привет, ребята, спасибо за помощь!
Я хотел бы навсегда встроить прямую трансляцию YouTube с чатом на свой сайт.
Проблема в том, что , что YouTube не предоставляет постоянные URL-адреса. Каждая прямая трансляция имеет уникальный идентификатор...