Skip to content

Commit

Permalink
refactor video_input save_prefix to image_name, for proper use with l…
Browse files Browse the repository at this point in the history
…ogger.save_image
  • Loading branch information
maxlou05 committed Dec 22, 2024
1 parent 8ddc188 commit e7f966c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ video_input:
# contrast: 1.0 # Contrast, 1.0 for nomral, 32.0 for max, 0.0 for min
# lens_position: null # Focal length, 1/m (0 for infinity, null for auto focus)
log_images: true # Set to true to save images
save_prefix: "log_image" # Image name prefix when saving images
image_name: "log_image" # Image name when saving images

detect_target:
worker_count: 1
Expand Down
15 changes: 7 additions & 8 deletions main_2024.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,12 @@ def main() -> int:
**config["video_input"]["camera_config"]
)
case _:
raise ValueError(f"Inputted an invalid camera option: {VIDEO_INPUT_OPTION}")
if config["video_input"]["log_images"]:
VIDEO_INPUT_SAVE_PREFIX = None
else:
VIDEO_INPUT_SAVE_PREFIX = str(
pathlib.Path(logging_path, config["video_input"]["save_prefix"])
)
main_logger.error(f"Inputted an invalid camera option: {VIDEO_INPUT_OPTION}", True)
return -1

VIDEO_INPUT_IMAGE_NAME = (
config["video_input"]["image_name"] if config["video_input"]["log_images"] else None
)

DETECT_TARGET_WORKER_COUNT = config["detect_target"]["worker_count"]
DETECT_TARGET_OPTION = detect_target_factory.DetectTargetOption(
Expand Down Expand Up @@ -225,7 +224,7 @@ def main() -> int:
VIDEO_INPUT_WIDTH,
VIDEO_INPUT_HEIGHT,
VIDEO_INPUT_CAMERA_CONFIG,
VIDEO_INPUT_SAVE_PREFIX,
VIDEO_INPUT_IMAGE_NAME,
VIDEO_INPUT_WORKER_PERIOD,
),
input_queues=[],
Expand Down
2 changes: 1 addition & 1 deletion modules/video_input/video_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create(
width is the width of the images the camera takes in pixels.
height is the height of the images the camera takes in pixels.
camera_config specifies camera settings.
maybe_image_name is name of iamge log files. Set to None to not log any images.
maybe_image_name is the filename to save the image as. Set to None to not log any images.
"""
result, camera = camera_factory.create_camera(camera_option, width, height, config)
if not result:
Expand Down

0 comments on commit e7f966c

Please sign in to comment.