ImageHelper already has similar function.
Change-Id: Ibeecaf6ba387a1504811c70423f9d7b216cec154
Signed-off-by: Kwang Son <k.son@samsung.com>
unsigned long *pBufferSize,
ImageData *pImageData);
+ static int loadImageToSource(const char *filePath, mv_source_h source);
+
/**
* @brief Saves image stored into @a pDataBuffer to the file in jpeg format.
*
return MEDIA_VISION_ERROR_NONE;
}
+int ImageHelper::loadImageToSource(const char *filePath, mv_source_h source)
+{
+ unsigned char *data_buffer = NULL;
+ unsigned long buffer_size = 0;
+ ImageData image_data;
+
+ int err = loadImageToBuffer(filePath, &data_buffer, &buffer_size,
+ &image_data);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occurred during opening file!!! code: %i\n",
+ err);
+ return err;
+ }
+
+ err = mv_source_fill_by_buffer(source, data_buffer, buffer_size,
+ image_data.imageWidth,
+ image_data.imageHeight,
+ image_data.imageColorspace);
+
+ if (MEDIA_VISION_ERROR_NONE != err)
+ printf("ERROR: Errors were occurred during filling source!!! code %i\n",
+ err);
+
+ if (NULL != data_buffer)
+ destroyLoadedBuffer(data_buffer);
+ return err;
+}
+
int ImageHelper::saveImageFromBuffer(
const char *filePath,
unsigned char *pDataBuffer,
#include <gtest/gtest.h>
+#include <ImageHelper.h>
#include "test_inference_helper.hpp"
#define IC_LABEL_MOBILENET_V1_224_PATH \
EXPECT_EQ(mv_inference_configure(infer, engine_cfg),
MEDIA_VISION_ERROR_NONE);
EXPECT_EQ(mv_inference_prepare(infer), MEDIA_VISION_ERROR_NONE);
- EXPECT_EQ(load_mv_source_from_file(mv_source, IMG_BANANA),
+ EXPECT_EQ(MediaVision::Common::ImageHelper::loadImageToSource(IMG_BANANA,
+ mv_source),
MEDIA_VISION_ERROR_NONE);
EXPECT_EQ(mv_inference_image_classify(mv_source, infer, NULL,
_image_classified_cb, NULL),
MEDIA_VISION_ERROR_NONE);
EXPECT_EQ(mv_source_clear(mv_source), MEDIA_VISION_ERROR_NONE);
-}
\ No newline at end of file
+}
handle, MV_INFERENCE_MODEL_USER_FILE_PATH, user_file),
MEDIA_VISION_ERROR_NONE);
}
-
-// TODO: memcpy twice to one time
-int load_mv_source_from_file(mv_source_h source, const char *path_to_image)
-{
- unsigned char *data_buffer = NULL;
- unsigned long buffer_size = 0;
- image_data_s image_data;
-
- int err = load_image_to_buffer(path_to_image, &data_buffer, &buffer_size,
- &image_data);
- if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occurred during opening file!!! code: %i\n",
- err);
- if (NULL != data_buffer)
- destroy_loaded_buffer(data_buffer);
-
- return err;
- }
-
- err = mv_source_fill_by_buffer(source, data_buffer, buffer_size,
- image_data.image_width,
- image_data.image_height,
- image_data.image_colorspace);
-
- if (MEDIA_VISION_ERROR_NONE != err)
- printf("ERROR: Errors were occurred during filling source!!! code %i\n",
- err);
-
- if (NULL != data_buffer)
- destroy_loaded_buffer(data_buffer);
-
- return err;
-}
const char *tf_weight,
const char *user_file);
-int load_mv_source_from_file(mv_source_h source, const char *path_to_image);
-
-#endif //__TEST_INFERENCE_HELPER_HPP__
\ No newline at end of file
+#endif //__TEST_INFERENCE_HELPER_HPP__