Skip to content

Commit

Permalink
Fix for low power lap. result images
Browse files Browse the repository at this point in the history
  • Loading branch information
remov-b4-flight committed Jul 7, 2024
1 parent f4af1d9 commit 46bbe0f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions EvalFocus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, },

}
19 changes: 13 additions & 6 deletions evalfocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 46bbe0f

Please sign in to comment.