Skip to content
Snippets Groups Projects
Commit 481c52fc authored by Simon Wittl's avatar Simon Wittl
Browse files

dev

parent 3bbaae66
No related branches found
No related tags found
No related merge requests found
Metadata-Version: 2.1
Name: rq_controller
Version: 0.0.0
Summary: TODO: Package description
Maintainer: root
Maintainer-email: simon.wittl@th-deg.de
License: TODO: License declaration
Requires-Dist: setuptools
README.md
package.xml
setup.cfg
setup.py
resource/rq_controller
rq_controller/__init__.py
rq_controller.egg-info/PKG-INFO
rq_controller.egg-info/SOURCES.txt
rq_controller.egg-info/dependency_links.txt
rq_controller.egg-info/requires.txt
rq_controller.egg-info/top_level.txt
rq_controller.egg-info/zip-safe
rq_controller/common/__init__.py
rq_controller/common/projection.py
rq_controller/common/projection_geometry.py
rq_controller/common/region_of_intrest.py
rq_controller/common/io/__init__.py
rq_controller/common/io/loader.py
rq_controller/common/io/writer.py
rq_controller/common/io/rq_json/__init__.py
rq_controller/common/io/rq_json/load.py
rq_controller/common/io/rq_json/write.py
test/test_copyright.py
test/test_flake8.py
test/test_pep257.py
\ No newline at end of file
setuptools
rq_controller
from __future__ import annotations
import numpy as np import numpy as np
from numpy import ndarray from numpy import ndarray
from .projection_geometry import PyProjectionGeometry from .projection_geometry import PyProjectionGeometry
from rq_interfaces.msg import Projection, ProjectionGeometry from rq_interfaces.msg import Projection, ProjectionGeometry
from sensor_msgs.msg import Image
import ros2_numpy
class PyProjection(PyProjectionGeometry): class PyProjection(PyProjectionGeometry):
def __init__(self, focal_spot_mm: ndarray, detector_postion_mm: ndarray, detector_orientation_quad: ndarray, image: np.ndarray, def __init__(self, focal_spot_mm: ndarray, detector_postion_mm: ndarray, detector_orientation_quad: ndarray, image: np.ndarray,
detector_heigth_mm: float, detector_width_mm: float, frame_id: str = 'object') -> None: detector_heigth_mm: float, detector_width_mm: float, frame_id: str = 'object',
super().__init__(focal_spot_mm, detector_postion_mm, detector_orientation_quad, frame_id) focal_spot_orientation_quad: np.ndarray = np.array([0., 0., 0, 1.])) -> None:
self.image = image super().__init__(focal_spot_mm, detector_postion_mm, detector_orientation_quad, frame_id, focal_spot_orientation_quad)
self.image = image.astype(np.uint16)
self.detector_heigth_mm = detector_heigth_mm self.detector_heigth_mm = detector_heigth_mm
self.detector_width_mm = detector_width_mm self.detector_width_mm = detector_width_mm
...@@ -36,12 +42,20 @@ class PyProjection(PyProjectionGeometry): ...@@ -36,12 +42,20 @@ class PyProjection(PyProjectionGeometry):
msg.projection_geometry.detector_orientation_quad.z, msg.projection_geometry.detector_orientation_quad.z,
msg.projection_geometry.detector_orientation_quad.w]) msg.projection_geometry.detector_orientation_quad.w])
image = msg.image focal_spot_orientation = np.array([msg.projection_geometry.focal_spot_orientation_quad.x,
msg.projection_geometry.focal_spot_orientation_quad.y,
msg.projection_geometry.focal_spot_orientation_quad.z,
msg.projection_geometry.focal_spot_orientation_quad.w])
detector_heigth_mm = msg.detector_heigth_mm detector_heigth_mm = msg.detector_heigth_mm
detector_width_mm = msg.detector_width_mm detector_width_mm = msg.detector_width_mm
frame_id = msg.projection_geometry.header.frame_id frame_id = msg.projection_geometry.header.frame_id
return cls(focal_spot_mm, detector_center_mm, detector_orientation_quad, image, detector_heigth_mm, detector_width_mm, frame_id) image = ros2_numpy.numpify(msg.image)
return cls(focal_spot_mm, detector_center_mm, detector_orientation_quad, image,
detector_heigth_mm, detector_width_mm, frame_id, focal_spot_orientation)
def as_message(self) -> ProjectionGeometry: def as_message(self) -> ProjectionGeometry:
message = Projection() message = Projection()
...@@ -60,8 +74,14 @@ class PyProjection(PyProjectionGeometry): ...@@ -60,8 +74,14 @@ class PyProjection(PyProjectionGeometry):
projection_geometry.detector_orientation_quad.z = self.detector_orientation_quad[2] projection_geometry.detector_orientation_quad.z = self.detector_orientation_quad[2]
projection_geometry.detector_orientation_quad.w = self.detector_orientation_quad[3] projection_geometry.detector_orientation_quad.w = self.detector_orientation_quad[3]
projection_geometry.focal_spot_orientation_quad.x = self.focal_spot_orientation_quad[0]
projection_geometry.focal_spot_orientation_quad.y = self.focal_spot_orientation_quad[1]
projection_geometry.focal_spot_orientation_quad.z = self.focal_spot_orientation_quad[2]
projection_geometry.focal_spot_orientation_quad.w = self.focal_spot_orientation_quad[3]
message.projection_geometry = projection_geometry message.projection_geometry = projection_geometry
message.image = self.image message.image = ros2_numpy.msgify(Image, self.image, 'mono16')
message.detector_heigth_mm = self.detector_heigth_mm message.detector_heigth_mm = self.detector_heigth_mm
message.detector_width_mm = self.detector_width_mm message.detector_width_mm = self.detector_width_mm
......
from __future__ import annotations
import numpy as np import numpy as np
from rq_interfaces.msg import ProjectionGeometry from rq_interfaces.msg import ProjectionGeometry, Projection
class PyProjectionGeometry(): class PyProjectionGeometry():
def __init__(self, focal_spot_mm: np.ndarray, detector_postion_mm: np.ndarray, detector_orientation_quad: np.ndarray, def __init__(self, focal_spot_mm: np.ndarray, detector_postion_mm: np.ndarray,
frame_id: str = 'object') -> None: detector_orientation_quad: np.ndarray,
frame_id: str = 'object', focal_spot_orientation_quad: np.ndarray = np.array([0., 0., 0, 1.])
) -> None:
self.focal_spot_mm = focal_spot_mm self.focal_spot_mm = focal_spot_mm
self.detector_postion_mm = detector_postion_mm self.detector_postion_mm = detector_postion_mm
self.focal_spot_orientation_quad = focal_spot_orientation_quad
self.detector_orientation_quad = detector_orientation_quad self.detector_orientation_quad = detector_orientation_quad
self.frame_id = frame_id self.frame_id = frame_id
...@@ -14,7 +19,7 @@ class PyProjectionGeometry(): ...@@ -14,7 +19,7 @@ class PyProjectionGeometry():
def dummy(cls): def dummy(cls):
return cls(np.array([1., 0., 0]), return cls(np.array([1., 0., 0]),
np.array([-1., 0., 0]), np.array([-1., 0., 0]),
np.array([1., 0., 0, 1.])) np.array([0., 0., 0, 1.]))
@classmethod @classmethod
def from_message(cls, msg: ProjectionGeometry): def from_message(cls, msg: ProjectionGeometry):
...@@ -30,9 +35,15 @@ class PyProjectionGeometry(): ...@@ -30,9 +35,15 @@ class PyProjectionGeometry():
msg.detector_orientation_quad.y, msg.detector_orientation_quad.y,
msg.detector_orientation_quad.z, msg.detector_orientation_quad.z,
msg.detector_orientation_quad.w]) msg.detector_orientation_quad.w])
focal_spot_orientation = np.array([msg.focal_spot_orientation_quad.x,
msg.focal_spot_orientation_quad.y,
msg.focal_spot_orientation_quad.z,
msg.focal_spot_orientation_quad.w])
frame_id = msg.header.frame_id frame_id = msg.header.frame_id
return cls(focal_spot_mm, detector_center_mm, detector_orientation_quad, frame_id) return cls(focal_spot_mm, detector_center_mm, detector_orientation_quad, frame_id, focal_spot_orientation)
def as_message(self) -> ProjectionGeometry: def as_message(self) -> ProjectionGeometry:
message = ProjectionGeometry() message = ProjectionGeometry()
...@@ -45,6 +56,11 @@ class PyProjectionGeometry(): ...@@ -45,6 +56,11 @@ class PyProjectionGeometry():
message.detector_postion_mm.y = self.detector_postion_mm[1] message.detector_postion_mm.y = self.detector_postion_mm[1]
message.detector_postion_mm.z = self.detector_postion_mm[2] message.detector_postion_mm.z = self.detector_postion_mm[2]
message.focal_spot_orientation_quad.x = self.focal_spot_orientation_quad[0]
message.focal_spot_orientation_quad.y = self.focal_spot_orientation_quad[1]
message.focal_spot_orientation_quad.z = self.focal_spot_orientation_quad[2]
message.focal_spot_orientation_quad.w = self.focal_spot_orientation_quad[3]
message.detector_orientation_quad.x = self.detector_orientation_quad[0] message.detector_orientation_quad.x = self.detector_orientation_quad[0]
message.detector_orientation_quad.y = self.detector_orientation_quad[1] message.detector_orientation_quad.y = self.detector_orientation_quad[1]
message.detector_orientation_quad.z = self.detector_orientation_quad[2] message.detector_orientation_quad.z = self.detector_orientation_quad[2]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment