完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好呀。我目前正在使用 ESP32 摄像头模块制作一辆汽车,该汽车可将汽车摄像头的实时信息流式传输到智能手机或笔记本电脑。现在,我在流式传输方面遇到了问题。机器人汽车工作正常,但我无法让饲料工作。它无法在我的智能手机上正常播放。您可以在下面找到我用于此项目的代码:
代码:全选#include "esp_camera.h" #include #define CAMERA_MODEL_AI_THINKER const char* ssid = "--------"; const char* password = "--------"; #if defined(CAMERA_MODEL_WROVER_KIT) #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 21 #define SIOD_GPIO_NUM 26 #define SIOC_GPIO_NUM 27 #define Y9_GPIO_NUM 35 #define Y8_GPIO_NUM 34 #define Y7_GPIO_NUM 39 #define Y6_GPIO_NUM 36 #define Y5_GPIO_NUM 19 #define Y4_GPIO_NUM 18 #define Y3_GPIO_NUM 5 #define Y2_GPIO_NUM 4 #define VSYNC_GPIO_NUM 25 #define HREF_GPIO_NUM 23 #define PCLK_GPIO_NUM 22 #elif defined(CAMERA_MODEL_AI_THINKER) #define PWDN_GPIO_NUM 32 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 0 #define SIOD_GPIO_NUM 26 #define SIOC_GPIO_NUM 27 #define Y9_GPIO_NUM 35 #define Y8_GPIO_NUM 34 #define Y7_GPIO_NUM 39 #define Y6_GPIO_NUM 36 #define Y5_GPIO_NUM 21 #define Y4_GPIO_NUM 19 #define Y3_GPIO_NUM 18 #define Y2_GPIO_NUM 5 #define VSYNC_GPIO_NUM 25 #define HREF_GPIO_NUM 23 #define PCLK_GPIO_NUM 22 #else #error "Camera model not selected" #endif extern int gpLb = 2; extern int gpLf = 14; extern int gpRb = 15; extern int gpRf = 13; extern int gpLed = 4; extern String WiFiAddr =""; void startCameraServer(); void setup() { Serial.begin(115200); Serial.setDebugOutput(true); Serial.println(); pinMode(gpLb, OUTPUT); pinMode(gpLf, OUTPUT); pinMode(gpRb, OUTPUT); pinMode(gpRf, OUTPUT); pinMode(gpLed, OUTPUT); //initialize digitalWrite(gpLb, LOW); digitalWrite(gpLf, LOW); digitalWrite(gpRb, LOW); digitalWrite(gpRf, LOW); digitalWrite(gpLed, LOW); 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; if(psramFound()){ config.frame_size = FRAMESIZE_UXGA; config.jpeg_quality = 10; config.fb_count = 2; } else { config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = 12; config.fb_count = 1; } 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_CIF); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); startCameraServer(); Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); WiFiAddr = WiFi.localIP().toString(); Serial.println("' to connect"); } void loop() { } |
|
相关推荐
1个回答
|
|
在您提供的代码中,没有涉及到流式传输的具体实现。所以,为了诊断您遇到的问题,我们需要更多的信息。以下是一些可能有用的提示:
1. 确保您的智能手机和笔记本电脑连接到了您的Wi-Fi网络上。 2. 您的代码中似乎没有 WiFi 连接的相关代码。请确保您在您的代码中包含了正确的 WiFi 连接代码。 3. 您需要将相机模块配置为以流式传输的形式向客户端发送视频流。在 esp_camera.h 中,您可以使用该模块的 stream 函数。以下是一些使用 stream 函数的示例代码: ``` #include "esp_camera.h" #include "WiFi.h" const char* ssid = "your-ssid"; const char* password = "your-password"; void setup() { Serial.begin(115200); // initialize the camera module camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = 5; config.pin_d1 = 18; config.pin_d2 = 19; config.pin_d3 = 21; config.pin_d4 = 36; config.pin_d5 = 39; config.pin_d6 = 34; config.pin_d7 = 35; config.pin_xclk = 0; config.pin_pclk = 22; config.pin_vsync = 25; config.pin_href = 23; config.pin_sscb_sda = 26; config.pin_sscb_scl = 27; config.pin_pwdn = 32; config.pin_reset = -1; config.xclk_freq_hz = 20000000; config.pixel_format = PIXFORMAT_JPEG; config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = 10; config.fb_count = 2; // power on the camera module esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); return; } // connect to the wifi network WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } // print out the assigned IP address Serial.printf("Connected to WiFi! IP address: %sn", WiFi.localIP().toString().c_str()); } void loop() { camera_fb_t* fb = esp_camera_fb_get(); // send the JPEG image stream to the client WiFiClient client = WiFiServer(8080).available(); if (client) { client.write(fb->buf, fb->len); client.flush(); client.stop(); } esp_camera_fb_return(fb); } ``` 4. 如果您连接的是笔记本电脑,您可以使用 VLC 等流媒体播放器来进行测试。打开 VLC,点击"文件"->"打开网络串流",输入您 ESP32 的 IP 地址和端口号(默认是8080),点击"播放"。如果您的代码实现正确,您应该能够在 VLC 中看到实时视频流。 希望这些提示能够帮助您找到问题所在! |
|
|
|
只有小组成员才能发言,加入小组>>
1002 浏览 1 评论
554浏览 6评论
463浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
447浏览 5评论
448浏览 4评论
422浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-30 09:36 , Processed in 0.727736 second(s), Total 76, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号