From f4126e4d894fd9ca143792cf09b7466b0e890f6c Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Wed, 15 Nov 2017 08:48:47 +0900 Subject: [PATCH] Remove user_marked field in face table Add face scan status for distinguish between file changes and re-scans. - file modified time > face detected time : file is changed - face detected time == 0 : some detected faces are removed by user Change logic to re-scan: - Do not delete, add missing. Delete is performed only when the file is modified. - Delete unnecessary fields (user_marked) Change-Id: I293a3bbbf62ef22c66b74243a6e4554ac69974cc Signed-off-by: Minje Ahn --- include/media_info_private.h | 6 +++--- include_product/media_info_private.h | 6 +++--- src/media_face.c | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/media_info_private.h b/include/media_info_private.h index f3d424f..7a4c275 100755 --- a/include/media_info_private.h +++ b/include/media_info_private.h @@ -657,7 +657,7 @@ typedef struct _media_content_cb_data { /* Face */ #define DELETE_FACE_FROM_FACE "DELETE FROM "DB_TABLE_FACE" WHERE face_id=%d" -#define INSERT_FACE_TO_FACE "INSERT INTO "DB_TABLE_FACE" (media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag, user_marked) VALUES ('%q', %d, %d, %d, %d, %d, %Q, 1);" +#define INSERT_FACE_TO_FACE "INSERT INTO "DB_TABLE_FACE" (media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag) VALUES ('%q', %d, %d, %d, %d, %d, %Q);" #define UPDATE_FACE_TO_FACE "UPDATE "DB_TABLE_FACE" SET face_rect_x=%d, face_rect_y=%d, face_rect_w=%d, face_rect_h=%d, orientation=%d, face_tag=%Q WHERE face_id=%d" #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q' AND validity=1" #define SELECT_FACE_COUNT "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN @@ -665,9 +665,9 @@ typedef struct _media_content_cb_data { #define SELECT_FACE_LIST "SELECT fa.face_id, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN #define SELECT_FACE_LIST_BY_MEDIA_ID "SELECT fa.face_id, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'" #define SELECT_FACE_PATH_FROM_MEDIA "SELECT path FROM "DB_TABLE_MEDIA_VIEW" media_uuid='%s'" -#define SELECT_MEDIA_FROM_FACE "SELECT media_uuid FROM "DB_TABLE_FACE" WHERE face_id=%d AND user_marked = 0" +#define SELECT_MEDIA_FROM_FACE "SELECT media_uuid FROM "DB_TABLE_FACE" WHERE face_id=%d" #define UPDATE_MEDIA_INFO_IN_FACE_SCAN_LIST "UPDATE "DB_TABLE_FACE_SCAN_LIST" SET modified_time = 0 WHERE media_uuid='%q'" -#define SELECT_FACE_ID_USER_MARKED "SELECT face_id FROM "DB_TABLE_FACE" WHERE media_uuid='%q' AND face_rect_x=%d AND face_rect_y=%d AND face_rect_w=%d AND face_rect_h=%d AND orientation=%d AND user_marked=1" +#define SELECT_FACE_ID "SELECT face_id FROM "DB_TABLE_FACE" WHERE media_uuid='%q' AND face_rect_x=%d AND face_rect_y=%d AND face_rect_w=%d AND face_rect_h=%d AND orientation=%d" #define DEFAULT_MEDIA_STORAGE_ID "media" diff --git a/include_product/media_info_private.h b/include_product/media_info_private.h index 1df829b..63d9ef6 100755 --- a/include_product/media_info_private.h +++ b/include_product/media_info_private.h @@ -827,7 +827,7 @@ typedef struct _media_content_scan_cb_data_v2 { /* Face */ #define DELETE_FACE_FROM_FACE "DELETE FROM "DB_TABLE_FACE" WHERE face_id=%d" -#define INSERT_FACE_TO_FACE "INSERT INTO "DB_TABLE_FACE" (media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag, user_marked) VALUES ('%q', %d, %d, %d, %d, %d, %Q, 1);" +#define INSERT_FACE_TO_FACE "INSERT INTO "DB_TABLE_FACE" (media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag) VALUES ('%q', %d, %d, %d, %d, %d, %Q);" #define UPDATE_FACE_TO_FACE "UPDATE "DB_TABLE_FACE" SET face_rect_x=%d, face_rect_y=%d, face_rect_w=%d, face_rect_h=%d, orientation=%d, face_tag=%Q WHERE face_id=%d" #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q' AND validity=1" #define SELECT_FACE_COUNT "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN @@ -835,9 +835,9 @@ typedef struct _media_content_scan_cb_data_v2 { #define SELECT_FACE_LIST "SELECT fa.face_id, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN #define SELECT_FACE_LIST_BY_MEDIA_ID "SELECT fa.face_id, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'" #define SELECT_FACE_PATH_FROM_MEDIA "SELECT path FROM "DB_TABLE_MEDIA_VIEW" media_uuid='%s'" -#define SELECT_MEDIA_FROM_FACE "SELECT media_uuid FROM "DB_TABLE_FACE" WHERE face_id=%d AND user_marked = 0" +#define SELECT_MEDIA_FROM_FACE "SELECT media_uuid FROM "DB_TABLE_FACE" WHERE face_id=%d" #define UPDATE_MEDIA_INFO_IN_FACE_SCAN_LIST "UPDATE "DB_TABLE_FACE_SCAN_LIST" SET modified_time = 0 WHERE media_uuid='%q'" -#define SELECT_FACE_ID_USER_MARKED "SELECT face_id FROM "DB_TABLE_FACE" WHERE media_uuid='%q' AND face_rect_x=%d AND face_rect_y=%d AND face_rect_w=%d AND face_rect_h=%d AND orientation=%d AND user_marked=1" +#define SELECT_FACE_ID "SELECT face_id FROM "DB_TABLE_FACE" WHERE media_uuid='%q' AND face_rect_x=%d AND face_rect_y=%d AND face_rect_w=%d AND face_rect_h=%d AND orientation=%d" #define DEFAULT_MEDIA_STORAGE_ID "media" diff --git a/src/media_face.c b/src/media_face.c index a6bb244..4963e18 100755 --- a/src/media_face.c +++ b/src/media_face.c @@ -257,7 +257,7 @@ int media_face_insert_to_db(media_face_h face) ret = _content_query_sql(query_str); SQLITE3_SAFE_FREE(query_str); - query_str = sqlite3_mprintf(SELECT_FACE_ID_USER_MARKED, _face->media_id, _face->face_rect_x, _face->face_rect_y, _face->face_rect_w, _face->face_rect_h, _face->orientation); + query_str = sqlite3_mprintf(SELECT_FACE_ID, _face->media_id, _face->face_rect_x, _face->face_rect_y, _face->face_rect_w, _face->face_rect_h, _face->orientation); ret = _content_query_prepare(&stmt, query_str, NULL, NULL); SQLITE3_SAFE_FREE(query_str); media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); @@ -323,9 +323,7 @@ int media_face_delete_from_db(const char *face_id) ret = __media_face_safe_atoi(face_id, &query_face_id); media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid face_id"); - /*To refresh face information(User try to start_face_detection again for the already scanned item), - mark media modified_time to '0' if user delete system extracted face info. */ - + /*Update modified_time to 0.. It will restore the deleted face when media_info_start_face_detection() is called */ query_str = sqlite3_mprintf(SELECT_MEDIA_FROM_FACE, query_face_id); ret = _content_query_prepare(&stmt, query_str, NULL, NULL); SQLITE3_SAFE_FREE(query_str); -- 2.7.4