Skip to content

Commit ac17989

Browse files
authored
Merge pull request #67 from vaughantnrc/dev-tv-detector-comms-simplification
Detector Improvements
2 parents 9dbe1e0 + 5ee751b commit ac17989

File tree

74 files changed

+1850
-1767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1850
-1767
lines changed

data/detector_config.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"serial_identifier": "example_detector",
3-
"camera_implementation": "picamera",
4-
"camera_connection": {
5-
"usb_id": 0
6-
},
7-
"camera_intrinsic_parameters": {},
82
"calibrator_configuration": {
93
"data_path": "./example_data_path/"
4+
},
5+
"camera_configuration": {
6+
"driver": "picamera2",
7+
"capture_device": "0"
8+
},
9+
"marker_configuration": {
10+
"method": "aruco_opencv"
1011
}
1112
}

src/common/mct_component.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def dequeue_status_messages(self, **kwargs) -> DequeueStatusMessagesResponse:
8585
return DequeueStatusMessagesResponse(
8686
status_messages=status_messages)
8787

88+
def get_status_message_source(self):
89+
return self._status_message_source
90+
8891
@abc.abstractmethod
8992
def supported_request_types(self) -> dict[type[MCTRequest], Callable[[dict], MCTResponse]]:
9093
"""

src/common/structures/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .capture_format import CaptureFormat
2-
from .capture_status import CaptureStatus
32
from .component_role_label import \
43
ComponentRoleLabel, \
54
COMPONENT_ROLE_LABEL_DETECTOR, \
@@ -14,7 +13,6 @@
1413
CORNER_REFINEMENT_METHOD_DICTIONARY_TEXT_TO_INT
1514
from .detector_frame import DetectorFrame
1615
from .detection_parameters import DetectionParameters
17-
from .detector_resolution import DetectorResolution
1816
from .image_resolution import ImageResolution
1917
from .intrinsic_calibration import \
2018
IntrinsicCalibration, \
@@ -36,7 +34,6 @@
3634
from .marker_corner_image_point import MarkerCornerImagePoint
3735
from .marker_definition import MarkerDefinition
3836
from .marker_snapshot import MarkerSnapshot
39-
from .marker_status import MarkerStatus
4037
from .matrix4x4 import Matrix4x4
4138
from .mct_parsable import MCTParsable
4239
from .pose import Pose

src/common/structures/capture_status.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/common/structures/detector_resolution.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/common/structures/image_resolution.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ class ImageResolution(BaseModel):
55
x_px: int = Field()
66
y_px: int = Field()
77

8-
def __str__(self):
9-
return f"{self.x_px}x{self.y_px}"
8+
def __eq__(self, other) -> bool:
9+
if type(self) is not type(other):
10+
return False
11+
return \
12+
self.x_px == other.x_px and \
13+
self.y_px == other.y_px
14+
15+
def __hash__(self) -> int:
16+
return hash(str(self))
1017

1118
def __lt__(self, other):
1219
if not isinstance(other, ImageResolution):
@@ -20,6 +27,9 @@ def __lt__(self, other):
2027
else:
2128
return False
2229

30+
def __str__(self):
31+
return f"{self.x_px}x{self.y_px}"
32+
2333
@staticmethod
2434
def from_str(in_str: str) -> 'ImageResolution':
2535
if 'x' not in in_str:

src/common/structures/intrinsic_calibration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class IntrinsicCalibrationFrameResult(BaseModel):
1616

1717
class IntrinsicCalibration(BaseModel):
1818
timestamp_utc: str = Field()
19-
detector_serial_identifier: str = Field()
2019
image_resolution: ImageResolution = Field()
2120
calibrated_values: IntrinsicParameters = Field()
2221
calibrated_stdevs: list[float] = Field()

src/common/structures/intrinsic_parameters.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pydantic import BaseModel, Field
2+
import math
23

34

45
class IntrinsicParameters(BaseModel):
@@ -46,3 +47,24 @@ def get_distortion_coefficients(self) -> list[float]:
4647
self.tangential_distortion_coefficients[1]]
4748
coefficients += self.radial_distortion_coefficients[2:]
4849
return coefficients
50+
51+
@staticmethod
52+
def generate_zero_parameters(
53+
resolution_x_px: int,
54+
resolution_y_px: int,
55+
fov_x_degrees: float = 45.0,
56+
fov_y_degrees: float = 45.0
57+
) -> "IntrinsicParameters":
58+
optical_center_x_px: int = int(round(resolution_x_px/2.0))
59+
fov_x_radians: float = fov_x_degrees * math.pi / 180.0
60+
focal_length_x_px = (resolution_x_px / 2.0) / math.tan(fov_x_radians / 2.0)
61+
optical_center_y_px: int = int(round(resolution_y_px/2.0))
62+
fov_y_radians: float = fov_y_degrees * math.pi / 180.0
63+
focal_length_y_px = (resolution_y_px / 2.0) / math.tan(fov_y_radians / 2.0)
64+
return IntrinsicParameters(
65+
focal_length_x_px=focal_length_x_px,
66+
focal_length_y_px=focal_length_y_px,
67+
optical_center_x_px=optical_center_x_px,
68+
optical_center_y_px=optical_center_y_px,
69+
radial_distortion_coefficients=[0.0, 0.0, 0.0],
70+
tangential_distortion_coefficients=[0.0, 0.0])

src/common/structures/marker_status.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)