Skip to content

Commit

Permalink
Merge branch 'cluster-estimation-worker-integration-redo' of https://…
Browse files Browse the repository at this point in the history
…github.com/UWARG/computer-vision-python into cluster-estimation-worker-integration-redo
  • Loading branch information
Aleksa-M committed Nov 7, 2024
2 parents 617ae90 + db684fa commit 3f799e0
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions main_2024.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from modules.geolocation import geolocation_worker
from modules.geolocation import camera_properties
from modules.cluster_estimation import cluster_estimation_worker
from modules.cluster_estimation import cluster_estimation_worker
from modules.common.modules.logger import logger
from modules.common.modules.logger import logger_main_setup
from modules.common.modules.read_yaml import read_yaml
Expand Down Expand Up @@ -113,6 +114,10 @@ def main() -> int:
GEOLOCATION_CAMERA_ORIENTATION_PITCH = config["geolocation"]["camera_orientation_pitch"]
GEOLOCATION_CAMERA_ORIENTATION_ROLL = config["geolocation"]["camera_orientation_roll"]

MIN_ACTIVATION_THRESHOLD = config["cluster_estimation"]["min_activation_threshold"]
MIN_NEW_POINTS_TO_RUN = config["cluster_estimation"]["min_new_points_to_run"]
RANDOM_STATE = config["cluster_estimation"]["random_state"]

MIN_ACTIVATION_THRESHOLD = config["cluster_estimation"]["min_activation_threshold"]
MIN_NEW_POINTS_TO_RUN = config["cluster_estimation"]["min_new_points_to_run"]
RANDOM_STATE = config["cluster_estimation"]["random_state"]
Expand Down Expand Up @@ -144,6 +149,7 @@ def main() -> int:
mp_manager,
QUEUE_MAX_SIZE,
)
geolocation_to_cluster_estimation_queue = queue_proxy_wrapper.QueueProxyWrapper(
geolocation_to_cluster_estimation_queue = queue_proxy_wrapper.QueueProxyWrapper(
mp_manager,
QUEUE_MAX_SIZE,
Expand All @@ -156,6 +162,10 @@ def main() -> int:
mp_manager,
QUEUE_MAX_SIZE,
)
cluster_estimation_to_main_queue = queue_proxy_wrapper.QueueProxyWrapper(
mp_manager,
QUEUE_MAX_SIZE,
)

result, camera_intrinsics = camera_properties.CameraIntrinsics.create(
GEOLOCATION_RESOLUTION_X,
Expand Down Expand Up @@ -276,6 +286,7 @@ def main() -> int:
),
input_queues=[data_merge_to_geolocation_queue],
output_queues=[geolocation_to_cluster_estimation_queue],
output_queues=[geolocation_to_cluster_estimation_queue],
controller=controller,
local_logger=main_logger,
)
Expand All @@ -302,6 +313,22 @@ def main() -> int:
# Get Pylance to stop complaining
assert cluster_estimation_worker_properties is not None

result, cluster_estimation_worker_properties = worker_manager.WorkerProperties.create(
count=1,
target=cluster_estimation_worker.cluster_estimation_worker,
work_arguments=(MIN_ACTIVATION_THRESHOLD, MIN_NEW_POINTS_TO_RUN, RANDOM_STATE),
input_queues=[geolocation_to_cluster_estimation_queue],
output_queues=[cluster_estimation_to_main_queue],
controller=controller,
local_logger=main_logger,
)
if not result:
main_logger.error("Failed to create arguments for Cluster Estimation", True)
return -1

# Get Pylance to stop complaining
assert cluster_estimation_worker_properties is not None

# Create managers
worker_managers = []

Expand Down Expand Up @@ -383,6 +410,19 @@ def main() -> int:

worker_managers.append(cluster_estimation_manager)

result, cluster_estimation_manager = worker_manager.WorkerManager.create(
worker_properties=cluster_estimation_worker_properties,
local_logger=main_logger,
)
if not result:
main_logger.error("Failed to create manager for Cluster Estimation", True)
return -1

# Get Pylance to stop complaining
assert cluster_estimation_manager is not None

worker_managers.append(cluster_estimation_manager)

# Run
for manager in worker_managers:
manager.start_workers()
Expand All @@ -396,9 +436,15 @@ def main() -> int:

try:
cluster_estimation_data = cluster_estimation_to_main_queue.queue.get_nowait()
cluster_estimation_data = cluster_estimation_to_main_queue.queue.get_nowait()
except queue.Empty:
cluster_estimation_data = None
cluster_estimation_data = None

if cluster_estimation_data is not None:
for object_in_world in cluster_estimation_data:
main_logger.debug("Cluster in world: ", True)
main_logger.debug(str(object_in_world))
if cluster_estimation_data is not None:
for object_in_world in cluster_estimation_data:
main_logger.debug("Cluster in world: ", True)
Expand All @@ -415,8 +461,10 @@ def main() -> int:
flight_interface_to_data_merge_queue.fill_and_drain_queue()
data_merge_to_geolocation_queue.fill_and_drain_queue()
geolocation_to_cluster_estimation_queue.fill_and_drain_queue()
geolocation_to_cluster_estimation_queue.fill_and_drain_queue()
flight_interface_decision_queue.fill_and_drain_queue()
cluster_estimation_to_main_queue.fill_and_drain_queue()
cluster_estimation_to_main_queue.fill_and_drain_queue()

for manager in worker_managers:
manager.join_workers()
Expand Down

0 comments on commit 3f799e0

Please sign in to comment.