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 <minje.ahn@samsung.com>
/* 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
#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"
/* 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
#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"
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);
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);