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");
68 tet_printf("Cannot load file. %s", filename);
69 tet_result(TET_UNRESOLVED);
78 face_rect_s *rects = NULL;
81 for ( i = 0; i < TESTVIDEO_FRAME; i++)
83 nRead = fread (YBuf, 1, nW * nH, fp );
85 if ( nRead != nW * nH )
88 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
89 tet_result(TET_UNRESOLVED);
93 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
95 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, NULL, &nCount );
96 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
98 face_image_destroy(image);
102 err = face_destroy(face);
108 static void utc_uix_face_detect_faces_from_video_stream_negative_02(void)
110 static const char szFunc[] = "face_detect_faces_from_video_stream";
116 err = face_create(&face);
118 char *filename = TESTVIDEO_NAME;
119 int nW = TESTVIDEO_WIDTH;
120 int nH = TESTVIDEO_HEIGHT;
122 unsigned char YBuf[nW*nH];
127 fp = fopen(filename, "rb");
130 tet_printf("Cannot load file. %s", filename);
131 tet_result(TET_UNRESOLVED);
140 face_rect_s *rects = NULL;
143 for ( i = 0; i < TESTVIDEO_FRAME; i++)
145 nRead = fread (YBuf, 1, nW * nH, fp );
147 if ( nRead != nW * nH )
150 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
151 tet_result(TET_UNRESOLVED);
155 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
157 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, NULL );
158 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
160 face_image_destroy(image);
163 err = face_destroy(face);
171 static void utc_uix_face_detect_faces_from_video_stream_negative_03(void)
173 static const char szFunc[] = "face_detect_faces_from_video_stream";
179 err = face_create(&face);
181 char *filename = TESTVIDEO_NAME;
182 int nW = TESTVIDEO_WIDTH;
183 int nH = TESTVIDEO_HEIGHT;
185 unsigned char YBuf[nW*nH];
190 fp = fopen(filename, "rb");
193 tet_printf("Cannot load file. %s", filename);
194 tet_result(TET_UNRESOLVED);
203 face_rect_s *rects = NULL;
206 for ( i = 0; i < TESTVIDEO_FRAME; i++)
208 nRead = fread (YBuf, 1, nW * nH, fp );
210 if ( nRead != nW * nH )
213 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
214 tet_result(TET_UNRESOLVED);
218 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
220 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, NULL, &rects, &nCount );
221 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
223 face_image_destroy(image);
226 err = face_destroy(face);
233 static void utc_uix_face_extract_component_negative_01(void)
235 static const char szFunc[] = "face_extract_component";
241 err = face_create(&face);
243 char *filename = TESTVIDEO_NAME;
244 int nW = TESTVIDEO_WIDTH;
245 int nH = TESTVIDEO_HEIGHT;
247 unsigned char YBuf[nW*nH];
252 fp = fopen(filename, "rb");
255 tet_printf("Cannot load file. %s", filename);
256 tet_result(TET_UNRESOLVED);
264 face_rect_s *rects = NULL;
265 face_component_h component;
269 for ( i = 0; i < TESTVIDEO_FRAME; i++)
271 nRead = fread (YBuf, 1, nW * nH, fp );
273 if ( nRead != nW * nH )
276 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
277 tet_result(TET_UNRESOLVED);
281 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
283 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
285 if ( err != FACE_ERROR_NONE )
287 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
288 tet_result(TET_UNRESOLVED);
297 err = face_extract_component(face, NULL, &rects[0], &component);
299 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
301 face_image_destroy(image);
305 face_component_destroy(component);
308 err = face_destroy(face);
314 static void utc_uix_face_extract_component_negative_02(void)
316 static const char szFunc[] = "face_extract_component";
322 err = face_create(&face);
324 char *filename = TESTVIDEO_NAME;
325 int nW = TESTVIDEO_WIDTH;
326 int nH = TESTVIDEO_HEIGHT;
328 unsigned char YBuf[nW*nH];
333 fp = fopen(filename, "rb");
336 tet_printf("Cannot load file. %s", filename);
337 tet_result(TET_UNRESOLVED);
345 face_rect_s *rects = NULL;
346 face_component_h component;
350 for ( i = 0; i < TESTVIDEO_FRAME; i++)
352 nRead = fread (YBuf, 1, nW * nH, fp );
354 if ( nRead != nW * nH )
357 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
358 tet_result(TET_UNRESOLVED);
362 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
364 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
366 if ( err != FACE_ERROR_NONE )
368 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
369 tet_result(TET_UNRESOLVED);
378 err = face_extract_component(face, image, NULL, &component);
380 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
382 face_image_destroy(image);
386 face_component_destroy(component);
389 err = face_destroy(face);
396 static void utc_uix_face_extract_component_negative_03(void)
398 static const char szFunc[] = "face_extract_component";
404 err = face_create(&face);
406 char *filename = TESTVIDEO_NAME;
407 int nW = TESTVIDEO_WIDTH;
408 int nH = TESTVIDEO_HEIGHT;
410 unsigned char YBuf[nW*nH];
415 fp = fopen(filename, "rb");
418 tet_printf("Cannot load file. %s", filename);
419 tet_result(TET_UNRESOLVED);
427 face_rect_s *rects = NULL;
428 face_component_h component;
432 for ( i = 0; i < TESTVIDEO_FRAME; i++)
434 nRead = fread (YBuf, 1, nW * nH, fp );
436 if ( nRead != nW * nH )
439 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
440 tet_result(TET_UNRESOLVED);
444 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
446 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
448 if ( err != FACE_ERROR_NONE )
450 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
451 tet_result(TET_UNRESOLVED);
460 err = face_extract_component(face, NULL, &rects[0], &component);
462 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
464 face_image_destroy(image);
468 face_component_destroy(component);
471 err = face_destroy(face);
477 static void utc_uix_face_extract_component_negative_04(void)
479 static const char szFunc[] = "face_extract_component";
485 err = face_create(&face);
487 char *filename = TESTVIDEO_NAME;
488 int nW = TESTVIDEO_WIDTH;
489 int nH = TESTVIDEO_HEIGHT;
491 unsigned char YBuf[nW*nH];
496 fp = fopen(filename, "rb");
499 tet_printf("Cannot load file. %s", filename);
500 tet_result(TET_UNRESOLVED);
508 face_rect_s *rects = NULL;
509 face_component_h component;
513 for ( i = 0; i < TESTVIDEO_FRAME; i++)
515 nRead = fread (YBuf, 1, nW * nH, fp );
517 if ( nRead != nW * nH )
520 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
521 tet_result(TET_UNRESOLVED);
525 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
527 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
529 if ( err != FACE_ERROR_NONE )
531 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
532 tet_result(TET_UNRESOLVED);
541 err = face_extract_component(face, image, &rects[0], NULL);
543 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
545 face_image_destroy(image);
549 face_component_destroy(component);
552 err = face_destroy(face);
557 static void utc_uix_face_extract_feature_negative_01(void)
559 static const char szFunc[] = "face_extract_feature";
565 err = face_create(&face);
567 char *filename = TESTVIDEO_NAME;
568 int nW = TESTVIDEO_WIDTH;
569 int nH = TESTVIDEO_HEIGHT;
571 unsigned char YBuf[nW*nH];
576 fp = fopen(filename, "rb");
579 tet_printf("Cannot load file. %s", filename);
580 tet_result(TET_UNRESOLVED);
588 face_rect_s *rects = NULL;
589 face_component_h component;
590 face_feature_h feature;
594 for ( i = 0; i < TESTVIDEO_FRAME; i++)
596 nRead = fread (YBuf, 1, nW * nH, fp );
598 if ( nRead != nW * nH )
601 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
602 tet_result(TET_UNRESOLVED);
606 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
608 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
610 if ( err != FACE_ERROR_NONE )
612 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
613 tet_result(TET_UNRESOLVED);
622 err = face_extract_component(face, image, &rects[0], &component);
624 err = face_extract_feature(face, image, NULL, &feature);
626 dts_check_ne(szFunc, err, FACE_ERROR_NONE); // Face feature func does not support continous frame
630 face_image_destroy(image);
632 face_component_destroy(component);
634 if ( feature != NULL ) face_feature_destroy(feature);
637 err = face_destroy(face);
644 static void utc_uix_face_recognize_blink_negative_01(void)
646 static const char szFunc[] = "face_recognize_blink";
652 err = face_create(&face);
654 char *filename = TESTVIDEO_NAME;
655 int nW = TESTVIDEO_WIDTH;
656 int nH = TESTVIDEO_HEIGHT;
658 unsigned char YBuf[nW*nH];
663 fp = fopen(filename, "rb");
666 tet_printf("Cannot load file. %s", filename);
667 tet_result(TET_UNRESOLVED);
675 face_rect_s *rects = NULL;
676 face_component_h component;
677 face_eye_state_e lefteye, righteye;
681 for ( i = 0; i < TESTVIDEO_FRAME; i++)
683 nRead = fread (YBuf, 1, nW * nH, fp );
685 if ( nRead != nW * nH )
688 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
689 tet_result(TET_UNRESOLVED);
693 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
695 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
697 if ( err != FACE_ERROR_NONE )
699 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
700 tet_result(TET_UNRESOLVED);
709 err = face_extract_component(face, image, &rects[0], &component);
711 err = face_recognize_blink(face, NULL, component, &lefteye, &righteye);
713 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
715 face_image_destroy(image);
718 face_component_destroy(component);
722 err = face_destroy(face);
728 static void utc_uix_face_recognize_expression_negative_01(void)
730 static const char szFunc[] = "face_recognize_expression";
736 err = face_create(&face);
738 char *filename = TESTVIDEO_NAME;
739 int nW = TESTVIDEO_WIDTH;
740 int nH = TESTVIDEO_HEIGHT;
742 unsigned char YBuf[nW*nH];
747 fp = fopen(filename, "rb");
750 tet_printf("Cannot load file. %s", filename);
751 tet_result(TET_UNRESOLVED);
759 face_rect_s *rects = NULL;
760 face_component_h component;
761 face_expression_e expr;
765 for ( i = 0; i < TESTVIDEO_FRAME; i++)
767 nRead = fread (YBuf, 1, nW * nH, fp );
769 if ( nRead != nW * nH )
772 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
773 tet_result(TET_UNRESOLVED);
777 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf, nW, nH, nW * nH, &image);
779 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
781 if ( err != FACE_ERROR_NONE )
783 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
784 tet_result(TET_UNRESOLVED);
793 err = face_extract_component(face, image, &rects[0], &component);
795 err = face_recognize_expression(face, image, NULL, &expr);
797 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
799 face_image_destroy(image);
802 face_component_destroy(component);
805 err = face_destroy(face);
811 static void utc_uix_face_get_movement_negative_01(void)
813 static const char szFunc[] = "face_get_movement";
819 err = face_create(&face);
821 char *filename = TESTVIDEO_NAME;
822 int nW = TESTVIDEO_WIDTH;
823 int nH = TESTVIDEO_HEIGHT;
825 unsigned char YBuf[2][TESTVIDEO_WIDTH*TESTVIDEO_HEIGHT];
830 fp = fopen(filename, "rb");
833 tet_printf("Cannot load file. %s", filename);
834 tet_result(TET_UNRESOLVED);
839 face_image_h prev_image;
843 face_rect_s *rects = NULL;
845 face_rect_s prev_rect;
846 face_rect_s cur_rect;
850 for ( i = 0; i < TESTVIDEO_FRAME; i++)
852 nRead = fread (YBuf[i%2], 1, nW * nH, fp );
854 if ( nRead != nW * nH )
857 tet_printf("Wanted %d bytes Read %d bytes\n", nW * nH, nRead);
858 tet_result(TET_UNRESOLVED);
863 face_image_create(FACE_IMAGE_COLORSPACE_LUMINANCE_ONLY, YBuf[i%2], nW, nH, nW * nH, &image);
865 err = face_detect_faces(face, FACE_IMAGE_TYPE_CONTINIOUS, image, &rects, &nCount );
867 if ( err != FACE_ERROR_NONE )
869 tet_printf("[F:%20s L%4d] Detect face Error! err=%d\n", __FUNCTION__, __LINE__, err);
870 tet_result(TET_UNRESOLVED);
877 // rects is NULL when count is 0
884 prev_rect = rects[0];
887 continue; // Skip first frame
890 err = face_get_movement(face, prev_image, NULL, NULL, &cur_rect);
892 dts_check_ne(szFunc, err, FACE_ERROR_NONE);
894 face_image_destroy(prev_image);
896 prev_rect = rects[0];
902 err = face_destroy(face);
909 struct tet_testlist tet_testlist[] = {
910 { utc_uix_face_detect_faces_from_video_stream_negative_01, 1},
911 { utc_uix_face_detect_faces_from_video_stream_negative_02, 1},
912 { utc_uix_face_detect_faces_from_video_stream_negative_03, 1},
913 { utc_uix_face_extract_component_negative_01, 2},
914 { utc_uix_face_extract_component_negative_02, 2},
915 { utc_uix_face_extract_component_negative_03, 2},
916 { utc_uix_face_extract_component_negative_04, 2},
917 { utc_uix_face_extract_feature_negative_01, 3},
918 { utc_uix_face_recognize_blink_negative_01, 4},
919 { utc_uix_face_recognize_expression_negative_01, 5},
920 { utc_uix_face_get_movement_negative_01, 6},