Browse Source

崩溃+摄像头适配(没有PSRAM)

xuxinyi 9 months ago
parent
commit
2c6fa9f06b
2 changed files with 15 additions and 5 deletions
  1. 10 4
      main/camera.c
  2. 5 1
      managed_components/espressif__esp32-camera/driver/esp_camera.c

+ 10 - 4
main/camera.c

@@ -137,8 +137,8 @@ static const char *TAG = "example:take_picture";
 
 
 #if ESP_CAMERA_SUPPORTED
 #if ESP_CAMERA_SUPPORTED
 static camera_config_t camera_config = {
 static camera_config_t camera_config = {
-    //.pin_pwdn = CAM_PIN_PWDN,
-    //.pin_reset = CAM_PIN_RESET,
+    .pin_pwdn = CAM_PIN_PWDN,
+    .pin_reset = CAM_PIN_RESET,
     .pin_xclk = CAM_PIN_XCLK,
     .pin_xclk = CAM_PIN_XCLK,
     .pin_sccb_sda = CAM_PIN_SIOD,
     .pin_sccb_sda = CAM_PIN_SIOD,
     .pin_sccb_scl = CAM_PIN_SIOC,
     .pin_sccb_scl = CAM_PIN_SIOC,
@@ -165,7 +165,7 @@ static camera_config_t camera_config = {
 
 
     .jpeg_quality = 12, //0-63, for OV series camera sensors, lower number means higher quality
     .jpeg_quality = 12, //0-63, for OV series camera sensors, lower number means higher quality
     .fb_count = 1,       //When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
     .fb_count = 1,       //When jpeg mode is used, if fb_count more than one, the driver will work in continuous mode.
-    .fb_location = CAMERA_FB_IN_PSRAM,
+    .fb_location = CAMERA_FB_IN_DRAM,
     .grab_mode = CAMERA_GRAB_WHEN_EMPTY,
     .grab_mode = CAMERA_GRAB_WHEN_EMPTY,
 };
 };
 
 
@@ -194,7 +194,13 @@ void take_photo(void)
     {
     {
         ESP_LOGI(TAG, "Taking picture...");
         ESP_LOGI(TAG, "Taking picture...");
         camera_fb_t *pic = esp_camera_fb_get();
         camera_fb_t *pic = esp_camera_fb_get();
-
+        if ( pic == NULL) 
+        {
+            /* code */
+            ESP_LOGE(TAG, "Camera capture failed");
+            return; 
+        }
+        
         // use pic->buf to access the image
         // use pic->buf to access the image
         ESP_LOGI(TAG, "Picture taken! Its size was: %zu bytes", pic->len);
         ESP_LOGI(TAG, "Picture taken! Its size was: %zu bytes", pic->len);
         esp_camera_fb_return(pic);
         esp_camera_fb_return(pic);

+ 5 - 1
managed_components/espressif__esp32-camera/driver/esp_camera.c

@@ -370,13 +370,17 @@ camera_fb_t *esp_camera_fb_get()
         return NULL;
         return NULL;
     }
     }
     camera_fb_t *fb = cam_take(FB_GET_TIMEOUT);
     camera_fb_t *fb = cam_take(FB_GET_TIMEOUT);
+    ESP_LOGI(TAG, "测试");
     //set the frame properties
     //set the frame properties
     if (fb) {
     if (fb) {
         fb->width = resolution[s_state->sensor.status.framesize].width;
         fb->width = resolution[s_state->sensor.status.framesize].width;
         fb->height = resolution[s_state->sensor.status.framesize].height;
         fb->height = resolution[s_state->sensor.status.framesize].height;
         fb->format = s_state->sensor.pixformat;
         fb->format = s_state->sensor.pixformat;
+        return fb;
+    }else{
+        return NULL;
     }
     }
-    return fb;
+    
 }
 }
 
 
 void esp_camera_fb_return(camera_fb_t *fb)
 void esp_camera_fb_return(camera_fb_t *fb)