[shotwell/wip/always-enable-facedetect: 1/2] faces: Always enable face tagging
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/always-enable-facedetect: 1/2] faces: Always enable face tagging
- Date: Sat, 7 May 2022 07:08:14 +0000 (UTC)
commit d7f45e969eadf36d1312824d7e617fa5b432a99f
Author: Jens Georg <mail jensge org>
Date: Sat May 7 09:03:34 2022 +0200
faces: Always enable face tagging
There was absolutely no reason to not enable that always. Also fixes an
issue with shotwell aborting on unexpected OpenCV log output.
The face-detection build option will now just building the disable the
helper process so the OpenCV dependency is still opt-in.
meson.build | 2 +-
src/AppDirs.vala | 4 ----
src/Commands.vala | 3 ---
src/Dialogs.vala | 4 ----
src/Photo.vala | 2 --
src/PhotoPage.vala | 8 --------
src/Resources.vala | 2 --
src/SearchFilter.vala | 5 +----
src/db/FaceLocationTable.vala | 4 ----
src/db/FaceTable.vala | 2 --
src/faces/Face.vala | 3 ---
src/faces/FaceLocation.vala | 4 ----
src/faces/FacePage.vala | 4 ----
src/faces/FaceShape.vala | 4 ----
src/faces/Faces.vala | 20 --------------------
src/faces/FacesBranch.vala | 4 ----
src/faces/FacesTool.vala | 13 +++++++------
src/library/LibraryWindow.vala | 9 ---------
src/main.vala | 6 ------
src/meson.build | 5 +----
src/searches/SavedSearchDialog.vala | 2 --
src/searches/SearchBoolean.vala | 18 ++++++------------
src/util/ui.vala | 2 --
23 files changed, 16 insertions(+), 114 deletions(-)
---
diff --git a/meson.build b/meson.build
index f9c63dbb..d9896016 100644
--- a/meson.build
+++ b/meson.build
@@ -96,7 +96,7 @@ if get_option('udev') and gudev.found()
endif
if get_option('face-detection')
- add_global_arguments(['--define=ENABLE_FACES'], language : 'vala')
+ add_global_arguments(['--define=ENABLE_FACE_DETECTION'], language : 'vala')
subdir('facedetect')
endif
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 74b045f1..6c4541c1 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -258,14 +258,12 @@ class AppDirs {
return subdir;
}
-#if ENABLE_FACES
public static File get_resources_dir() {
File? install_dir = get_install_dir();
return (install_dir != null) ? install_dir.get_child("share").get_child("shotwell")
: get_exec_dir();
}
-#endif
public static File get_lib_dir() {
File? install_dir = get_install_dir();
@@ -329,7 +327,6 @@ class AppDirs {
return f;
}
-#if ENABLE_FACES
public static File get_facedetect_bin() {
const string filename = "shotwell-facedetect";
File f = AppDirs.get_libexec_dir().get_parent().get_child("facedetect").get_child (filename);
@@ -346,7 +343,6 @@ class AppDirs {
}
return get_resources_dir().get_child("facedetect-haarcascade.xml");
}
-#endif
}
diff --git a/src/Commands.vala b/src/Commands.vala
index 2b9eac1e..589ae383 100644
--- a/src/Commands.vala
+++ b/src/Commands.vala
@@ -2507,7 +2507,6 @@ public class FlagUnflagCommand : MultipleDataSourceAtOnceCommand {
}
}
-#if ENABLE_FACES
public class RemoveFacesFromPhotosCommand : SimpleProxyableCommand {
private Gee.Map<MediaSource, string> map_source_geometry = new Gee.HashMap<MediaSource, string>();
@@ -2721,5 +2720,3 @@ public class ModifyFacesCommand : SingleDataSourceCommand {
get_command_manager().reset();
}
}
-
-#endif
diff --git a/src/Dialogs.vala b/src/Dialogs.vala
index dc9f5a0d..c4e4f3dc 100644
--- a/src/Dialogs.vala
+++ b/src/Dialogs.vala
@@ -46,8 +46,6 @@ public bool confirm_warn_developer_changed(int number) {
return response == Gtk.ResponseType.YES;
}
-#if ENABLE_FACES
-
public bool confirm_delete_face(Face face) {
int count = face.get_sources_count();
string msg = ngettext(
@@ -59,8 +57,6 @@ public bool confirm_delete_face(Face face) {
Resources.DELETE_FACE_TITLE);
}
-#endif
-
}
namespace ExportUI {
diff --git a/src/Photo.vala b/src/Photo.vala
index 41b6f1df..b67457e4 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -5209,7 +5209,6 @@ public class LibraryPhoto : Photo, Flaggable, Monitorable {
}
}
-#if ENABLE_FACES
// Attach faces.
Gee.Collection<Face>? faces = Face.global.fetch_for_source(this);
if (faces != null) {
@@ -5223,7 +5222,6 @@ public class LibraryPhoto : Photo, Flaggable, Monitorable {
}
}
}
-#endif
return dupe;
}
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index bced0ead..fd513b2b 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -396,9 +396,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
private Gtk.ToggleToolButton redeye_button = null;
private Gtk.ToggleToolButton adjust_button = null;
private Gtk.ToggleToolButton straighten_button = null;
-#if ENABLE_FACES
private Gtk.ToggleToolButton faces_button = null;
-#endif
private Gtk.ToolButton enhance_button = null;
private Gtk.Scale zoom_slider = null;
private Gtk.ToolButton prev_button = new Gtk.ToolButton(null, Resources.PREVIOUS_LABEL);
@@ -491,12 +489,10 @@ public abstract class EditingHostPage : SinglePhotoPage {
enhance_button.is_important = true;
toolbar.insert(enhance_button, -1);
-#if ENABLE_FACES
// faces tool
insert_faces_button(toolbar);
faces_button = new Gtk.ToggleToolButton();
//face_button
-#endif
// separator to force next/prev buttons to right side of toolbar
Gtk.SeparatorToolItem separator = new Gtk.SeparatorToolItem();
@@ -2357,9 +2353,7 @@ public class LibraryPhotoPage : EditingHostPage {
}
}
-#if ENABLE_FACES
private Gtk.ToggleToolButton faces_button = null;
-#endif
private CollectionPage? return_page = null;
private bool return_to_collection_on_release = false;
private LibraryPhotoPageViewFilter filter = new LibraryPhotoPageViewFilter();
@@ -3168,7 +3162,6 @@ public class LibraryPhotoPage : EditingHostPage {
get_command_manager().execute(new ModifyTagsCommand(photo, new_tags));
}
-#if ENABLE_FACES
private void on_faces_toggled() {
on_tool_button_toggled(faces_button, FacesTool.factory);
}
@@ -3186,6 +3179,5 @@ public class LibraryPhotoPage : EditingHostPage {
faces_button.is_important = true;
toolbar.insert(faces_button, -1);
}
-#endif
}
diff --git a/src/Resources.vala b/src/Resources.vala
index f9fa8753..b65ec52b 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -390,7 +390,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
return _("Delete Search “%s”").printf(name);
}
-#if ENABLE_FACES
public static string rename_face_exists_message(string name) {
return _("Unable to rename face to “%s” because the face already exists.").printf(name);
}
@@ -420,7 +419,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public string delete_face_label(string name) {
return _("Delete Face “%s”").printf(name);
}
-#endif
private unowned string rating_label(Rating rating) {
switch (rating) {
diff --git a/src/SearchFilter.vala b/src/SearchFilter.vala
index bad6a738..ad8b7ec8 100644
--- a/src/SearchFilter.vala
+++ b/src/SearchFilter.vala
@@ -223,9 +223,7 @@ public abstract class DefaultSearchViewFilter : SearchViewFilter {
Gee.List<Tag>? tags = Tag.global.fetch_for_source(source);
int tags_size = (tags != null) ? tags.size : 0;
-#if ENABLE_FACES
Gee.List<Face>? faces = Face.global.fetch_for_source(source);
-#endif
foreach (unowned string word in get_search_filter_words()) {
if (media_keywords != null && media_keywords.contains(word))
@@ -249,7 +247,6 @@ public abstract class DefaultSearchViewFilter : SearchViewFilter {
continue;
}
-#if ENABLE_FACES
if (faces != null) {
bool found = false;
foreach (Face f in faces) {
@@ -264,7 +261,7 @@ public abstract class DefaultSearchViewFilter : SearchViewFilter {
if (found)
continue;
}
-#endif
+
// failed all tests (this even works if none of the Indexables have strings,
// as they fail the implicit AND test)
return false;
diff --git a/src/db/FaceLocationTable.vala b/src/db/FaceLocationTable.vala
index 14fef4c7..83986161 100644
--- a/src/db/FaceLocationTable.vala
+++ b/src/db/FaceLocationTable.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public struct FaceLocationID {
public const int64 INVALID = -1;
@@ -198,5 +196,3 @@ public class FaceLocationTable : DatabaseTable {
throw_error("FaceLocationTable.update_face_location_serialized_geometry", res);
}
}
-
-#endif
diff --git a/src/db/FaceTable.vala b/src/db/FaceTable.vala
index a6e0bad6..4836910d 100644
--- a/src/db/FaceTable.vala
+++ b/src/db/FaceTable.vala
@@ -4,7 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
public struct FaceID {
public const int64 INVALID = -1;
@@ -166,4 +165,3 @@ public class FaceTable : DatabaseTable {
update_text_by_id_2(face_id.id, "name", new_name);
}
}
-#endif
diff --git a/src/faces/Face.vala b/src/faces/Face.vala
index 9be33c9d..93040238 100644
--- a/src/faces/Face.vala
+++ b/src/faces/Face.vala
@@ -4,7 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
public class FaceSourceCollection : ContainerSourceCollection {
private Gee.HashMap<string, Face> name_map = new Gee.HashMap<string, Face>
((Gee.HashDataFunc)Face.hash_name_string, (Gee.EqualDataFunc)Face.equal_name_strings);
@@ -677,5 +676,3 @@ public class Face : DataSource, ContainerSource, Proxyable, Indexable {
base.destroy();
}
}
-
-#endif
diff --git a/src/faces/FaceLocation.vala b/src/faces/FaceLocation.vala
index cc5c4cf3..e143b2e0 100644
--- a/src/faces/FaceLocation.vala
+++ b/src/faces/FaceLocation.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public class FaceLocation : Object {
private static Gee.Map<FaceID?, Gee.Map<PhotoID?, FaceLocation>> face_photos_map;
@@ -205,5 +203,3 @@ public class FaceLocation : Object {
this.geometry = geometry;
}
}
-
-#endif
diff --git a/src/faces/FacePage.vala b/src/faces/FacePage.vala
index 41d1cef1..f2512d55 100644
--- a/src/faces/FacePage.vala
+++ b/src/faces/FacePage.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public class FacePage : CollectionPage {
private Face face;
@@ -123,5 +121,3 @@ public class FacePage : CollectionPage {
}
}
}
-
-#endif
diff --git a/src/faces/FaceShape.vala b/src/faces/FaceShape.vala
index 21e85a94..1ff01fd3 100644
--- a/src/faces/FaceShape.vala
+++ b/src/faces/FaceShape.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public abstract class FaceShape : Object {
public const string SHAPE_TYPE = null;
@@ -779,5 +777,3 @@ public class FaceRectangle : FaceShape {
return Math.sqrt((center_x - x) * (center_x - x) + (center_y - y) * (center_y - y));
}
}
-
-#endif
diff --git a/src/faces/Faces.vala b/src/faces/Faces.vala
index 3f0623a7..595c3b6c 100644
--- a/src/faces/Faces.vala
+++ b/src/faces/Faces.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
namespace Faces {
public void init() throws Error {
@@ -17,21 +15,3 @@ public void terminate() {
}
}
-
-#else
-
-namespace Faces {
-
-public void init() throws Error {
- // do nothing; this method is here only
- // to make the unitizing mechanism happy
-}
-
-public void terminate() {
- // do nothing; this method is here only
- // to make the unitizing mechanism happy
-}
-
-}
-
-#endif
diff --git a/src/faces/FacesBranch.vala b/src/faces/FacesBranch.vala
index 1eb25cf4..42fd9213 100644
--- a/src/faces/FacesBranch.vala
+++ b/src/faces/FacesBranch.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public class Faces.Branch : Sidebar.Branch {
private Gee.HashMap<Face, Faces.SidebarEntry> entry_map = new Gee.HashMap<Face, Faces.SidebarEntry>();
@@ -142,5 +140,3 @@ public class Faces.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.RenameableEnt
AppWindow.get_command_manager().execute(new DeleteFaceCommand(face));
}
}
-
-#endif
diff --git a/src/faces/FacesTool.vala b/src/faces/FacesTool.vala
index cf53736d..98037875 100644
--- a/src/faces/FacesTool.vala
+++ b/src/faces/FacesTool.vala
@@ -4,7 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
public errordomain FaceShapeError {
CANT_CREATE
}
@@ -155,7 +154,9 @@ public class FacesTool : EditingTools.EditingTool {
help_layout.pack_start(help_text, true);
response_layout = new Gtk.Box(Gtk.Orientation.HORIZONTAL, CONTROL_SPACING);
+ #if ENABLE_FACE_DETECTION
response_layout.add(detection_button);
+ #endif
response_layout.add(cancel_button);
response_layout.add(ok_button);
@@ -348,10 +349,12 @@ public class FacesTool : EditingTools.EditingTool {
if (line.length == 0)
continue;
+ debug("shotwell-facedetect: %s", line);
+
string[] type_and_serialized = line.split(";");
if (type_and_serialized.length != 2) {
- critical("Wrong serialized line in face detection program output.");
- assert_not_reached();
+ // Pass on external helper log output as our debug log
+ continue;
}
switch (type_and_serialized[0]) {
@@ -373,7 +376,7 @@ public class FacesTool : EditingTools.EditingTool {
assert_not_reached();
default:
- assert_not_reached();
+ break;
}
}
}
@@ -973,5 +976,3 @@ public class FacesTool : EditingTools.EditingTool {
face_detection.cancel();
}
}
-
-#endif
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 99a1c679..3aa397ec 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -48,9 +48,7 @@ public class LibraryWindow : AppWindow {
EVENTS,
IMPORT_ROLL,
FOLDERS,
-#if ENABLE_FACES
FACES,
-#endif
TAGS
}
@@ -115,9 +113,7 @@ public class LibraryWindow : AppWindow {
private Library.Branch library_branch = new Library.Branch();
private Tags.Branch tags_branch = new Tags.Branch();
private Folders.Branch folders_branch = new Folders.Branch();
-#if ENABLE_FACES
private Faces.Branch faces_branch = new Faces.Branch();
-#endif
private Events.Branch events_branch = new Events.Branch();
private Camera.Branch camera_branch = new Camera.Branch();
private Searches.Branch saved_search_branch = new Searches.Branch();
@@ -176,10 +172,7 @@ public class LibraryWindow : AppWindow {
sidebar_tree.graft(library_branch, SidebarRootPosition.LIBRARY);
sidebar_tree.graft(tags_branch, SidebarRootPosition.TAGS);
sidebar_tree.graft(folders_branch, SidebarRootPosition.FOLDERS);
-#if ENABLE_FACES
sidebar_tree.graft(faces_branch, SidebarRootPosition.FACES);
-#endif
-
sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS);
sidebar_tree.graft(camera_branch, SidebarRootPosition.CAMERAS);
sidebar_tree.graft(saved_search_branch, SidebarRootPosition.SAVED_SEARCH);
@@ -414,7 +407,6 @@ public class LibraryWindow : AppWindow {
debug("No search entry found for rename");
}
-#if ENABLE_FACES
public void rename_face_in_sidebar(Face face) {
Faces.SidebarEntry? entry = faces_branch.get_entry_for_face(face);
if (entry != null)
@@ -422,7 +414,6 @@ public class LibraryWindow : AppWindow {
else
assert_not_reached();
}
-#endif
protected override void on_quit() {
Config.Facade.get_instance().set_library_window_state(maximized, dimensions);
diff --git a/src/main.vala b/src/main.vala
index a971f157..d0cb2462 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -99,10 +99,8 @@ void library_exec(string[] mounts) {
+ EventTable.get_instance().get_row_count()
+ TagTable.get_instance().get_row_count()
+ VideoTable.get_instance().get_row_count()
-#if ENABLE_FACES
+ FaceTable.get_instance().get_row_count()
+ FaceLocationTable.get_instance().get_row_count()
-#endif
+ Upgrades.get_instance().get_step_count();
if (grand_total > 5000) {
progress_dialog = new ProgressDialog(null, _("Loading Shotwell"));
@@ -146,14 +144,12 @@ void library_exec(string[] mounts) {
if (aggregate_monitor != null)
aggregate_monitor.next_step("Tag.init");
Tag.init(monitor);
-#if ENABLE_FACES
if (aggregate_monitor != null)
aggregate_monitor.next_step("FaceLocation.init");
FaceLocation.init(monitor);
if (aggregate_monitor != null)
aggregate_monitor.next_step("Face.init");
Face.init(monitor);
-#endif
MetadataWriter.init();
DesktopIntegration.init();
@@ -219,10 +215,8 @@ void library_exec(string[] mounts) {
Tombstone.terminate();
ThumbnailCache.terminate();
Video.terminate();
-#if ENABLE_FACES
Face.terminate();
FaceLocation.terminate();
-#endif
Library.app_terminate();
}
diff --git a/src/meson.build b/src/meson.build
index 530d6aff..cc99f560 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -17,9 +17,7 @@ processor = executable('shotwell-graphics-processor',
dependencies: [gio, gdk, gee],
link_with: sw_graphics_processor)
-face_sources = []
-if get_option('face-detection')
- face_sources = (['faces/FacesBranch.vala',
+face_sources = (['faces/FacesBranch.vala',
'faces/FaceLocation.vala',
'faces/FacePage.vala',
'faces/FaceShape.vala',
@@ -28,7 +26,6 @@ if get_option('face-detection')
'db/FaceLocationTable.vala',
'db/FaceTable.vala',
'faces/FacesTool.vala'])
-endif
shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
gstreamer_pbu, gio_unix, gudev, gexiv2, gmodule,
diff --git a/src/searches/SavedSearchDialog.vala b/src/searches/SavedSearchDialog.vala
index f5558bff..526da35b 100644
--- a/src/searches/SavedSearchDialog.vala
+++ b/src/searches/SavedSearchDialog.vala
@@ -79,9 +79,7 @@ public class SavedSearchDialog : Gtk.Dialog {
case SearchCondition.SearchType.ANY_TEXT:
case SearchCondition.SearchType.EVENT_NAME:
case SearchCondition.SearchType.FILE_NAME:
-#if ENABLE_FACES
case SearchCondition.SearchType.FACE:
-#endif
case SearchCondition.SearchType.TAG:
case SearchCondition.SearchType.COMMENT:
case SearchCondition.SearchType.TITLE:
diff --git a/src/searches/SearchBoolean.vala b/src/searches/SearchBoolean.vala
index 2be83020..5e69e57b 100644
--- a/src/searches/SearchBoolean.vala
+++ b/src/searches/SearchBoolean.vala
@@ -52,9 +52,7 @@ public abstract class SearchCondition {
TAG,
EVENT_NAME,
FILE_NAME,
-#if ENABLE_FACES
FACE,
-#endif
MEDIA_TYPE,
FLAG_STATE,
MODIFIED_STATE,
@@ -65,9 +63,7 @@ public abstract class SearchCondition {
public static SearchType[] as_array() {
return { ANY_TEXT, TITLE, TAG, COMMENT, EVENT_NAME, FILE_NAME,
-#if ENABLE_FACES
FACE,
-#endif
MEDIA_TYPE, FLAG_STATE, MODIFIED_STATE, RATING, DATE };
}
@@ -98,10 +94,10 @@ public abstract class SearchCondition {
case SearchType.FILE_NAME:
return "FILE_NAME";
-#if ENABLE_FACES
+
case SearchType.FACE:
return "FACE";
-#endif
+
case SearchType.MEDIA_TYPE:
return "MEDIA_TYPE";
@@ -140,10 +136,10 @@ public abstract class SearchCondition {
else if (str == "FILE_NAME")
return SearchType.FILE_NAME;
-#if ENABLE_FACES
+
else if (str == "FACE")
return SearchType.FACE;
-#endif
+
else if (str == "MEDIA_TYPE")
return SearchType.MEDIA_TYPE;
@@ -182,10 +178,10 @@ public abstract class SearchCondition {
case SearchType.FILE_NAME:
return _("File name");
-#if ENABLE_FACES
+
case SearchType.FACE:
return _("Face");
-#endif
+
case SearchType.MEDIA_TYPE:
return _("Media type");
@@ -361,7 +357,6 @@ public class SearchConditionText : SearchCondition {
ret |= string_match(text, String.remove_diacritics(source.get_basename().down()));
}
-#if ENABLE_FACES
if (SearchType.ANY_TEXT == search_type || SearchType.FACE == search_type) {
Gee.List<Face>? face_list = Face.global.fetch_for_source(source);
if (null != face_list) {
@@ -372,7 +367,6 @@ public class SearchConditionText : SearchCondition {
ret |= string_match(text, null); // for IS_NOT_SET
}
}
-#endif
return (context == Context.DOES_NOT_CONTAIN) ? !ret : ret;
}
diff --git a/src/util/ui.vala b/src/util/ui.vala
index 7e7348fd..6d32738e 100644
--- a/src/util/ui.vala
+++ b/src/util/ui.vala
@@ -86,7 +86,6 @@ public bool has_only_key_modifier(Gdk.ModifierType field, Gdk.ModifierType mask)
| Gdk.ModifierType.META_MASK)) == mask;
}
-#if ENABLE_FACES
bool is_pointer_over(Gdk.Window window) {
Gdk.DeviceManager? devmgr = window.get_display().get_device_manager();
if (devmgr == null) {
@@ -101,5 +100,4 @@ bool is_pointer_over(Gdk.Window window) {
return x >= 0 && y >= 0 && x < window.get_width() && y < window.get_height();
}
-#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]