-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In/Out Endpoint Configuration #135
In/Out Endpoint Configuration #135
Conversation
renzodgc
commented
Feb 12, 2021
- Add endpoints to support the In/Out Metric.
- Add structure for the metric's implementation.
- Fixed typos in metrics interface.
api/models/camera.py
Outdated
|
||
|
||
class InOutBoundaries(BaseModel): | ||
in_line: Tuple[Tuple[int, int], Tuple[int, int]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will also need the direction of movement for each line. Not sure about the best way to store it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't it from in
to out
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. Each line has a direction. Only if a person is moving in that direction it will be counted. In/Out could possibly be the same line but will have opposite directions
""" | ||
in_out_file_path = InOutMetric.get_in_out_file_path(camera_id, settings.config) | ||
in_out_boundaries = InOutMetric.get_in_out_boundaries(in_out_file_path) | ||
if in_out_boundaries is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that before checking for the boundaries we should check for camera existence in order to return a clear 404 message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I thought we were doing that by default on a callback, I'll update the endpoints to check for camera existance
def get_in_out_file_path(cls, camera_id, config): | ||
""" Returns the path to the roi_contour file """ | ||
return f"{get_source_log_directory(config)}/{camera_id}/{IN_OUT}/{IN_OUT}.json" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if the log directory is the best place to store these configuration files (such as the calibration matrix and the in/out json).
Maybe we can "refactor" this and store the config files in a different folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't want to clog the camera's configs, and the file should be inside one of the folders for a specific camera
api/routers/cameras.py
Outdated
@@ -236,6 +239,7 @@ async def get_camera_image(camera_id: str): | |||
""" | |||
Gets the image related to the camera <camera_id> | |||
""" | |||
_ = get_camera_from_id(camera_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this probably works, it doesn't sound right. I think you are misusing the function or at least the name is very misleading
api/routers/cameras.py
Outdated
@@ -347,8 +355,12 @@ async def remove_roi_contour(camera_id: str, reboot_processor: Optional[bool] = | |||
@cameras_router.get("/{camera_id}/in_out_boundaries") | |||
async def get_in_out_boundaries(camera_id: str): | |||
""" | |||
Get the In/Out Boundaries | |||
Get the In/Out Boundaries for a camera. | |||
Two coordinates `[x,y]` are given in duples `[A,B]`. These points form a **line**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two coordinates `[x,y]` are given in duples `[A,B]`. These points form a **line**. | |
Two coordinates `[x,y]` are given in tuples `[A,B]`. These points form a **line**. |