@@ -98,7 +98,7 @@ SscmaCamera::SscmaCamera(esp_io_expander_handle_t io_exp_handle) {
9898 break ;
9999 }
100100 }
101-
101+ free (boxes);
102102 } else if (sscma_utils_fetch_classes_from_reply (reply, &classes, &class_count) == ESP_OK && class_count > 0 ) {
103103 // 尝试获取分类数据(分类模型)
104104 for (int i = 0 ; i < class_count; i++) {
@@ -110,6 +110,7 @@ SscmaCamera::SscmaCamera(esp_io_expander_handle_t io_exp_handle) {
110110 obj_cnt++;
111111 }
112112 }
113+ free (classes);
113114 } else if (sscma_utils_fetch_points_from_reply (reply, &points, &point_count) == ESP_OK && point_count > 0 ) {
114115 // 尝试获取关键点数据(姿态估计模型)
115116 for (int i = 0 ; i < point_count; i++) {
@@ -121,6 +122,7 @@ SscmaCamera::SscmaCamera(esp_io_expander_handle_t io_exp_handle) {
121122 obj_cnt++;
122123 }
123124 }
125+ free (points);
124126 }
125127
126128 // 如果需要开始冷却期,现在开始计时
@@ -307,7 +309,7 @@ SscmaCamera::SscmaCamera(esp_io_expander_handle_t io_exp_handle) {
307309
308310 preview_image_.header .stride = preview_image_.header .w * 2 ;
309311 preview_image_.data_size = preview_image_.header .w * preview_image_.header .h * 2 ;
310- preview_image_.data = (uint8_t *)heap_caps_malloc (preview_image_.data_size , MALLOC_CAP_SPIRAM );
312+ preview_image_.data =(uint8_t *)jpeg_calloc_align (preview_image_.data_size , 16 );
311313 if (preview_image_.data == nullptr ) {
312314 ESP_LOGE (TAG, " Failed to allocate memory for preview image" );
313315 return ;
@@ -582,7 +584,7 @@ bool SscmaCamera::Capture() {
582584 uint16_t h = preview_image_.header .h ;
583585 size_t image_size = w * h * 2 ;
584586 size_t stride = preview_image_.header .w * 2 ;
585-
587+
586588 uint8_t * data = (uint8_t *)heap_caps_malloc (image_size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
587589 if (data == nullptr ) {
588590 ESP_LOGE (TAG, " Failed to allocate memory for display image" );
0 commit comments