Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable green and blue lasers #108

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions res/locale/en/LC_MESSAGES/horus.po
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ msgstr "Remove background"
msgid "Red channel"
msgstr "Red channel"

#: ../../src/horus/util/profile.py:250 ../../src/horus/util/profile.py:315
msgid "Laser color"
msgstr "Laser color"

#: ../../src/horus/util/profile.py:250 ../../src/horus/util/profile.py:315
msgid "Red"
msgstr "Red"

#: ../../src/horus/util/profile.py:250 ../../src/horus/util/profile.py:315
msgid "Green"
msgstr "Green"

#: ../../src/horus/util/profile.py:250 ../../src/horus/util/profile.py:315
msgid "Blue"
msgstr "Blue"

#: ../../src/horus/util/profile.py:254 ../../src/horus/util/profile.py:319
msgid "Enable threshold"
msgstr "Enable threshold"
Expand Down
21 changes: 15 additions & 6 deletions src/horus/engine/algorithms/laser_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self):
self.point_cloud_roi = PointCloudROI()

self.red_channel = 'R (RGB)'
self.color_channel = 'Red'
self.threshold_enable = False
self.threshold_value = 0
self.blur_enable = False
Expand All @@ -34,6 +35,9 @@ def __init__(self):
def set_red_channel(self, value):
self.red_channel = value

def set_color_channel(self, value):
self.color_channel = value

def set_threshold_enable(self, value):
self.threshold_enable = value

Expand Down Expand Up @@ -86,22 +90,27 @@ def compute_line_segmentation(self, image, roi_mask=False):
# Apply ROI mask
if roi_mask:
image = self.point_cloud_roi.mask_image(image)
# Obtain red channel
image = self._obtain_red_channel(image)
# Obtain laser channel (usually red)
image = self._obtain_laser_channel(image)
if image is not None:
# Threshold image
image = self._threshold_image(image)
# Window mask
image = self._window_mask(image)
return image

def _obtain_red_channel(self, image):
def _obtain_laser_channel(self, image):
ret = None
if self.red_channel == 'R (RGB)':
# color channel takes priority over unused YCrCb and YUV tests
if self.color_channel == 'Green':
ret = cv2.split(image)[1]
elif self.color_channel == 'Blue':
ret = cv2.split(image)[2]
elif self.red_channel == 'R (RGB)':
ret = cv2.split(image)[0]
elif self.red_channel == 'Cr (YCrCb)':
elif self.red_channel == 'Cr (YCrCb)': # unused, UI code commented out
ret = cv2.split(cv2.cvtColor(image, cv2.COLOR_RGB2YCR_CB))[1]
elif self.red_channel == 'U (YUV)':
elif self.red_channel == 'U (YUV)': # unused, UI code commented out
ret = cv2.split(cv2.cvtColor(image, cv2.COLOR_RGB2YUV))[1]
return ret

Expand Down
3 changes: 3 additions & 0 deletions src/horus/gui/workbench/adjustment/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def __init__(self, parent, on_selected_callback):

def add_controls(self):
# self.add_control('red_channel_scanning', ComboBox)
self.add_control('color_channel_scanning', ComboBox)
self.add_control(
'threshold_value_scanning', Slider,
_("Remove all pixels which intensity is less that the threshold value"))
Expand All @@ -172,6 +173,7 @@ def add_controls(self):

def update_callbacks(self):
# self.update_callback('red_channel_scanning', laser_segmentation.set_red_channel)
self.update_callback('color_channel_scanning', laser_segmentation.set_color_channel)
self.update_callback('threshold_value_scanning', laser_segmentation.set_threshold_value)
self.update_callback('threshold_enable_scanning', laser_segmentation.set_threshold_enable)
self.update_callback('blur_value_scanning', laser_segmentation.set_blur_value)
Expand All @@ -192,6 +194,7 @@ def on_selected(self):
laser_mode.set_exposure(profile.settings['exposure_laser_scanning'])
image_capture.set_remove_background(profile.settings['remove_background_scanning'])
laser_segmentation.set_red_channel(profile.settings['red_channel_scanning'])
laser_segmentation.set_color_channel(profile.settings['color_channel_scanning'])
laser_segmentation.set_threshold_value(profile.settings['threshold_value_scanning'])
laser_segmentation.set_threshold_enable(profile.settings['threshold_enable_scanning'])
laser_segmentation.set_blur_value(profile.settings['blur_value_scanning'])
Expand Down
7 changes: 7 additions & 0 deletions src/horus/util/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def _initialize_settings(self):
# Hack to translate combo boxes:
_('Texture')
_('Laser')
_('Red')
_('Green')
_('Blue')
self._add_setting(
Setting('capture_mode_scanning', _('Capture mode'), 'profile_settings',
unicode, u'Texture', possible_values=(u'Texture', u'Laser')))
Expand Down Expand Up @@ -250,6 +253,10 @@ def _initialize_settings(self):
Setting('red_channel_scanning', _('Red channel'), 'profile_settings',
unicode, u'R (RGB)',
possible_values=(u'R (RGB)', u'Cr (YCrCb)', u'U (YUV)')))
self._add_setting(
Setting('color_channel_scanning', _('Laser color'), 'profile_settings',
unicode, u'Red',
possible_values=(u'Red', u'Green', u'Blue')))
self._add_setting(
Setting('threshold_enable_scanning', _('Enable threshold'),
'profile_settings', bool, True))
Expand Down