-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1001 from aaronwmorris/dev
BREAKING CHANGE: Detection masks utilized prior to geometry changes
- Loading branch information
Showing
9 changed files
with
303 additions
and
18 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block title %}indi-allsky: Mask Base{% endblock %} | ||
|
||
{% block head %} | ||
<meta charset="UTF-8"> | ||
<style> | ||
#mask_img { | ||
width: 100%; | ||
height: auto; | ||
} | ||
</style> | ||
<script> | ||
var url = '{{ mask_image_uri }}'; | ||
</script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-12 text-center" style="font-size:10px"> | ||
This image is the original camera output. It is not rotated, flipped, or cropped. | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-1"></div> | ||
<div class="col-10"> | ||
<img id="mask_img"> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12 text-center" style="font-size:10px"> | ||
<span>Generated: {{ mask_date }}</span> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12 text-center"> | ||
<span id="mask_download"></span> | ||
</div> | ||
</div> | ||
<script> | ||
function init() { | ||
$('#mask_img').attr('src', url + '?' + new Date().getTime()); | ||
|
||
$('#mask_download').html( | ||
$('<a />', { | ||
'href' : $('#mask_img').attr('src'), | ||
'rel' : 'noopener noreferrer', | ||
'download' : 'mask_base.png', | ||
}).html( | ||
$('<span />', { | ||
'text' : 'Download Mask Base', | ||
'class' : "badge pill bg-info text-dark", | ||
}) | ||
) | ||
); | ||
} | ||
|
||
$( document ).ready(function() { | ||
init(); | ||
}); | ||
|
||
</script> | ||
|
||
{% endblock %} |
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
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
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
### This is a mini image processor for masks | ||
### Masks are pre-rotation/flip/cropping and need these operations to be applied to processed images | ||
|
||
#import time | ||
import cv2 | ||
import logging | ||
|
||
|
||
logger = logging.getLogger('indi_allsky') | ||
|
||
|
||
class MaskProcessor(object): | ||
def __init__( | ||
self, | ||
config, | ||
bin_v, | ||
): | ||
|
||
self.config = config | ||
self.bin_v = bin_v | ||
|
||
self._image = None | ||
|
||
|
||
@property | ||
def image(self): | ||
return self._image | ||
|
||
@image.setter | ||
def image(self, new_image): | ||
self._image = new_image | ||
|
||
|
||
def rotate_90(self): | ||
try: | ||
rotate_enum = getattr(cv2, self.config['IMAGE_ROTATE']) | ||
except AttributeError: | ||
logger.error('Unknown rotation option: %s', self.config['IMAGE_ROTATE']) | ||
return | ||
|
||
self.image = cv2.rotate(self.image, rotate_enum) | ||
|
||
|
||
def rotate_angle(self): | ||
angle = self.config.get('IMAGE_ROTATE_ANGLE') | ||
|
||
#rotate_start = time.time() | ||
|
||
height, width = self.image.shape[:2] | ||
center_x = int(width / 2) | ||
center_y = int(height / 2) | ||
|
||
rot = cv2.getRotationMatrix2D((center_x, center_y), int(angle), 1.0) | ||
|
||
abs_cos = abs(rot[0, 0]) | ||
abs_sin = abs(rot[0, 1]) | ||
|
||
bound_w = int(height * abs_sin + width * abs_cos) | ||
bound_h = int(height * abs_cos + width * abs_sin) | ||
|
||
rot[0, 2] += bound_w / 2 - center_x | ||
rot[1, 2] += bound_h / 2 - center_y | ||
|
||
self.image = cv2.warpAffine(self.image, rot, (bound_w, bound_h)) | ||
|
||
rot_height, rot_width = self.image.shape[:2] | ||
mod_height = rot_height % 2 | ||
mod_width = rot_width % 2 | ||
|
||
if mod_height or mod_width: | ||
# width and height needs to be divisible by 2 for timelapse | ||
crop_height = rot_height - mod_height | ||
crop_width = rot_width - mod_width | ||
|
||
self.image = self.image[ | ||
0:crop_height, | ||
0:crop_width, | ||
] | ||
|
||
|
||
#processing_elapsed_s = time.time() - rotate_start | ||
#logger.warning('Rotation in %0.4f s', processing_elapsed_s) | ||
|
||
|
||
def flip(self, cv2_axis): | ||
self.image = cv2.flip(self.image, cv2_axis) | ||
|
||
|
||
def flip_v(self): | ||
self.flip(0) | ||
|
||
|
||
def flip_h(self): | ||
self.flip(1) | ||
|
||
|
||
def crop_image(self): | ||
# divide the coordinates by binning value | ||
x1 = int(self.config['IMAGE_CROP_ROI'][0] / self.bin_v.value) | ||
y1 = int(self.config['IMAGE_CROP_ROI'][1] / self.bin_v.value) | ||
x2 = int(self.config['IMAGE_CROP_ROI'][2] / self.bin_v.value) | ||
y2 = int(self.config['IMAGE_CROP_ROI'][3] / self.bin_v.value) | ||
|
||
|
||
self.image = self.image[ | ||
y1:y2, | ||
x1:x2, | ||
] | ||
|
||
#new_height, new_width = self.image.shape[:2] | ||
#logger.info('New cropped size: %d x %d', new_width, new_height) | ||
|
||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
__version__ = "7.5" | ||
__version__ = "7.6" | ||
__config_level__ = "20231018.0" | ||
|
Oops, something went wrong.