Explorar el Código

Propagate image resize failures through ROI processing

SybexXx hace 2 días
padre
commit
78e5a2ebfd

+ 1 - 2
code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp

@@ -613,8 +613,7 @@ bool ClassFlowCNNGeneral::doAlignAndCut(string time) {
                 }
             }
 
-            region->image_org->Resize(modelxsize, modelysize, region->image);
-            if (!region->image->ImageOkay()) {
+            if (!region->image_org->Resize(modelxsize, modelysize, region->image)) {
                 LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "ROI resize failed");
                 return false;
             }

+ 6 - 5
code/components/jomjol_image_proc/CImageBasis.cpp

@@ -890,28 +890,28 @@ void CImageBasis::Resize(int _new_dx, int _new_dy)
 }
 
 
-void CImageBasis::Resize(int _new_dx, int _new_dy, CImageBasis *_target)
+bool CImageBasis::Resize(int _new_dx, int _new_dy, CImageBasis *_target)
 {
     if (_target == this || _target == NULL || rgb_image == NULL || !_target->ImageOkay() ||
         _target->height != _new_dy || _target->width != _new_dx ||
         _target->channels != channels) {
         ESP_LOGE(TAG, "Resize - Target image size does not fit or is unavailable!");
-        return;
+        return false;
     }
 
     size_t sourceSize = 0, targetSize = 0;
     if (!getImageBufferSize(width, height, channels, &sourceSize) ||
         !getImageBufferSize(_new_dx, _new_dy, channels, &targetSize)) {
         ESP_LOGE(TAG, "Resize - Invalid source or target dimensions");
-        return;
+        return false;
     }
 
     uint8_t* source = RGBImageLock();
-    if (source == NULL) return;
+    if (source == NULL) return false;
     uint8_t* target = _target->RGBImageLock();
     if (target == NULL) {
         RGBImageRelease();
-        return;
+        return false;
     }
 
     const int resized = stbir_resize_uint8(source, width, height, 0,
@@ -919,5 +919,6 @@ void CImageBasis::Resize(int _new_dx, int _new_dy, CImageBasis *_target)
     _target->RGBImageRelease();
     RGBImageRelease();
     if (resized == 0) ESP_LOGE(TAG, "Resize - stb resize failed");
+    return resized != 0;
 }
 

+ 1 - 1
code/components/jomjol_image_proc/CImageBasis.h

@@ -89,7 +89,7 @@ class CImageBasis
         CImageBasis(std::string name, CImageBasis *_copyfrom);
 
         void Resize(int _new_dx, int _new_dy);        
-        void Resize(int _new_dx, int _new_dy, CImageBasis *_target);        
+        bool Resize(int _new_dx, int _new_dy, CImageBasis *_target);        
         void crop_image(unsigned short cropLeft, unsigned short cropRight, unsigned short cropTop, unsigned short cropBottom);
 
         bool LoadFromMemory(stbi_uc *_buffer, int len);