add_library(${PROJECT_NAME} SHARED ${MV_IMAGE_HELPER_SRC_LIST})
endif()
-target_include_directories(${PROJECT_NAME} PUBLIC include ${OpenCV_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include ${${PROJECT_NAME}_DEP_INCLUDE_DIRS})
-target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
+target_include_directories(${PROJECT_NAME} PUBLIC include)
+target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${${PROJECT_NAME}_DEP_LIBRARIES} mv_common)
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
#include "ImageHelper.h"
#include "mv_private.h"
-
#include <vector>
#include <cstring>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/imgcodecs/legacy/constants_c.h>
+#include <MediaSource.h>
/**
* @file ImageHelper.cpp
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;
- }
+ if (filePath == nullptr || source == nullptr)
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- err = mv_source_fill_by_buffer(source, data_buffer, buffer_size,
- image_data.imageWidth,
- image_data.imageHeight,
- image_data.imageColorspace);
+ MediaSource *mediaSource = static_cast<MediaSource *>(source);
+ cv::Mat image = cv::imread(filePath);
+ cv::cvtColor(image, image, CV_BGR2RGB);
- if (MEDIA_VISION_ERROR_NONE != err)
- printf("ERROR: Errors were occurred during filling source!!! code %i\n",
- err);
+ if (!(mediaSource->fill(image.data, image.total() * image.elemSize(),
+ image.cols, image.rows, OPEN_CV_COLOR)))
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- if (NULL != data_buffer)
- destroyLoadedBuffer(data_buffer);
- return err;
+ return MEDIA_VISION_ERROR_NONE;
}
int ImageHelper::saveImageFromBuffer(