Skip to content

Commit

Permalink
enhancements for sony cam
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McFadden committed Apr 9, 2024
1 parent 0f9b0a2 commit c6f65a1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
22 changes: 20 additions & 2 deletions LS_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,28 @@ def stackFocusStack(self, folder):
for stackFolder in onlyFolders:

focusStackInstall = self.config.configValues["FocusStackInstall"]

inputPath = ""
if(self.config.configValues["PruneBeforeStacking"]):
files = [f for f in os.listdir(folder + "/" + stackFolder) if isfile(join(folder + "/" + stackFolder, f))]
files.sort()
onlyJpegs = [jpg for jpg in files if jpg.lower().endswith(".jpg")]
if(len(onlyJpegs) < 1):
continue
# sort the files by filesize and remove the smallest 50% of them files
fileSizes = []
for file in onlyJpegs:
fileSizes.append(os.path.getsize(folder + "/" + stackFolder + "/" + file))
median = statistics.median(fileSizes)
for file in onlyJpegs:
if(os.path.getsize(folder + "/" + stackFolder + "/" + file) >= median):
inputPath = inputPath + ' "' + folder + "/" + stackFolder + "/" + file + '"'
else:
inputPath = '"' + folder + "/" + stackFolder + "/*jpg" + '"'


commandLine = self.config.configValues["FocusStackLaunchPath"] \
.replace('{{Install}}', focusStackInstall) \
.replace('{{folderPath}}', folder + "/" + stackFolder) \
.replace('{{folderPath}}', inputPath) \
.replace('{{outputPath}}', folder + "/" + stackFolder + ".jpg")
print(commandLine);
subprocess.call(commandLine, stdout=DEVNULL,
Expand Down
11 changes: 10 additions & 1 deletion Preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def CreateWindow(self, parent):
fgSizer1.Add( self.focuslabel, 0, wx.ALL, 5 )

self.focusLaunch = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
fgSizer1.Add( self.focusLaunch, 0, wx.ALL, 5 )
fgSizer1.Add( self.focusLaunch, 0, wx.ALL|wx.EXPAND, 5 )


fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )
Expand Down Expand Up @@ -181,6 +181,13 @@ def CreateWindow(self, parent):

fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )

fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )

self.m_pruneBefore = wx.CheckBox( panel, wx.ID_ANY, u"Prune Before Stacking", wx.DefaultPosition, wx.DefaultSize, 0 )
fgSizer1.Add( self.m_pruneBefore, 0, wx.ALL, 5 )


fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )

fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )

Expand Down Expand Up @@ -225,6 +232,7 @@ def save(self, event=None):
self.config.configValues['FocusStackLaunchPath'] = self.focusLaunch.GetValue()
self.config.configValues['RightToLeft'] = self.rightToLeft.IsChecked()
self.config.configValues['StackerSelection'] = self.m_stackerSelection.GetString(self.m_stackerSelection.GetSelection())
self.config.configValues['PruneBeforeStacking'] = self.m_pruneBefore.IsChecked()
self.config.save_config()

def reload(self, event=None):
Expand All @@ -243,6 +251,7 @@ def reload(self, event=None):
self.focusStack.SetValue(self.config.configValues["FocusStackInstall"])
self.focusLaunch.SetValue(self.config.configValues["FocusStackLaunchPath"])
self.rightToLeft.SetValue(self.config.configValues['RightToLeft'])
self.m_pruneBefore.SetValue(self.config.configValues['PruneBeforeStacking'])
self.m_stackerSelection.SetSelection(self.m_stackerSelection.FindString(self.config.configValues['StackerSelection']))


Expand Down
4 changes: 3 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def _load_from_file(self):
self.configValues["Overlap"] = self.Config.get("Processing", "Overlap", fallback="0.35")
self.configValues["FocusThreshold"] = self.Config.get("Processing", "FocusThreshold", fallback="13.0")
self.configValues["RightToLeft"] = True if self.Config.get("Processing", "RightToLeft", fallback="0") == "1" else False
self.configValues["PruneBeforeStacking"] = True if self.Config.get("Processing", "PruneBeforeStacking", fallback="0") == "1" else False
self.configValues["StackerSelection"] = self.Config.get("Processing", "StackerSelection", fallback="FocusStack")
self.configValues["FocusStackInstall"] = self.Config.get("FocusStack", "Install", fallback=str(homedir.absolute()))
self.configValues["FocusStackLaunchPath"] = self.Config.get("FocusStack", "LaunchPath", fallback='"{{Install}}" --consistency=0 --align-keep-size --no-whitebalance --no-contrast --jpgquality=100 --output="{{outputPath}}" "{{folderPath}}/"*jpg')
self.configValues["FocusStackLaunchPath"] = self.Config.get("FocusStack", "LaunchPath", fallback='"{{Install}}" --consistency=0 --align-keep-size --no-whitebalance --no-contrast --jpgquality=100 --output="{{outputPath}}" {{folderPath}}')

def save_config(self):

Expand All @@ -84,6 +85,7 @@ def save_config(self):
self.Config.set("Processing", "VignetteMagic",self.configValues["VignetteMagic"])
self.Config.set("Processing", "Overlap",self.configValues["Overlap"])
self.Config.set("Processing", "RightToLeft","1" if self.configValues["RightToLeft"] else "0")
self.Config.set("Processing", "PruneBeforeStacking","1" if self.configValues["PruneBeforeStacking"] else "0")
self.Config.set("Processing", "StackerSelection",self.configValues["StackerSelection"])
self.Config.set("FocusStack", "Install",self.configValues["FocusStackInstall"])
self.Config.set("FocusStack", "LaunchPath",self.configValues["FocusStackLaunchPath"])
Expand Down
4 changes: 2 additions & 2 deletions stitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

CONFIG={}
CONFIG['max_features'] = 500
CONFIG['scale_factor'] = 0.5
CONFIG['scale_factor'] = 0.25
CONFIG['flann_checks'] = 12

class Stitcher:
Expand Down Expand Up @@ -146,7 +146,7 @@ def removeVignette(self, img, vignetteMagicNumber):
return np.rint(corrected).astype(np.uint8)

def rotateAndCrop(self, image):
scale_percent = 5 # percent of original size
scale_percent = 2.5 # percent of original size
width = int(image.shape[1] * scale_percent / 100)
height = int(image.shape[0] * scale_percent / 100)
dim = (width, height)
Expand Down

0 comments on commit c6f65a1

Please sign in to comment.