g_object_unref(parser);
}
-/**
- * @function LoadImageMediaSource
- * @description Load image source
- * @parameter const char *file_path, mv_source_h source
- * @return Media vision error map value
- */
-int LoadImageMediaSource(const char *file_path, mv_source_h source)
-{
- if (NULL == file_path || NULL == source) {
- FPRINTF("[Line : %d][%s] File path or source is NULL\n", __LINE__, API_NAMESPACE);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- unsigned long nWidth = 0;
- unsigned long nHeight = 0;
- unsigned long long nBufSize = 0;
- unsigned char *pszDataBuf = NULL;
- int nRet1 = IMAGE_UTIL_ERROR_NONE;
- int nRet2 = MEDIA_VISION_ERROR_NONE;
- image_util_decode_h hDecoder = NULL;
-
- nRet1 = image_util_decode_create(&hDecoder);
- PRINT_RESULT(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_create", ImageUtilGetError(nRet1));
- CHECK_HANDLE(&hDecoder, "image_util_decode_create");
- nRet1 = image_util_decode_set_input_path(hDecoder, file_path);
- PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_set_input_path", ImageUtilGetError(nRet1),
- image_util_decode_destroy(hDecoder));
- nRet1 = image_util_decode_set_colorspace(hDecoder, IMAGE_UTIL_COLORSPACE_RGB888);
- PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_set_colorspace", ImageUtilGetError(nRet1),
- image_util_decode_destroy(hDecoder));
- nRet1 = image_util_decode_set_output_buffer(hDecoder, &pszDataBuf);
- PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_set_output_buffer", ImageUtilGetError(nRet1),
- image_util_decode_destroy(hDecoder));
- nRet1 = image_util_decode_run(hDecoder, &nWidth, &nHeight, &nBufSize);
- PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_run", ImageUtilGetError(nRet1),
- image_util_decode_destroy(hDecoder);
- FREE_MEMORY(pszDataBuf));
-
- // Only grayscale and RGB jpegs in test set:
- mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
- nRet2 = mv_source_clear(source);
- PRINT_RESULT_CLEANUP(MEDIA_VISION_ERROR_NONE, nRet2, "mv_source_clear", MediaVisionGetError(nRet2),
- image_util_decode_destroy(hDecoder);
- FREE_MEMORY(pszDataBuf));
- nRet2 = mv_source_fill_by_buffer(source, pszDataBuf, (unsigned int) nBufSize, (unsigned int) nWidth,
- (unsigned int) nHeight, source_colorspace);
- PRINT_RESULT_CLEANUP(MEDIA_VISION_ERROR_NONE, nRet2, "mv_source_fill_by_buffer", MediaVisionGetError(nRet2),
- image_util_decode_destroy(hDecoder);
- FREE_MEMORY(pszDataBuf));
-
- image_util_decode_destroy(hDecoder);
- FREE_MEMORY(pszDataBuf);
- return MEDIA_VISION_ERROR_NONE;
-}
-
/**
* @function CreateAndGetEngineAttributes
* @description Create Engine and get supported attributes
int nIndex = 0, nRet = -1;
for (nIndex = 0; nIndex < nDetectModelLength; ++nIndex) {
- nRet = LoadImageMediaSource(DetectModel[nIndex].image_path, g_hMvSource);
- PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "LoadImageMediaSource", MediaVisionGetError(nRet));
- FPRINTF("[Line : %d][%s] LoadImageMediaSource done successfully\n", __LINE__, API_NAMESPACE);
+ nRet = image_load(DetectModel[nIndex].image_path, g_hMvSource);
+ PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet));
+ FPRINTF("[Line : %d][%s] image_load done successfully\n", __LINE__, API_NAMESPACE);
mv_rectangle_s roi;
roi.point.x = 0;
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
- unsigned long width = 0;
- unsigned long height = 0;
- unsigned long long buffer_size = 0;
+ unsigned int width = 0;
+ unsigned int height = 0;
+ size_t buffer_size = 0;
unsigned char *data_buffer = NULL;
image_util_decode_h hDecoder = NULL;
+ image_util_image_h _decoded_image = NULL;
int ret = image_util_decode_create(&hDecoder);
if (IMAGE_UTIL_ERROR_NONE != ret) {
FPRINTF("[Line : %d][%s] image_util_decode_set_colorspace Failed\n", __LINE__, API_NAMESPACE);
return ret;
}
- ret = image_util_decode_set_output_buffer(hDecoder, &data_buffer);
+ ret = image_util_decode_run2(hDecoder, &_decoded_image);
if (IMAGE_UTIL_ERROR_NONE != ret) {
ret = image_util_decode_destroy(hDecoder);
if (IMAGE_UTIL_ERROR_NONE != ret) {
FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\n", __LINE__, API_NAMESPACE);
return ret;
}
- FPRINTF("[Line : %d][%s] image_util_decode_set_output_buffer Failed\n", __LINE__, API_NAMESPACE);
+ FPRINTF("[Line : %d][%s] image_util_decode_run2 Failed\n", __LINE__, API_NAMESPACE);
return ret;
}
- ret = image_util_decode_run(hDecoder, &width, &height, &buffer_size);
+ ret = image_util_get_image(hDecoder, &width, &height, NULL, &data_buffer, &buffer_size);
if (IMAGE_UTIL_ERROR_NONE != ret) {
if (data_buffer) {
free(data_buffer);
FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\n", __LINE__, API_NAMESPACE);
return ret;
}
- FPRINTF("[Line : %d][%s] image_util_decode_run Failed\n", __LINE__, API_NAMESPACE);
+ FPRINTF("[Line : %d][%s] image_util_get_image Failed\n", __LINE__, API_NAMESPACE);
return ret;
}
- mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
ret = mv_source_clear(source);
if (MEDIA_VISION_ERROR_NONE != ret) {
if (data_buffer) {
return ret;
}
- ret = mv_source_fill_by_buffer(source, data_buffer, buffer_size, width, height, source_colorspace);
+ ret = mv_source_fill_by_buffer(source, data_buffer, buffer_size, width, height, MEDIA_VISION_COLORSPACE_RGB888);
if (MEDIA_VISION_ERROR_NONE != ret) {
if (data_buffer) {
free(data_buffer);