-
Notifications
You must be signed in to change notification settings - Fork 8
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
(DiamondLightSource/dodal#751) Draw crosshairs with better contrast #787
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0609e84
(DiamondLightSource/dodal#751) Draw crosshairs with better contrast
rtuck99 0e6fe7e
Fix Image type checking
rtuck99 3bafe15
Minor changes following PR comments
rtuck99 0f65e7c
Merge branch 'main' into dodal_751_draw_crosshairs_with_better_contrast
rtuck99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,8 @@ class SnapshotWithBeamCentre(MJPG): | |
image and saves the image to disk.""" | ||
|
||
CROSSHAIR_LENGTH_PX = 20 | ||
CROSSHAIR_COLOUR = "Blue" | ||
CROSSHAIR_OUTLINE_COLOUR = "Black" | ||
CROSSHAIR_FILL_COLOUR = "White" | ||
|
||
def post_processing(self, image: Image.Image): | ||
assert ( | ||
|
@@ -100,15 +101,27 @@ def post_processing(self, image: Image.Image): | |
beam_x = self.oav_params.beam_centre_i | ||
beam_y = self.oav_params.beam_centre_j | ||
|
||
SnapshotWithBeamCentre.draw_crosshair(image, beam_x, beam_y) | ||
|
||
self._save_image(image) | ||
|
||
@classmethod | ||
def draw_crosshair(cls, image: Image.Image, beam_x: int, beam_y: int): | ||
draw = ImageDraw.Draw(image) | ||
HALF_LEN = self.CROSSHAIR_LENGTH_PX / 2 | ||
HALF_LEN = cls.CROSSHAIR_LENGTH_PX / 2 | ||
draw.rectangle( | ||
[beam_x - 1, beam_y - HALF_LEN - 1, beam_x + 1, beam_y + HALF_LEN + 1], | ||
fill=cls.CROSSHAIR_OUTLINE_COLOUR, | ||
) | ||
draw.rectangle( | ||
[beam_x - HALF_LEN - 1, beam_y - 1, beam_x + HALF_LEN + 1, beam_y + 1], | ||
fill=cls.CROSSHAIR_OUTLINE_COLOUR, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should: The 1 in here is the width of the outline right? Might be worth pulling into a constant for readability? |
||
draw.line( | ||
((beam_x, beam_y - HALF_LEN), (beam_x, beam_y + HALF_LEN)), | ||
fill=self.CROSSHAIR_COLOUR, | ||
fill=cls.CROSSHAIR_FILL_COLOUR, | ||
) | ||
draw.line( | ||
((beam_x - HALF_LEN, beam_y), (beam_x + HALF_LEN, beam_y)), | ||
fill=self.CROSSHAIR_COLOUR, | ||
fill=cls.CROSSHAIR_FILL_COLOUR, | ||
) | ||
|
||
self._save_image(image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could: Would be good to mention the outline in the docstring