typedef enum {
DCM_SVC_I420,
- DCM_SVC_RGB888,
+ DCM_SVC_RGB,
+ DCM_SVC_RGBA,
} DcmImageDecodeType;
typedef struct {
unsigned char *pixel; /* decoding results, must be freed after use */
- unsigned int size;
+ unsigned long long size;
int orientation; /* orientation information extracted from exif */
unsigned int original_width; /* original image width */
unsigned int original_height; /* original image height */
return ret;
}
-EXPORT_API int dcm_face_get_prefered_colorspace(__in dcm_face_h handle, __out face_image_colorspace_e *colorspace)
-{
- dcm_retvm_if(handle == NULL, FACE_ERROR_INVALID_PARAMTER, "Invalid handle");
- dcm_retvm_if(colorspace == NULL, FACE_ERROR_INVALID_PARAMTER, "Invalid colorspace");
-
- *colorspace = FACE_IMAGE_COLORSPACE_RGB888;
-
- return FACE_ERROR_NONE;
-}
-
-EXPORT_API int dcm_face_set_image_info(dcm_face_h handle, face_image_colorspace_e colorspace, unsigned char *buffer, unsigned int width, unsigned int height, unsigned int size)
+EXPORT_API int dcm_face_set_image_info(dcm_face_h handle, face_image_colorspace_e colorspace, unsigned char *buffer, unsigned int width, unsigned int height, unsigned long long size)
{
FaceHandleT *_handle = (FaceHandleT *)handle;
unsigned char *data = NULL;
case FACE_IMAGE_COLORSPACE_RGB888:
case FACE_IMAGE_COLORSPACE_RGBA:
data = (unsigned char *)calloc(1, size);
+ if (data == NULL) {
+ dcm_error("Not allocate memory");
+ return FACE_ERROR_OUT_OF_MEMORY;
+ }
memcpy(data, buffer, size);
break;
default:
dcm_debug("face_detect image: %p, size: %d, width: %d, height: %d, color: %d", handle->image_info->data, handle->image_info->size, handle->image_info->width, handle->image_info->height, colorspace);
- err = mv_source_fill_by_buffer(_fengine->source, handle->image_info->data, handle->image_info->size, handle->image_info->width, handle->image_info->height, colorspace);
+ err = mv_source_fill_by_buffer(_fengine->source, handle->image_info->data, (unsigned int)(handle->image_info->size), handle->image_info->width, handle->image_info->height, colorspace);
if (err != MEDIA_VISION_ERROR_NONE) {
dcm_error("Fail to mv_source_fill_by_buffer");
return __convert_to_mv_error_e(err);
unsigned char *data;
unsigned int width;
unsigned int height;
- unsigned int size;
+ unsigned long long size;
face_image_colorspace_e colorspace;
unsigned int magic;
} FaceImage;
* @retval #FACE_ERROR_OUT_OF_MEMORY Out of memory
* @see dcm_face_create()
*/
-int dcm_face_set_image_info(dcm_face_h handle, face_image_colorspace_e colorspace, unsigned char *buffer, unsigned int width, unsigned int height, unsigned int size);
+int dcm_face_set_image_info(dcm_face_h handle, face_image_colorspace_e colorspace, unsigned char *buffer, unsigned int width, unsigned int height, unsigned long long size);
/**
* @brief Gets the face information of detected faces.
#define MIME_TYPE_PNG "image/png"
#define MIME_TYPE_BMP "image/bmp"
-#define OPT_IMAGE_WIDTH 2048
-#define OPT_IMAGE_HEIGHT 1536
+#define OPT_IMAGE_WIDTH 1280
+#define OPT_IMAGE_HEIGHT 720
static void _dcm_get_optimized_wh(unsigned int src_width, unsigned int src_height, unsigned int *calc_width, unsigned int *calc_height)
{
}
}
-static int _dcm_rotate_image(const unsigned char *source, unsigned char **image_buffer, unsigned int *buff_width, unsigned int *buff_height, dcm_image_codec_type_e decode_type, int orientation)
+static int _dcm_rotate_image(const unsigned char *source, const dcm_image_format_e format, const int orientation, unsigned char **image_buffer, unsigned long long *size, unsigned int *buff_width, unsigned int *buff_height)
{
int ret = IMAGE_UTIL_ERROR_NONE;
image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
DCM_CHECK_VAL(source, DCM_ERROR_INVALID_PARAMETER);
- if (decode_type == DCM_IMAGE_CODEC_I420) {
+ if (format == DCM_IMAGE_FORMAT_I420) {
colorspace = IMAGE_UTIL_COLORSPACE_I420;
- } else if (decode_type == DCM_IMAGE_CODEC_RGB) {
+ } else if (format == DCM_IMAGE_FORMAT_RGB) {
colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
- } else if (decode_type == DCM_IMAGE_CODEC_RGBA) {
+ } else if (format == DCM_IMAGE_FORMAT_RGBA) {
colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
} else {
return DCM_ERROR_UNSUPPORTED_IMAGE_TYPE;
}
/* Get rotate angle enum */
- if (orientation == DEGREE_180) { // 3-180
+ if (orientation == DEGREE_180) {
rotate = IMAGE_UTIL_ROTATION_180;
- } else if (orientation == DEGREE_90) { // 6-90
+ } else if (orientation == DEGREE_90) {
rotate = IMAGE_UTIL_ROTATION_90;
- } else if (orientation == DEGREE_270) { // 8-270
+ } else if (orientation == DEGREE_270) {
rotate = IMAGE_UTIL_ROTATION_270;
} else {
rotate = IMAGE_UTIL_ROTATION_NONE;
return DCM_ERROR_IMAGE_UTIL_FAILED;
}
+ *size = rotated_buffer_size;
+
try {
- /* Rotate input bitmap */
+ /* Rotate input buffer */
ret = image_util_rotate(rotated_buffer, &rotated_width, &rotated_height, rotate, source,
*buff_width, *buff_height, colorspace);
*buff_width = rotated_width;
*buff_height = rotated_height;
- /* Allocated pixel should be freed when scanning is finished for this rotated bitmap */
+ /* Allocated data should be freed when scanning is finished for this rotated image */
*image_buffer = rotated_buffer;
dcm_warn("rotated decode buffer: %p", *image_buffer);
return DCM_SUCCESS;
}
-int dcm_decode_image(const char *file_path,
- dcm_image_codec_type_e decode_type, const char* mimne_type, bool resize,
- unsigned char **image_buffer, unsigned int *buff_width, unsigned int *buff_height,
- int orientation, unsigned int *size)
+int dcm_decode_image(const char *file_path, const dcm_image_format_e format,
+ const char* mimne_type, const int orientation, const bool resize,
+ unsigned char **image_buffer, unsigned long long *size,
+ unsigned int *buff_width, unsigned int *buff_height)
{
int ret = IMAGE_UTIL_ERROR_NONE;
image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
+ mm_util_img_format mm_format = MM_UTIL_IMG_FMT_RGBA8888;
unsigned char *decode_buffer = NULL;
unsigned int decode_width = 0, decode_height = 0;
unsigned char *resize_buffer = NULL;
- unsigned int resize_buffer_size = 0;
+ unsigned int buffer_size = 0;
image_util_decode_h handle = NULL;
dcm_debug_fenter();
return DCM_ERROR_IMAGE_UTIL_FAILED;
}
- if (strcmp(mimne_type, MIME_TYPE_PNG) == 0) {
- DCM_CHECK_VAL((decode_type != DCM_IMAGE_CODEC_RGBA), DCM_ERROR_UNSUPPORTED_IMAGE_TYPE);
- } else if (strcmp(mimne_type, MIME_TYPE_BMP) == 0) {
- DCM_CHECK_VAL((decode_type != DCM_IMAGE_CODEC_RGBA), DCM_ERROR_UNSUPPORTED_IMAGE_TYPE);
- } else if (strcmp(mimne_type, MIME_TYPE_JPEG) == 0) {
- if (decode_type == DCM_IMAGE_CODEC_I420) {
+ ret = image_util_decode_set_input_path(handle, file_path);
+ if (ret != IMAGE_UTIL_ERROR_NONE) {
+ dcm_error("Error image_util_decode_set_input_path ret : %d", ret);
+ return DCM_ERROR_IMAGE_UTIL_FAILED;
+ }
+
+ if (strcmp(mimne_type, MIME_TYPE_JPEG) == 0) {
+ if (format == DCM_IMAGE_FORMAT_I420) {
colorspace = IMAGE_UTIL_COLORSPACE_I420;
- } else if (decode_type == DCM_IMAGE_CODEC_RGB) {
+ mm_format = MM_UTIL_IMG_FMT_I420;
+ } else if (format == DCM_IMAGE_FORMAT_RGB) {
colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
- } else if (decode_type == DCM_IMAGE_CODEC_RGBA) {
+ mm_format = MM_UTIL_IMG_FMT_RGB888;
+ } else if (format == DCM_IMAGE_FORMAT_RGBA) {
colorspace = IMAGE_UTIL_COLORSPACE_RGBA8888;
+ mm_format = MM_UTIL_IMG_FMT_RGBA8888;
} else {
return DCM_ERROR_UNSUPPORTED_IMAGE_TYPE;
}
ret = image_util_decode_set_colorspace(handle, colorspace);
- } else {
- dcm_error("Failed not supported mime type! (%s)", mimne_type);
- return DCM_ERROR_INVALID_PARAMETER;
- }
-
- ret = image_util_decode_set_input_path(handle, file_path);
- if (ret != IMAGE_UTIL_ERROR_NONE) {
- dcm_error("Error image_util_decode_set_input_path ret : %d", ret);
- return DCM_ERROR_IMAGE_UTIL_FAILED;
+ if (ret != IMAGE_UTIL_ERROR_NONE) {
+ dcm_error("Error image_util_decode_set_colorspace ret : %d", ret);
+ return DCM_ERROR_IMAGE_UTIL_FAILED;
+ }
}
ret = image_util_decode_set_output_buffer(handle, &decode_buffer);
return DCM_ERROR_IMAGE_UTIL_FAILED;
}
- ret = image_util_decode_run(handle, (unsigned long *)&decode_width, (unsigned long *)&decode_height, (unsigned long long *)size);
+ ret = image_util_decode_run(handle, (unsigned long *)&decode_width, (unsigned long *)&decode_height, size);
if (ret != IMAGE_UTIL_ERROR_NONE) {
dcm_error("Error image_util_decode_run ret : %d", ret);
return DCM_ERROR_IMAGE_UTIL_FAILED;
/* Resize the big size image to enhance performance for big size image */
if ((decode_width != *buff_width) || (decode_height != *buff_height)) {
- ret = image_util_calculate_buffer_size(*buff_width, *buff_height, colorspace, &resize_buffer_size);
+ ret = image_util_calculate_buffer_size(*buff_width, *buff_height, colorspace, &buffer_size);
if (ret != DCM_SUCCESS) {
dcm_error("Failed to calculate image buffer size! err: %d", ret);
return DCM_ERROR_CODEC_DECODE_FAILED;
}
- resize_buffer = (unsigned char *)malloc(sizeof(unsigned char) * (resize_buffer_size));
- mm_util_resize_image(decode_buffer, decode_width, decode_height, MM_UTIL_IMG_FMT_RGBA8888, resize_buffer, buff_width, buff_height);
+ *size = buffer_size;
+ resize_buffer = (unsigned char *)malloc(sizeof(unsigned char) * (buffer_size));
+ if (resize_buffer != NULL) {
+ mm_util_resize_image(decode_buffer, decode_width, decode_height, mm_format, resize_buffer, buff_width, buff_height);
+ }
} else {
resize_buffer = decode_buffer;
}
if (orientation == 0) {
*image_buffer = resize_buffer;
} else {
- ret = _dcm_rotate_image(resize_buffer, image_buffer, buff_width, buff_height, decode_type, orientation);
+ ret = _dcm_rotate_image(resize_buffer, format, orientation, image_buffer, size, buff_width, buff_height);
if (ret != DCM_SUCCESS) {
dcm_error("Failed to rotate image buffer! err: %d", ret);
return DCM_ERROR_CODEC_DECODE_FAILED;
#endif
typedef enum {
- DCM_IMAGE_CODEC_I420,
- DCM_IMAGE_CODEC_RGB,
- DCM_IMAGE_CODEC_RGBA,
-} dcm_image_codec_type_e;
+ DCM_IMAGE_FORMAT_I420,
+ DCM_IMAGE_FORMAT_RGB,
+ DCM_IMAGE_FORMAT_RGBA,
+} dcm_image_format_e;
typedef struct {
int size;
} dcm_image_info;
-int dcm_decode_image(const char *file_path, dcm_image_codec_type_e decode_type, const char* mimne_type,
- bool resize, unsigned char **image_buffer, unsigned int *buff_width, unsigned int *buff_height,
- int orientation, unsigned int *size);
+int dcm_decode_image(const char *file_path, const dcm_image_format_e format,
+ const char* mimne_type, const int orientation, const bool resize,
+ unsigned char **image_buffer, unsigned long long *size,
+ unsigned int *buff_width, unsigned int *buff_height);
#ifdef __cplusplus
}
Name: dcm-service
Summary: Multimedia DCM(Digital Contents Management) Service
-Version: 0.0.2
+Version: 0.0.3
Release: 0
Group: Multimedia/Service
License: Apache-2.0
char* query_string = NULL;
dcm_debug_fenter();
-
+#if 0
DCM_CHECK_VAL(db_handle, DCM_ERROR_INVALID_PARAMETER);
DCM_CHECK_VAL(color.media_uuid, DCM_ERROR_INVALID_PARAMETER);
DCM_CHECK_VAL(color.storage_uuid, DCM_ERROR_INVALID_PARAMETER);
g_mutex_unlock(&gMutexLock);
DCM_SQLITE3_FREE(query_string);
-
+#endif
dcm_debug_fleave();
return ret;
DCM_CHECK_VAL(image_info, DCM_ERROR_INVALID_PARAMETER);
DCM_CHECK_VAL(image_info->pixel, DCM_ERROR_INVALID_PARAMETER);
- /* Create image buffer used for face detection */
- face_image_colorspace_e prefered_colorspace = FACE_IMAGE_COLORSPACE_RGB888;
+ dcm_debug("colorspce: [%d], w: [%d], h: [%d]", image_info->decode_type, image_info->buffer_width, image_info->buffer_height);
- err = dcm_face_get_prefered_colorspace(dcm_face_handle, &prefered_colorspace);
- if (err != FACE_ERROR_NONE) {
- dcm_error("Failed to create face_image! err: %d", err);
- ret = DCM_ERROR_FACE_ENGINE_FAILED;
- goto DCM_SVC_FACE_RECOGNIZE_BUFFER_FAILED;
- }
-
- dcm_debug("colorspce: [%d], w: [%d], h: [%d]", prefered_colorspace, image_info->buffer_width, image_info->buffer_height);
-
- err = dcm_face_set_image_info(dcm_face_handle, prefered_colorspace, image_info->pixel, image_info->buffer_width, image_info->buffer_height, image_info->size);
+ err = dcm_face_set_image_info(dcm_face_handle, (face_image_colorspace_e)image_info->decode_type, image_info->pixel, image_info->buffer_width, image_info->buffer_height, image_info->size);
if (err != FACE_ERROR_NONE) {
dcm_error("Failed to dcm_face_set_image_info! err: %d", err);
ret = DCM_ERROR_FACE_ENGINE_FAILED;
#include <DcmTypes.h>
#include <DcmDebugUtils.h>
-static char DCM_IPC_PATH[5][100] =
+static char DCM_IPC_PATH[][100] =
{"/var/run/media-server/dcm_ipc_scanthread_recv",
"/var/run/media-server/dcm_ipc_thumbserver_comm_recv",
"/var/run/media-server/media_ipc_thumbdcm_dcmrecv"};
DcmImageInfo image_info = {0, };
memset(&image_info, 0, sizeof(DcmImageInfo));
- dcm_image_codec_type_e image_format = DCM_IMAGE_CODEC_RGBA;
+ dcm_image_format_e image_format = DCM_IMAGE_FORMAT_I420;
/* Process scan operation if the file exists */
if (g_file_test(scan_item->file_path, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) == TRUE) {
dcm_debug("ImgGetImageInfo type: %d, width: %d, height: %d", type, image_info.original_width, image_info.original_height);
}
- if ((strcmp(scan_item->mime_type, MIME_TYPE_JPEG) == 0) ||
- (strcmp(scan_item->mime_type, MIME_TYPE_PNG) == 0) ||
- (strcmp(scan_item->mime_type, MIME_TYPE_BMP) == 0)) {
- ret = dcm_decode_image((const char *) (scan_item->file_path),
- image_format, scan_item->mime_type, FALSE, &(image_info.pixel),
- &(image_info.buffer_width), &(image_info.buffer_height), image_info.orientation, &(image_info.size));
- if (ret != DCM_SUCCESS) {
- dcm_error("Failed dcm_decode_image! err: %d", ret);
- return ret;
- }
+ if (strcmp(scan_item->mime_type, MIME_TYPE_JPEG) == 0) {
+ image_format = DCM_IMAGE_FORMAT_RGB;
+ } else if (strcmp(scan_item->mime_type, MIME_TYPE_PNG) == 0) {
+ image_format = DCM_IMAGE_FORMAT_RGBA;
+ } else if (strcmp(scan_item->mime_type, MIME_TYPE_BMP) == 0) {
+ image_format = DCM_IMAGE_FORMAT_RGBA;
} else {
dcm_error("Failed not supported type! (%s)", scan_item->mime_type);
return DCM_ERROR_INVALID_PARAMETER;
}
+ ret = dcm_decode_image((const char *) (scan_item->file_path), image_format, scan_item->mime_type,
+ image_info.orientation, FALSE, &(image_info.pixel), &(image_info.size),
+ &(image_info.buffer_width), &(image_info.buffer_height));
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed dcm_decode_image! err: %d", ret);
+ return ret;
+ }
+
image_info.decode_type = (DcmImageDecodeType)image_format;
- dcm_debug("Image info width: %d, height: %d, buf_width: %d, buf_height: %d, orientation: %d",
- image_info.original_width, image_info.original_height, image_info.buffer_width, image_info.buffer_height, image_info.orientation);
+ dcm_debug("Image info width: %d, height: %d, buf_width: %d, buf_height: %d",
+ image_info.original_width, image_info.original_height, image_info.buffer_width, image_info.buffer_height);
/* Process face scan */
ret = DcmFaceUtils::runFaceRecognizeProcess(scan_item, &image_info);
- if (ret != DCM_SUCCESS) {
+ if (ret != DCM_SUCCESS)
dcm_error("Failed to process face detection! err: %d", ret);
- }
#if 0
/* Process color extract */