feat: refactor and option to configure camera fps
This commit is contained in:
parent
2593d5d953
commit
d4f8a12577
@ -10,7 +10,7 @@ import typing, types
|
|||||||
import depthai as dai
|
import depthai as dai
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
from . import depthai as cam # pylint: disable=reimported
|
from camera import oak_pipeline as cam
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,6 +45,10 @@ def _parse_args_cli() -> argparse.Namespace:
|
|||||||
help="threshold to filter detected objects",
|
help="threshold to filter detected objects",
|
||||||
type=float,
|
type=float,
|
||||||
default=_get_env_float_value("OBJECTS_THRESHOLD", 0.2))
|
default=_get_env_float_value("OBJECTS_THRESHOLD", 0.2))
|
||||||
|
parser.add_argument("-f", "--camera-fps",
|
||||||
|
help="set rate at which camera should produce frames",
|
||||||
|
type=int,
|
||||||
|
default=30)
|
||||||
parser.add_argument("-H", "--image-height", help="image height",
|
parser.add_argument("-H", "--image-height", help="image height",
|
||||||
type=int,
|
type=int,
|
||||||
default=_get_env_int_value("IMAGE_HEIGHT", 120))
|
default=_get_env_int_value("IMAGE_HEIGHT", 120))
|
||||||
@ -101,6 +105,7 @@ def execute_from_command_line() -> None:
|
|||||||
camera=cam.CameraSource(pipeline=pipeline,
|
camera=cam.CameraSource(pipeline=pipeline,
|
||||||
img_width=args.image_width,
|
img_width=args.image_width,
|
||||||
img_height=args.image_height,
|
img_height=args.image_height,
|
||||||
|
fps=args.camera_fps,
|
||||||
))
|
))
|
||||||
|
|
||||||
def sigterm_handler(signum: int, frame: typing.Optional[
|
def sigterm_handler(signum: int, frame: typing.Optional[
|
||||||
|
@ -196,7 +196,7 @@ class ObjectDetectionNN:
|
|||||||
class CameraSource(Source):
|
class CameraSource(Source):
|
||||||
"""Image source based on camera preview"""
|
"""Image source based on camera preview"""
|
||||||
|
|
||||||
def __init__(self, pipeline: dai.Pipeline, img_width: int, img_height: int):
|
def __init__(self, pipeline: dai.Pipeline, img_width: int, img_height: int, fps: int):
|
||||||
self._cam_rgb = pipeline.createColorCamera()
|
self._cam_rgb = pipeline.createColorCamera()
|
||||||
self._xout_rgb = pipeline.createXLinkOut()
|
self._xout_rgb = pipeline.createXLinkOut()
|
||||||
self._xout_rgb.setStreamName("rgb")
|
self._xout_rgb.setStreamName("rgb")
|
||||||
@ -206,7 +206,7 @@ class CameraSource(Source):
|
|||||||
self._cam_rgb.setPreviewSize(width=img_width, height=img_height)
|
self._cam_rgb.setPreviewSize(width=img_width, height=img_height)
|
||||||
self._cam_rgb.setInterleaved(False)
|
self._cam_rgb.setInterleaved(False)
|
||||||
self._cam_rgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
|
self._cam_rgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
|
||||||
self._cam_rgb.setFps(30)
|
self._cam_rgb.setFps(fps)
|
||||||
|
|
||||||
# link camera preview to output
|
# link camera preview to output
|
||||||
self._cam_rgb.preview.link(self._xout_rgb.input)
|
self._cam_rgb.preview.link(self._xout_rgb.input)
|
Loading…
Reference in New Issue
Block a user