3 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * PROPRIETARY/CONFIDENTIAL
6 * This software is the confidential and proprietary information of SAMSUNG
7 * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
8 * this software is owned by Samsung and you shall not disclose such
9 * Confidential Information and shall use it only in accordance with the terms
10 * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
11 * make no representations or warranties about the suitability of the software,
12 * either express or implied, including but not limited to the implied
13 * warranties of merchantability, fitness for a particular purpose, or
14 * non-infringement. SAMSUNG shall not be liable for any damages suffered by
15 * licensee arising out of or related to this software.
23 static void startup(void);
24 static void cleanup(void);
26 void (*tet_startup)(void) = startup;
27 void (*tet_cleanup)(void) = cleanup;
30 #define TESTVIDEO_NAME (DATADIR"suzie_qcif.yuv")
31 #define TESTVIDEO_WIDTH (176)
32 #define TESTVIDEO_HEIGHT (144)
33 #define TESTVIDEO_FRAME (10)
35 static void startup(void)
37 // TODO : How to copy sample image????
40 static void cleanup(void)
46 static void utc_uix_face_detect_faces_from_video_stream_negative_01(void)
48 static const char szFunc[] = "face_detect_faces_from_video_stream";
54 err = face_create(&face);
56 char *filename = TESTVIDEO_NAME;
57 int nW = TESTVIDEO_WIDTH;
58 int nH = TESTVIDEO_HEIGHT;
60 unsigned char YBuf[nW*nH];
65 fp = fopen(filename, "rb");
72 face_rect_s *rects = NULL;
75 for ( i = 0; i < TESTVIDEO_FRAME; i++)
77 nRead = fread (YBuf, 1, nW * nH, fp );
79 if ( nRead != nW * nH )
82 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
83 tet_result(TET_UNRESOLVED);
87 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
89 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, NULL, &nCount );
90 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
92 face_image_destroy(image);
96 err = face_destroy(face);
102 static void utc_uix_face_detect_faces_from_video_stream_negative_02(void)
104 static const char szFunc[] = "face_detect_faces_from_video_stream";
110 err = face_create(&face);
112 char *filename = TESTVIDEO_NAME;
113 int nW = TESTVIDEO_WIDTH;
114 int nH = TESTVIDEO_HEIGHT;
116 unsigned char YBuf[nW*nH];
121 fp = fopen(filename, "rb");
128 face_rect_s *rects = NULL;
131 for ( i = 0; i < TESTVIDEO_FRAME; i++)
133 nRead = fread (YBuf, 1, nW * nH, fp );
135 if ( nRead != nW * nH )
138 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
139 tet_result(TET_UNRESOLVED);
143 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
145 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, NULL );
146 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
148 face_image_destroy(image);
151 err = face_destroy(face);
159 static void utc_uix_face_detect_faces_from_video_stream_negative_03(void)
161 static const char szFunc[] = "face_detect_faces_from_video_stream";
167 err = face_create(&face);
169 char *filename = TESTVIDEO_NAME;
170 int nW = TESTVIDEO_WIDTH;
171 int nH = TESTVIDEO_HEIGHT;
173 unsigned char YBuf[nW*nH];
178 fp = fopen(filename, "rb");
185 face_rect_s *rects = NULL;
188 for ( i = 0; i < TESTVIDEO_FRAME; i++)
190 nRead = fread (YBuf, 1, nW * nH, fp );
192 if ( nRead != nW * nH )
195 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
196 tet_result(TET_UNRESOLVED);
200 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
202 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, NULL, &rects, &nCount );
203 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
205 face_image_destroy(image);
208 err = face_destroy(face);
215 static void utc_uix_face_extract_component_negative_01(void)
217 static const char szFunc[] = "face_extract_component";
223 err = face_create(&face);
225 char *filename = TESTVIDEO_NAME;
226 int nW = TESTVIDEO_WIDTH;
227 int nH = TESTVIDEO_HEIGHT;
229 unsigned char YBuf[nW*nH];
234 fp = fopen(filename, "rb");
240 face_rect_s *rects = NULL;
241 face_component_h component;
245 for ( i = 0; i < TESTVIDEO_FRAME; i++)
247 nRead = fread (YBuf, 1, nW * nH, fp );
249 if ( nRead != nW * nH )
252 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
253 tet_result(TET_UNRESOLVED);
257 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
259 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
261 if ( err != FACE_ERROR_NONE )
263 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
264 tet_result(TET_UNRESOLVED);
273 err = face_extract_component(face, NULL, &rects[0], &component);
275 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
277 face_image_destroy(image);
281 face_component_destroy(component);
284 err = face_destroy(face);
290 static void utc_uix_face_extract_component_negative_02(void)
292 static const char szFunc[] = "face_extract_component";
298 err = face_create(&face);
300 char *filename = TESTVIDEO_NAME;
301 int nW = TESTVIDEO_WIDTH;
302 int nH = TESTVIDEO_HEIGHT;
304 unsigned char YBuf[nW*nH];
309 fp = fopen(filename, "rb");
315 face_rect_s *rects = NULL;
316 face_component_h component;
320 for ( i = 0; i < TESTVIDEO_FRAME; i++)
322 nRead = fread (YBuf, 1, nW * nH, fp );
324 if ( nRead != nW * nH )
327 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
328 tet_result(TET_UNRESOLVED);
332 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
334 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
336 if ( err != FACE_ERROR_NONE )
338 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
339 tet_result(TET_UNRESOLVED);
348 err = face_extract_component(face, image, NULL, &component);
350 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
352 face_image_destroy(image);
356 face_component_destroy(component);
359 err = face_destroy(face);
366 static void utc_uix_face_extract_component_negative_03(void)
368 static const char szFunc[] = "face_extract_component";
374 err = face_create(&face);
376 char *filename = TESTVIDEO_NAME;
377 int nW = TESTVIDEO_WIDTH;
378 int nH = TESTVIDEO_HEIGHT;
380 unsigned char YBuf[nW*nH];
385 fp = fopen(filename, "rb");
391 face_rect_s *rects = NULL;
392 face_component_h component;
396 for ( i = 0; i < TESTVIDEO_FRAME; i++)
398 nRead = fread (YBuf, 1, nW * nH, fp );
400 if ( nRead != nW * nH )
403 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
404 tet_result(TET_UNRESOLVED);
408 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
410 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
412 if ( err != FACE_ERROR_NONE )
414 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
415 tet_result(TET_UNRESOLVED);
424 err = face_extract_component(face, NULL, &rects[0], &component);
426 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
428 face_image_destroy(image);
432 face_component_destroy(component);
435 err = face_destroy(face);
441 static void utc_uix_face_extract_component_negative_04(void)
443 static const char szFunc[] = "face_extract_component";
449 err = face_create(&face);
451 char *filename = TESTVIDEO_NAME;
452 int nW = TESTVIDEO_WIDTH;
453 int nH = TESTVIDEO_HEIGHT;
455 unsigned char YBuf[nW*nH];
460 fp = fopen(filename, "rb");
466 face_rect_s *rects = NULL;
467 face_component_h component;
471 for ( i = 0; i < TESTVIDEO_FRAME; i++)
473 nRead = fread (YBuf, 1, nW * nH, fp );
475 if ( nRead != nW * nH )
478 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
479 tet_result(TET_UNRESOLVED);
483 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
485 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
487 if ( err != FACE_ERROR_NONE )
489 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
490 tet_result(TET_UNRESOLVED);
499 err = face_extract_component(face, image, &rects[0], NULL);
501 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
503 face_image_destroy(image);
507 face_component_destroy(component);
510 err = face_destroy(face);
515 static void utc_uix_face_extract_feature_negative_01(void)
517 static const char szFunc[] = "face_extract_feature";
523 err = face_create(&face);
525 char *filename = TESTVIDEO_NAME;
526 int nW = TESTVIDEO_WIDTH;
527 int nH = TESTVIDEO_HEIGHT;
529 unsigned char YBuf[nW*nH];
534 fp = fopen(filename, "rb");
540 face_rect_s *rects = NULL;
541 face_component_h component;
542 face_feature_h feature;
546 for ( i = 0; i < TESTVIDEO_FRAME; i++)
548 nRead = fread (YBuf, 1, nW * nH, fp );
550 if ( nRead != nW * nH )
553 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
554 tet_result(TET_UNRESOLVED);
558 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
560 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
562 if ( err != FACE_ERROR_NONE )
564 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
565 tet_result(TET_UNRESOLVED);
574 err = face_extract_component(face, image, &rects[0], &component);
576 err = face_extract_feature(face, image, NULL, &feature);
578 dts_check_ne(szFunc, err, FACE_ERROR_NONE); // Face feature func does not support continous frame
582 face_image_destroy(image);
584 face_component_destroy(component);
586 if ( feature != NULL ) face_feature_destroy(feature);
589 err = face_destroy(face);
596 static void utc_uix_face_recognize_blink_negative_01(void)
598 static const char szFunc[] = "face_recognize_blink";
604 err = face_create(&face);
606 char *filename = TESTVIDEO_NAME;
607 int nW = TESTVIDEO_WIDTH;
608 int nH = TESTVIDEO_HEIGHT;
610 unsigned char YBuf[nW*nH];
615 fp = fopen(filename, "rb");
621 face_rect_s *rects = NULL;
622 face_component_h component;
623 face_eye_state_e lefteye, righteye;
627 for ( i = 0; i < TESTVIDEO_FRAME; i++)
629 nRead = fread (YBuf, 1, nW * nH, fp );
631 if ( nRead != nW * nH )
634 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
635 tet_result(TET_UNRESOLVED);
639 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
641 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
643 if ( err != FACE_ERROR_NONE )
645 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
646 tet_result(TET_UNRESOLVED);
655 err = face_extract_component(face, image, &rects[0], &component);
657 err = face_recognize_blink(face, NULL, component, &lefteye, &righteye);
659 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
661 face_image_destroy(image);
664 face_component_destroy(component);
668 err = face_destroy(face);
674 static void utc_uix_face_recognize_expression_negative_01(void)
676 static const char szFunc[] = "face_recognize_expression";
682 err = face_create(&face);
684 char *filename = TESTVIDEO_NAME;
685 int nW = TESTVIDEO_WIDTH;
686 int nH = TESTVIDEO_HEIGHT;
688 unsigned char YBuf[nW*nH];
693 fp = fopen(filename, "rb");
699 face_rect_s *rects = NULL;
700 face_component_h component;
701 face_expression_e expr;
705 for ( i = 0; i < TESTVIDEO_FRAME; i++)
707 nRead = fread (YBuf, 1, nW * nH, fp );
709 if ( nRead != nW * nH )
712 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
713 tet_result(TET_UNRESOLVED);
717 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
719 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
721 if ( err != FACE_ERROR_NONE )
723 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
724 tet_result(TET_UNRESOLVED);
733 err = face_extract_component(face, image, &rects[0], &component);
735 err = face_recognize_expression(face, image, NULL, &expr);
737 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
739 face_image_destroy(image);
742 face_component_destroy(component);
745 err = face_destroy(face);
751 static void utc_uix_face_get_movement_negative_01(void)
753 static const char szFunc[] = "face_get_movement";
759 err = face_create(&face);
761 char *filename = TESTVIDEO_NAME;
762 int nW = TESTVIDEO_WIDTH;
763 int nH = TESTVIDEO_HEIGHT;
765 unsigned char YBuf[2][TESTVIDEO_WIDTH*TESTVIDEO_HEIGHT];
770 fp = fopen(filename, "rb");
773 face_image_h prev_image;
777 face_rect_s *rects = NULL;
779 face_rect_s prev_rect;
780 face_rect_s cur_rect;
784 for ( i = 0; i < TESTVIDEO_FRAME; i++)
786 nRead = fread (YBuf[i%2], 1, nW * nH, fp );
788 if ( nRead != nW * nH )
791 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
792 tet_result(TET_UNRESOLVED);
797 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf[i%2], nW, nH, nW * nH, &image);
799 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
801 if ( err != FACE_ERROR_NONE )
803 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
804 tet_result(TET_UNRESOLVED);
811 // rects is NULL when count is 0
818 prev_rect = rects[0];
821 continue; // Skip first frame
824 err = face_get_movement(face, prev_image, NULL, NULL, &cur_rect);
826 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
828 face_image_destroy(prev_image);
830 prev_rect = rects[0];
836 err = face_destroy(face);
843 struct tet_testlist tet_testlist[] = {
844 { utc_uix_face_detect_faces_from_video_stream_negative_01, 1},
845 { utc_uix_face_detect_faces_from_video_stream_negative_02, 1},
846 { utc_uix_face_detect_faces_from_video_stream_negative_03, 1},
847 { utc_uix_face_extract_component_negative_01, 2},
848 { utc_uix_face_extract_component_negative_02, 2},
849 { utc_uix_face_extract_component_negative_03, 2},
850 { utc_uix_face_extract_component_negative_04, 2},
851 { utc_uix_face_extract_feature_negative_01, 3},
852 { utc_uix_face_recognize_blink_negative_01, 4},
853 { utc_uix_face_recognize_expression_negative_01, 5},
854 { utc_uix_face_get_movement_negative_01, 6},