diff --git a/EvalFocus.lua b/EvalFocus.lua index 2f6a6cb..c13b05f 100755 --- a/EvalFocus.lua +++ b/EvalFocus.lua @@ -16,7 +16,7 @@ local prefs = import 'LrPrefs'.prefsForPlugin() --Logger:enable('logfile') local MINRESULT = 5 -local LOW_BRISQUE = 4 +--local LOW_BRISQUE = 4 local CurrentCatalog = LrApplication.activeCatalog() local python = '/opt/homebrew/bin/python3 ' local script = '/evalfocus.py ' @@ -62,7 +62,7 @@ LrTasks.startAsyncTask( function () end else -- Logger:info('skip non JPEG file.') - end --isVidep + end --isVideo ProgressBar:setPortionComplete(i, countPhotos) end --end of for photos loop ProgressBar:done() diff --git a/Info.lua b/Info.lua index 9c94af1..59ec070 100755 --- a/Info.lua +++ b/Info.lua @@ -22,6 +22,6 @@ return { file = 'EvalClear.lua', enabledWhen = 'photosAvailable',}, }, - VERSION = { major = 0, minor = 7, revision = 3, build=0, }, + VERSION = { major = 0, minor = 8, revision = 0, build=0, }, } diff --git a/evalfocus.py b/evalfocus.py index 5a43864..659c950 100755 --- a/evalfocus.py +++ b/evalfocus.py @@ -16,7 +16,7 @@ SMALL_LS = 2400 BIG_LS = 4800 VISUAL_WAIT = 2000 -POWER_RANGE = 6 +HIST_DROP = 1.25 MOUTH_DEDUCT = 0.75 EYE_DEDUCT = 0.85 FACE_DEDUCT = 0.9 @@ -66,7 +66,7 @@ def get_resize_factor(long_side) : ap.add_argument("-v", help = "verbose outputs", action = 'count', default = 0) ap.add_argument("-k", help = "laplacian kernel", type = int, choices = [1,3,5,7,9], default = 5) ap.add_argument("-d", help = "laplacian depth", type = int, choices = [8,16,32], default = 8) -#ap.add_argument("-g", "--graph", help = "show histgram", action = 'store_true', default = False) +ap.add_argument("-g", "--graph", help = "show histgram", action = 'store_true', default = False) ap.add_argument("-m", "--model", help = "model", default = "yunet.onnx") ap.add_argument("-sr", "--skip_resize", help = "skip resize", action = 'store_true', default = False) ap.add_argument("-lap", "--laplacian", help = "show laplacian", action = 'store_true', default = False) @@ -170,12 +170,19 @@ def get_resize_factor(long_side) : cv.waitKey(VISUAL_WAIT) # Get result hist, bins = np.histogram(laplacian, bins = 32, range = (0,255)) - # Compute the power - power = 0 power_length = len(hist) - power_start = int(power_length - POWER_RANGE) + + #determine power start + power_start = 0 + for i in range(1, power_length - 1) : + if (hist[i] > 0 and (hist[i - 1] / hist[i]) < HIST_DROP) : + power_start = i + break if (verbose >= 3) : - print("hist=", hist[ -1 * POWER_RANGE : ], end=", ") + print("power_start=", power_start) + print("hist=", hist[ -1 * (power_length - power_start) : ], end=", ") + # Compute the power + power = 0 for i in range(power_start, power_length) : power += hist[i] * i