Added imgcv to be used for color extraction 89/51289/1 accepted/tizen/mobile/20151111.044107 accepted/tizen/tv/20151111.044112 accepted/tizen/wearable/20151111.044123 submit/tizen/20151110.064449
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 6 Nov 2015 07:59:09 +0000 (16:59 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 6 Nov 2015 07:59:58 +0000 (16:59 +0900)
Change-Id: Ic7381356a4e6f91dfa2162e6476f6b232bac21b6
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
Makefile.am
configure.ac
imgcv/Makefile.am [new file with mode: 0755]
imgcv/include/mm_util_imgcv.h [new file with mode: 0755]
imgcv/include/mm_util_imgcv_internal.h [new file with mode: 0755]
imgcv/mm_util_imgcv.c [new file with mode: 0755]
imgcv/mmutil-imgcv.pc.in [new file with mode: 0755]
imgcv/test/Makefile.am [new file with mode: 0755]
imgcv/test/mm_util_imgcv_testsuite.c [new file with mode: 0755]
packaging/libmm-utility.spec

index ced4f43..a4747a2 100755 (executable)
@@ -5,11 +5,12 @@ ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = \
        imgp \
-       jpeg 
-       
+       jpeg \
+       imgcv
 DIST_SUBDIRS = \
        imgp \
-       jpeg 
+       jpeg \
+       imgcv
 
 EXTRA_DIST = \
        configure.ac autogen.sh depcomp
index 6aba095..83b15c8 100755 (executable)
@@ -57,6 +57,10 @@ PKG_CHECK_MODULES(TBM, libtbm)
 AC_SUBST(TBM_CFLAGS)
 AC_SUBST(TBM_LIBS)
 
+PKG_CHECK_MODULES(OPENCV, opencv)
+AC_SUBST(OPENCV_CFLAGS)
+AC_SUBST(OPENCV_LIBS)
+
 PKG_CHECK_MODULES(SYSTEMINFO, capi-system-info)
 AC_SUBST(SYSTEMINFO_CFLAGS)
 AC_SUBST(SYSTEMINFO_LIBS)
@@ -76,6 +80,9 @@ AC_CONFIG_FILES([Makefile
                 jpeg/Makefile
                 jpeg/test/Makefile
                 jpeg/mmutil-jpeg.pc
+                imgcv/Makefile
+                imgcv/test/Makefile
+                imgcv/mmutil-imgcv.pc
                 test/Makefile
 ])
 
diff --git a/imgcv/Makefile.am b/imgcv/Makefile.am
new file mode 100755 (executable)
index 0000000..51f0f21
--- /dev/null
@@ -0,0 +1,31 @@
+ACLOCAL_AMFLAGS='-I m4'
+
+lib_LTLIBRARIES = libmmutil_imgcv.la
+
+installmmutil_imgcvdir = $(includedir)/mmf
+installmmutil_imgcv_HEADERS = include/mm_util_imgcv.h
+noinst_HEADERS = include/mm_util_imgcv_internal.h
+
+libmmutil_imgcv_la_SOURCES = mm_util_imgcv.c
+
+libmmutil_imgcv_la_CFLAGS = -I$(srcdir)/include \
+                          -I$(includedir)/drm \
+                          $(MMCOMMON_CFLAGS) \
+                           $(GLIB_CFLAGS) \
+                           $(GMODULE_CFLAGS) \
+                                                  $(OPENCV_CFLAGS) \
+                           $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\"
+
+libmmutil_imgcv_la_LIBADD = $(MMCOMMON_LIBS) \
+                           $(GLIB_LIBS) \
+                           $(GMODULE_LIBS) \
+                                                  $(OPENCV_LIBS) \
+                           $(MMLOG_LIBS)
+
+libmmutil_imgcv_la_CFLAGS += -lttrace $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -DLIBPREFIX=\"$(libdir)\"
+
+pcfiles = mmutil-imgcv.pc
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(pcfiles)
+EXTRA_DIST = $(pcfiles)
+#SUBDIRS = . test
diff --git a/imgcv/include/mm_util_imgcv.h b/imgcv/include/mm_util_imgcv.h
new file mode 100755 (executable)
index 0000000..911ade1
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd., Ltd. All rights reserved.
+ * Contact: Tae-Young Chung <yh8004.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __MM_UTILITY_IMGCV_H__
+#define __MM_UTILITY_IMGCV_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mm_types.h>
+
+/**
+    @addtogroup UTILITY
+    @{
+
+    @par
+    This part describes the APIs with repect to image color processing library.
+ */
+
+int mm_util_cv_extract_representative_color(void *image_buffer, int width, int height, unsigned char *r_color, unsigned char *g_color, unsigned char *b_color);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__MM_UTILITY_IMGP_H__*/
diff --git a/imgcv/include/mm_util_imgcv_internal.h b/imgcv/include/mm_util_imgcv_internal.h
new file mode 100755 (executable)
index 0000000..5dfa43d
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include "mm_util_imgcv.h"
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+#include <gmodule.h>
+#include <mm_debug.h>
+#include <mm_types.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+
+#include <opencv/cv.h>
+#include <opencv2/imgproc/imgproc_c.h>
+
+typedef struct _mm_util_imgcv_s
+{
+       IplImage *inImg;
+
+       int hBins; /**< Number of bins of Hue channle */
+       int sBins; /**< Number of bins of Saturation channle */
+       int vBins; /**< Number of bins of Value channle */
+
+       float hRanges[2]; /**< Range of Hues */
+       float sRanges[2]; /**< Range of Saturation */
+       float vRanges[2]; /**< Range of Value */
+
+       int sizeOfHist[3]; /**< array of bins; hBins,sBins,vBins */
+
+       int width;
+       int height;
+
+} mm_util_imgcv_s;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/imgcv/mm_util_imgcv.c b/imgcv/mm_util_imgcv.c
new file mode 100755 (executable)
index 0000000..e0d1257
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: YoungHun Kim <yh8004.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <limits.h>
+#include <math.h>
+#include <mm_debug.h>
+#include "mm_util_imgcv.h"
+#include "mm_util_imgcv_internal.h"
+#include <gmodule.h>
+#include <mm_error.h>
+#ifdef ENABLE_TTRACE
+#include <ttrace.h>
+#define TTRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_IMAGE, NAME)
+#define TTRACE_END() traceEnd(TTRACE_TAG_IMAGE)
+#else //ENABLE_TTRACE
+#define TTRACE_BEGIN(NAME)
+#define TTRACE_END()
+#endif //ENABLE_TTRACE
+
+#define RGB_COLOR_CHANNELS 3
+#define HSV_COLOR_CHANNELS 3
+
+#define HISTOGRAM_CHANNELS 3
+#define DEFAULT_NUM_HBINS 30
+#define DEFAULT_NUM_SBINS 32
+#define DEFAULT_NUM_VBINS 30
+
+#define DEFAULT_RANGE_HUE 180
+#define DEFAULT_RANGE_SATURATION 256
+#define DEFAULT_RANGE_VALUE 256
+
+static int _mm_util_imgcv_init(mm_util_imgcv_s *handle, int width, int height)
+{
+       debug_log("Enter _mm_util_imgcv_init");
+
+       handle->width = width;
+       handle->height = height;
+
+       handle->inImg = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, RGB_COLOR_CHANNELS);
+       if (handle->inImg == NULL) {
+               return MM_ERROR_IMAGE_INTERNAL;
+       }
+
+       handle->hBins = DEFAULT_NUM_HBINS;
+       handle->sBins = DEFAULT_NUM_SBINS;
+       handle->vBins = DEFAULT_NUM_VBINS;
+
+       handle->sizeOfHist[0] = handle->hBins;
+       handle->sizeOfHist[1] = handle->sBins;
+       handle->sizeOfHist[2] = handle->vBins;
+
+       handle->hRanges[0] = 0;
+       handle->hRanges[1] = DEFAULT_RANGE_HUE;
+       handle->sRanges[0] = 0;
+       handle->sRanges[1] = DEFAULT_RANGE_SATURATION;
+       handle->vRanges[0] = 0;
+       handle->vRanges[1] = DEFAULT_RANGE_VALUE;
+
+       debug_log("Leave _mm_util_imgcv_uninit");
+
+       return MM_ERROR_NONE;
+}
+
+static void _mm_util_imgcv_uninit(mm_util_imgcv_s *handle)
+{
+       debug_log("Enter _mm_util_imgcv_uninit");
+
+       if (handle->inImg != NULL) {
+               cvReleaseImageHeader(&handle->inImg);
+               handle->inImg = NULL;
+       }
+
+       debug_log("Leave _mm_util_imgcv_uninit");
+}
+
+static int _mm_util_imgcv_set_buffer(mm_util_imgcv_s *handle, void *image_buffer)
+{
+       debug_log("Enter _mm_util_imgcv_set_buffer");
+
+       unsigned char *buffer = (unsigned char *)image_buffer;
+
+       debug_log("image_buffer [%p], width [%d]", buffer, handle->width);
+
+       cvSetData(handle->inImg, buffer, RGB_COLOR_CHANNELS*(handle->width));
+       if (handle->inImg == NULL) {
+               return  MM_ERROR_IMAGE_INTERNAL;
+       }
+
+       debug_log("Leave _mm_util_imgcv_set_buffer");
+
+       return MM_ERROR_NONE;
+}
+
+static void _convert_hsv_to_rgb(int hVal, int sVal, int vVal, float *rVal, float *gVal, float *bVal)
+{
+       debug_log("Enter _convert_hsv_to_rgb");
+
+       CvMat *mat1 = cvCreateMat(1,1,CV_8UC3);
+       cvSet2D(mat1, 0, 0, cvScalar((double)hVal, (double)sVal, (double)vVal, 0.0));
+
+       CvMat *mat2 = cvCreateMat(1,1,CV_8UC3);
+
+       cvCvtColor(mat1, mat2, CV_HSV2BGR);
+
+       CvScalar bgr = cvGet2D(mat2, 0, 0);
+       *bVal = (float)bgr.val[0];
+       *gVal = (float)bgr.val[1];
+       *rVal = (float)bgr.val[2];
+
+       debug_log("from HSV[%f, %f, %f]", (float)hVal, (float)sVal, (float)vVal);
+       debug_log("to BGR[%f, %f, %f]", *bVal, *gVal, *rVal);
+
+       debug_log("Leave _convert_hsv_to_rgb");
+}
+
+static int _mm_util_imgcv_calculate_hist(mm_util_imgcv_s *handle, unsigned char *rgb_r, unsigned char *rgb_g, unsigned char *rgb_b)
+{
+       debug_log("Enter _mm_util_imgcv_calculate_hist");
+
+       int nh = 0;
+       int ns = 0;
+       int nv = 0;
+
+       int hVal = 0;
+       int sVal = 0;
+       int vVal = 0;
+
+       float rVal = 0.f;
+    float gVal = 0.f;
+    float bVal = 0.f;
+
+       unsigned int maxBinVal = 0;
+       int max_bin_idx[3] = {-1, -1, -1};
+
+       IplImage *hsvImg = cvCreateImage(cvSize(handle->width, handle->height), IPL_DEPTH_8U, HSV_COLOR_CHANNELS);
+       IplImage *hImg = cvCreateImage(cvSize(handle->width, handle->height), IPL_DEPTH_8U, 1);
+       IplImage *sImg = cvCreateImage(cvSize(handle->width, handle->height), IPL_DEPTH_8U, 1);
+       IplImage *vImg = cvCreateImage(cvSize(handle->width, handle->height), IPL_DEPTH_8U, 1);
+
+       if (!hsvImg || !hImg || !sImg || !vImg) {
+               debug_error("fail to cvCreateImage()\n");
+               return MM_ERROR_IMAGE_INTERNAL;
+       }
+
+       IplImage *planes [] = {hImg, sImg, vImg};
+
+       cvCvtColor(handle->inImg, hsvImg, CV_RGB2HSV);
+       cvSplit(hsvImg, hImg, sImg, vImg, NULL);
+
+       float * ranges[] = {handle->hRanges, handle->sRanges, handle->vRanges};
+       int histsize[] = {handle->sizeOfHist[0], handle->sizeOfHist[1], handle->sizeOfHist[2]};
+
+       /* create histogram*/
+       CvHistogram *hist = cvCreateHist(HISTOGRAM_CHANNELS, histsize, CV_HIST_ARRAY, ranges, 1);
+       if (hist == NULL) {
+               return MM_ERROR_IMAGE_INTERNAL;
+       }
+
+       cvCalcHist(planes, hist, 0, NULL);
+
+       for (nh=0; nh<(handle->hBins); nh++) {
+               for (ns=0; ns<(handle->sBins); ns++) {
+                       for (nv=0; nv<(handle->vBins); nv++) {
+                               unsigned int binVal = (unsigned int)cvGetReal3D( (hist)->bins, nh, ns, nv);
+                               if (binVal > maxBinVal) {
+                                       maxBinVal = binVal;
+                                       max_bin_idx[0] = nh;
+                                       max_bin_idx[1] = ns;
+                                       max_bin_idx[2] = nv;
+                               }
+                       }
+               }
+       }
+
+       rVal = gVal = bVal = 0.0f;
+       hVal = cvRound((max_bin_idx[0]+1)*(handle->hRanges[1]/(float)handle->hBins));
+       sVal = cvRound((max_bin_idx[1]+1)*(handle->sRanges[1]/(float)handle->sBins));
+       vVal = cvRound((max_bin_idx[2]+1)*(handle->vRanges[1]/(float)handle->vBins));
+
+       _convert_hsv_to_rgb(hVal, sVal, vVal, &rVal, &gVal, &bVal);
+
+       debug_log("nh[%d], ns[%d], nv[%d]\n", max_bin_idx[0], max_bin_idx[1], max_bin_idx[2]);
+       debug_log("h[%d], s[%d], v[%d]\n", hVal, sVal, vVal);
+       *rgb_r = rVal;
+       *rgb_g = gVal;
+       *rgb_b = bVal;
+
+       cvReleaseImage(&hsvImg);
+       cvReleaseImage(&hImg);
+       cvReleaseImage(&sImg);
+       cvReleaseImage(&vImg);
+
+       cvReleaseHist(&hist);
+
+       debug_log("Leave _mm_util_imgcv_calculate_hist");
+
+       return MM_ERROR_NONE;
+}
+
+int mm_util_cv_extract_representative_color(void *image_buffer, int width, int height, unsigned char *r_color, unsigned char *g_color, unsigned char *b_color)
+{
+       debug_log("Enter mm_util_cv_extract_representative_color");
+       if (image_buffer == NULL) {
+               debug_error("#ERROR#: image buffer is NULL");
+
+               return MM_ERROR_IMAGE_INVALID_VALUE;
+       }
+
+       mm_util_imgcv_s *handle = (mm_util_imgcv_s *)malloc(sizeof(mm_util_imgcv_s));
+       if (handle == NULL) {
+               debug_error("#ERROR#: fail to create handle");
+
+               return MM_ERROR_IMAGE_NO_FREE_SPACE;
+       }
+
+       int ret = _mm_util_imgcv_init(handle, width, height);
+       if (ret != MM_ERROR_NONE) {
+               _mm_util_imgcv_uninit(handle);
+               free(handle);
+               handle = NULL;
+
+               debug_error("#ERROR#: Fail to mm_util_imgcv_init: ret=%d", ret);
+
+               return ret;
+       }
+
+       ret = _mm_util_imgcv_set_buffer(handle, image_buffer);
+       if (ret != MM_ERROR_NONE) {
+               _mm_util_imgcv_uninit(handle);
+               free(handle);
+               handle = NULL;
+
+               debug_error("#ERROR#: Fail to mm_util_imgcv_set_buffer: ret=%d", ret);
+
+               return ret;
+       }
+
+       ret = _mm_util_imgcv_calculate_hist(handle, r_color, g_color, b_color);
+       if (ret != MM_ERROR_NONE) {
+               _mm_util_imgcv_uninit(handle);
+               free(handle);
+               handle = NULL;
+
+               debug_error("#ERROR#: Fail to mm_util_imgcv_calculate_hist: ret=%d", ret);
+
+               return ret;
+       }
+
+       _mm_util_imgcv_uninit(handle);
+
+       free(handle);
+       handle = NULL;
+
+       debug_log("Leave mm_util_cv_extract_representative_color");
+
+       return MM_ERROR_NONE;
+}
diff --git a/imgcv/mmutil-imgcv.pc.in b/imgcv/mmutil-imgcv.pc.in
new file mode 100755 (executable)
index 0000000..a8cd580
--- /dev/null
@@ -0,0 +1,12 @@
+prefix = @prefix@
+exec_prefix=@exec_prefix@
+libdir = @libdir@
+includedir = @includedir@
+
+Name : mmutil-imgcv
+Description : Multimedia Framework Utility Library
+Requires : @IMGCV_REQPKG@ mm-common opencv
+Version : @VERSION@
+Libs : -L${libdir} -lmmutil_imgcv
+Cflags : -I${includedir}/mmf -DLIBPREFIX=\"${libdir}\"
+
diff --git a/imgcv/test/Makefile.am b/imgcv/test/Makefile.am
new file mode 100755 (executable)
index 0000000..2b65344
--- /dev/null
@@ -0,0 +1,18 @@
+bin_PROGRAMS = mm_util_imgcv_testsuite
+
+mm_util_imgcv_testsuite_SOURCES = mm_util_imgcv_testsuite.c
+
+mm_util_imgcv_testsuite_CFLAGS = -I$(srcdir)/../include \
+                                                                -I$(srcdir)/../../jpeg/include \
+                                 $(MMCOMMON_CFLAGS) \
+                                 $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -fPIE -pie
+
+############################################
+
+mm_util_imgcv_testsuite_DEPENDENCIES = $(srcdir)/../libmmutil_imgcv.la
+mm_util_imgcv_testsuite_DEPENDENCIES += $(srcdir)/../../jpeg/libmmutil_jpeg.la
+
+mm_util_imgcv_testsuite_LDADD = $(srcdir)/../libmmutil_imgcv.la \
+                                 $(srcdir)/../../jpeg/libmmutil_jpeg.la \
+                                 $(MMCOMMON_LIBS)
+
diff --git a/imgcv/test/mm_util_imgcv_testsuite.c b/imgcv/test/mm_util_imgcv_testsuite.c
new file mode 100755 (executable)
index 0000000..b1e9a18
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * libmm-utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Tae-Young Chung <ty83.chung@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "mm_util_jpeg.h"
+#include <mm_util_imgcv.h>
+#include <mm_util_imgcv_internal.h>
+#include <mm_error.h>
+
+#define MAX_FILENAME_LEN 1024
+
+int main(int argc, char *argv[])
+{
+       int ret = 0;
+       int width;
+       int height;
+       int len;
+
+       unsigned char *img_buffer;
+       unsigned int  img_buffer_size;
+
+       char filename [MAX_FILENAME_LEN];
+
+       if (argc < 1) {
+               debug_error("[%s][%05d] Usage: ./mm_imgcv_testsuite filename(jpg format only)\n");
+               return ret;
+       }
+
+       len = strlen(argv[1]);
+       if (len > MAX_FILENAME_LEN) {
+               debug_error("[%s] filename is too long\n");
+               return -1;
+       }
+
+       strncpy(filename, argv[1], len);
+       debug_log("Filename is %s\n", filename);
+
+       /* decode jpg image */
+       mm_util_jpeg_yuv_data decoded;
+       memset(&decoded, 0, sizeof(mm_util_jpeg_yuv_data));
+
+       ret = mm_util_decode_from_jpeg_file(&decoded, filename, MM_UTIL_JPEG_FMT_RGB888);
+
+       if (ret == MM_ERROR_NONE) {
+               img_buffer = decoded.data;
+               width = decoded.width;
+               height = decoded.height;
+               img_buffer_size = decoded.size;
+               debug_log("Success - buffer[%p], width[%d], height[%d], size[%d]",
+                                                               img_buffer, width, height, img_buffer_size);
+       } else {
+               debug_log("ERROR - Fail to decode jpeg image file");
+               return ret;
+       }
+
+       /* extract color */
+       unsigned char rgb_r, rgb_g, rgb_b;
+       ret = image_util_color_extract_from_buffer(img_buffer, width, height, MM_UTIL_IMGCV_FMT_RGB888, &rgb_r, &rgb_g, &rgb_b);
+
+       if (ret == MM_ERROR_NONE) {
+               debug_log("Success - R[%d], G[%d], B[%d]", rgb_r, rgb_g, rgb_b);
+       } else {
+               debug_log("Error - fail to extract color");
+       }
+
+       free(img_buffer);
+       img_buffer = NULL;
+
+       return ret;
+}
+
index 3424e0b..f7442d8 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.16
+Version:    0.17
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
@@ -17,6 +17,7 @@ BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(capi-media-tool)
 BuildRequires:  pkgconfig(libtbm)
 BuildRequires:  pkgconfig(libexif)
+BuildRequires:  pkgconfig(opencv)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(ttrace)
 BuildRoot:  %{_tmppath}/%{name}-%{version}-build
@@ -57,6 +58,7 @@ LDFLAGS="$LDFLAGS -Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed"
 
 sed -i -e "s#@IMGP_REQPKG@#$IMGP_REQPKG#g" imgp/mmutil-imgp.pc
 sed -i -e "s#@JPEG_REQPKG@#$JPEG_REQPKG#g" jpeg/mmutil-jpeg.pc
+sed -i -e "s#@IMGCV_REQPKG@#$IMGCV_REQPKG#g" imgcv/mmutil-imgcv.pc
 
 %install
 rm -rf %{buildroot}