Skip to content

Commit

Permalink
fix power calc. method
Browse files Browse the repository at this point in the history
  • Loading branch information
remov-b4-flight committed Jul 7, 2024
1 parent 46bbe0f commit 0d7cb9a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
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 = 8, revision = 0, build=0, },
VERSION = { major = 0, minor = 8, revision = 1, build=0, },

}
29 changes: 20 additions & 9 deletions evalfocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
SMALL_LS = 2400
BIG_LS = 4800
VISUAL_WAIT = 2000
HIST_DROP = 1.25
HIST_RISE = 2
POWER_RANGE = 6
MOUTH_DEDUCT = 0.75
EYE_DEDUCT = 0.85
FACE_DEDUCT = 0.9
Expand Down Expand Up @@ -171,19 +172,29 @@ def get_resize_factor(long_side) :
# Get result
hist, bins = np.histogram(laplacian, bins = 32, range = (0,255))
power_length = len(hist)
if (verbose >= 3) :
print("(orig)hist=", hist, end=", ")

#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
power_end = 0
max_hist = 0
for i in range((power_length - 1), 1, -1) :
if (power_end == 0 and hist[i] != 0) :
power_end = i
else :
if (power_end != 0 and hist[i] != 0 and (hist[i - 1] / hist[i]) > HIST_RISE) :
power_start = i
if (power_start == 0 or (power_end - power_start) > POWER_RANGE ) :
power_start = power_end - POWER_RANGE

if (verbose >= 3) :
print("power_start=", power_start)
print("hist=", hist[ -1 * (power_length - power_start) : ], end=", ")
print("power_start=", power_start, end=", ")
print("power_end=", power_end)
print("hist=", hist[ power_start : power_end], end=", ")
# Compute the power
power = 0
for i in range(power_start, power_length) :
for i in range(power_start, power_end) :
power += hist[i] * i

if (verbose >= 1) :
Expand Down Expand Up @@ -217,7 +228,7 @@ def get_resize_factor(long_side) :
if (verbose >= 2) :
print("10Kpixels=", pixel_count)
print("power/10Kpixels={0:.2f}".format(power_kpixel))
result = np.ceil(power_kpixel)
result = int(np.ceil(power_kpixel))

# Make image log
#if (args["vlog"]) :
Expand Down

0 comments on commit 0d7cb9a

Please sign in to comment.