Skip to content

Commit

Permalink
WIP: display session accumulated exposure time
Browse files Browse the repository at this point in the history
  • Loading branch information
deufrai committed Mar 16, 2023
1 parent 85a564e commit d8204e6
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 144 deletions.
39 changes: 26 additions & 13 deletions src/als/io/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

_IGNORED_FILENAME_START_PATTERNS = ['.', '~', 'tmp']
_DEFAULT_SCAN_FILE_SIZE_RETRY_PERIOD_IN_SEC = 0.5

EXPOSURE_TIME_EXIF_TAG = 'EXIF ExposureTime'
SCANNER_TYPE_FILESYSTEM = "FS"


Expand Down Expand Up @@ -250,9 +250,6 @@ def _read_standard_image(path: Path):

@log
def _read_raw_image(path: Path):

EXPOSURE_TIME_EXIF_TAG = 'EXIF ExposureTime'

"""
Reads a RAW DLSR image from file
Expand Down Expand Up @@ -325,15 +322,7 @@ def _read_raw_image(path: Path):
new_image = Image(raw_image.raw_image_visible.copy())
new_image.bayer_pattern = bayer_pattern

# try and get exposure time
# exit tag desc. :
# 0x829a 33434 Photo Exif.Photo.ExposureTime Rational Exposure time, given in seconds (sec).
with open(path, 'rb') as raw:
tags = exifread.process_file(raw)
if tags and EXPOSURE_TIME_EXIF_TAG in tags.keys():
exposure_time = float(tags[EXPOSURE_TIME_EXIF_TAG].values[0])
_LOGGER.debug(f"*SD-EXP_T* extracted exposure time: {exposure_time}")
new_image.exposure_time = exposure_time
extract_exifs(new_image, path)

return new_image

Expand All @@ -345,6 +334,30 @@ def _read_raw_image(path: Path):
return None


@log
def extract_exifs(image, image_path):
"""
Try and get some exifs from the image file
For now, we only look for exposure time, but who knows...
The image in modified in place
:param image: the image to feed
:type image: Image
:param image_path: path to original file
:type image_path: Path
:return: None
"""
with open(image_path, 'rb') as raw:
tags = exifread.process_file(raw)
if tags and EXPOSURE_TIME_EXIF_TAG in tags.keys():
exposure_time = float(tags[EXPOSURE_TIME_EXIF_TAG].values[0])
_LOGGER.debug(f"*SD-EXP_T* extracted exposure time: {exposure_time}")
image.exposure_time = exposure_time


@log
def _report_fs_error(path: Path, error: Exception):
MESSAGE_HUB.dispatch_error(
Expand Down
4 changes: 4 additions & 0 deletions src/als/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ def on_new_stack_result(self, image: Image):
image.origin = "Stacking result"
self._last_stacking_result = image

if image.exposure_time != Image.UNDEF_EXP_TIME:
DYNAMIC_DATA.total_exposure_time += image.exposure_time

self.purge_queue(self._post_process_queue)
self._post_process_queue.put(image)

Expand Down Expand Up @@ -485,6 +488,7 @@ def start_session(self):
self._stacker.reset()
self._image_timings.clear()
DYNAMIC_DATA.last_timing = 0
DYNAMIC_DATA.total_exposure_time = 0

# checking presence of critical folders
critical_folders_dict = {
Expand Down
4 changes: 3 additions & 1 deletion src/als/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def set_status(self, status: int):

# pylint: disable=too-many-instance-attributes
class Image:

UNDEF_EXP_TIME = -1
"""
Represents an image, our basic processing object.
Expand All @@ -100,7 +102,7 @@ def __init__(self, data):
self._origin: str = "UNDEFINED"
self._destination: str = "UNDEFINED"
self._ticket = ""
self._exposure_time: float = -1.
self._exposure_time: float = Image.UNDEF_EXP_TIME

@log
def clone(self, keep_ref_to_data=False):
Expand Down
1 change: 1 addition & 0 deletions src/als/model/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def __init__(self):
self.is_first_run = True
self.post_processor_result_qimage = None
self.last_timing = 0
self.total_exposure_time: int = 0


class HistogramContainer:
Expand Down
247 changes: 119 additions & 128 deletions src/als/ui/als_ui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -304,155 +304,146 @@
<property name="title">
<string>Stack</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QCheckBox" name="chk_align">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Align frames before stacking</string>
</property>
<property name="statusTip">
<string>Align frames before stacking</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Align</string>
</property>
<property name="shortcut">
<string>A</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Mode:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cb_stacking_mode">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="chk_align">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Align frames before stacking</string>
</property>
<property name="statusTip">
<string>Align frames before stacking</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Align</string>
</property>
<property name="shortcut">
<string>A</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Mode:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cb_stacking_mode">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_align_threshold">
<property name="minimumSize">
<size>
<width>25</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="sld_align_threshold">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string/>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="value">
<number>25</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="lbl_stack_size">
<property name="font">
<font>
<pointsize>24</pointsize>
<pointsize>18</pointsize>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string notr="true">0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Threshold:</string>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_align_threshold">
<property name="minimumSize">
<size>
<width>25</width>
<height>0</height>
</size>
<item row="1" column="0">
<widget class="QLabel" name="lbl_stack_exposure">
<property name="font">
<font>
<pointsize>10</pointsize>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="sld_align_threshold">
<property name="minimumSize">
<size>
<width>170</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string/>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="value">
<number>25</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
<string notr="true">0</string>
</property>
<property name="tickInterval">
<number>10</number>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
Expand Down
Loading

0 comments on commit d8204e6

Please sign in to comment.