Skip to content

Commit 2515db3

Browse files
authored
Merge pull request darktable-org#250 from sbolten/enhance_face_recognition
face_recognition.lua: Added "People" category to tag routine
2 parents 8a8f633 + 54a66f9 commit 2515db3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

contrib/face_recognition.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ local function save_preferences()
139139
dt.preferences.write(MODULE, "unknown_tag", "string", fc.unknown_tag.text)
140140
dt.preferences.write(MODULE, "no_persons_found_tag", "string", fc.no_persons_found_tag.text)
141141
dt.preferences.write(MODULE, "ignore_tags", "string", fc.ignore_tags.text)
142+
dt.preferences.write(MODULE, "category_tags", "string", fc.category_tags.text)
142143
dt.preferences.write(MODULE, "known_image_path", "directory", fc.known_image_path.value)
143144
local val = fc.tolerance.value
144145
val = string.gsub(tostring(val), ",", ".")
@@ -153,6 +154,7 @@ local function reset_preferences()
153154
fc.unknown_tag.text = "unknown_person"
154155
fc.no_persons_found_tag.text = "no_persons_found"
155156
fc.ignore_tags.text = ""
157+
fc.category_tags.text = ""
156158
fc.known_image_path.value = dt.configuration.config_dir .. "/face_recognition"
157159
fc.tolerance.value = 0.6
158160
fc.num_cores.value = -1
@@ -203,6 +205,7 @@ local function face_recognition ()
203205
local knownPath = dt.preferences.read(MODULE, "known_image_path", "directory")
204206
local nrCores = dt.preferences.read(MODULE, "num_cores", "integer")
205207
local ignoreTagString = dt.preferences.read(MODULE, "ignore_tags", "string")
208+
local categoryTagString = dt.preferences.read(MODULE, "category_tags", "string")
206209
local unknownTag = dt.preferences.read(MODULE, "unknown_tag", "string")
207210
local nonpersonsfoundTag = dt.preferences.read(MODULE, "no_persons_found_tag", "string")
208211

@@ -303,6 +306,9 @@ local function face_recognition ()
303306
t = nonpersonsfoundTag
304307
end
305308
if t ~= "" and t ~= nil then
309+
if categoryTagString ~= "" and t ~= nonpersonsfoundTag then
310+
t = categoryTagString .. "|" .. t
311+
end
306312
dt.print_log ("ImgId:" .. img.id .. " Tag:".. t)
307313
-- Create tag if it does not exist
308314
if tags_list[t] == nil then
@@ -351,6 +357,12 @@ fc.ignore_tags = dt.new_widget("entry"){
351357
editable = true,
352358
}
353359

360+
fc.category_tags = dt.new_widget("entry"){
361+
text = dt.preferences.read(MODULE, "category_tags", "string"),
362+
tooltip = _("tag category"),
363+
editable = true,
364+
}
365+
354366
fc.tolerance = dt.new_widget("slider"){
355367
label = _("tolerance"),
356368
tooltip = ("detection tolerance - 0.6 default - lower if too many faces detected"),
@@ -421,6 +433,8 @@ local widgets = {
421433
fc.no_persons_found_tag,
422434
dt.new_widget("label"){ label = _("tags of images to ignore")},
423435
fc.ignore_tags,
436+
dt.new_widget("label"){ label = _("tag category")},
437+
fc.category_tags,
424438
dt.new_widget("label"){ label = _("face data directory")},
425439
fc.known_image_path,
426440
}

0 commit comments

Comments
 (0)