added copy constructor to ROI
This commit is contained in:
@@ -363,6 +363,7 @@ class ROI:
|
||||
width: int = None,
|
||||
height: int = None,
|
||||
name: str = None,
|
||||
from_ROI: "ROI" = None,
|
||||
):
|
||||
if None not in (left, right, bottom, top):
|
||||
(
|
||||
@@ -378,6 +379,12 @@ class ROI:
|
||||
)
|
||||
elif None not in (center_x, center_y, width, height):
|
||||
self.from_centers_widths(center_x, center_y, width, height)
|
||||
elif isinstance(from_ROI, ROI):
|
||||
self.left = from_ROI.left
|
||||
self.right = from_ROI.right
|
||||
self.top = from_ROI.top
|
||||
self.bottom = from_ROI.bottom
|
||||
name = from_ROI.name
|
||||
else:
|
||||
raise ValueError("No valid ROI definition.")
|
||||
|
||||
@@ -416,7 +423,10 @@ class ROI:
|
||||
return self.top - self.bottom
|
||||
|
||||
def __repr__(self):
|
||||
return f"ROI(bottom={self.bottom},top={self.top},left={self.left},right={self.right})"
|
||||
if hasattr(self, "name"):
|
||||
return f"ROI(bottom={self.bottom},top={self.top},left={self.left},right={self.right},name='{self.name}')"
|
||||
else:
|
||||
return f"ROI(bottom={self.bottom},top={self.top},left={self.left},right={self.right})"
|
||||
|
||||
def __eq__(self, other):
|
||||
# we disregard the name for comparisons
|
||||
@@ -428,7 +438,7 @@ class ROI:
|
||||
)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self == other
|
||||
return not self == other
|
||||
|
||||
|
||||
def check_pid_offset(step, ch1, ch2, offsets_to_try=[-2, -1, 0, 1, 2], plot=False):
|
||||
|
||||
Reference in New Issue
Block a user