-
Notifications
You must be signed in to change notification settings - Fork 48
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
RSDK-7565, RSDK-7471: add new methods to vision service get_properties and capture_all_from_camera #615
RSDK-7565, RSDK-7471: add new methods to vision service get_properties and capture_all_from_camera #615
Conversation
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
try: | ||
fmt = result.image.mime_type.to_proto() | ||
img_bytes = result.image.data | ||
img = Image(source_name=request.name, format=fmt, image=img_bytes) |
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.
this Image
is the viam.proto.component.camera.Image class, not a PIL image
CaptureAllFromCamera method. This is used most often for visualization purposes, since normally, | ||
returning the image on every call to a classifier/detector/etc would be costly and unnecessary. | ||
""" | ||
def __init__(self, image=None, classifications=None, detections=None, objects=None, extra={}): |
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 set the default results to None
rather than the empty list to distinguish between "there was no request for classifier to return a result" vs. "the classifier was requested, but there were no results" (I've put this explanation in the doc string as well)
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.
Generally looks good to me! I am unconvinced we need the CaptureAllRequest
type, but open to being talked into it :)
class CaptureAllRequest: | ||
""" | ||
CaptureAllRequest represents the collection of fields you can ask the | ||
CaptureAllFromCamera method to return. If you request something that the service | ||
cannot provide, a warning message will be generated, and the service will return an empty | ||
version of the requested thing. | ||
""" | ||
def __init__(self, return_image=False, return_classifications=False, | ||
return_detections=False, return_object_point_clouds=False): | ||
""" | ||
Args: | ||
return_image (bool): Return the image from the GetImage of the underlying camera. | ||
Default is False. | ||
return_classifications (bool): Return the classifications from GetClassifications. | ||
Default is False. | ||
return_detections (bool): Return the detections from GetDetections. | ||
Default is False. | ||
return_objet_point_clouds (bool): Return the point cloud objects from GetObjectPointClouds. | ||
Default is False. | ||
|
||
Returns: | ||
None | ||
""" | ||
self.return_image: bool = return_image | ||
self.return_classifications: bool = return_classifications | ||
self.return_detections: bool = return_detections | ||
self.return_object_point_clouds: bool = return_object_point_clouds |
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'm not convinced this is necessary or particularly helpful. This is only being used for a single call (CaptureAllFromCamera
) so we could just put these params and defaults on the capture_all_from_camera
method. And that way, a user doesn't have to look in multiple places to understand what their options are or why they matter.
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.
Mostly this is for future changes to the method and to ensure backwards compatability. Given that it is Capture"All", what "All" may mean may change in the future.
Let's say we add 2D segmentation as a vision service method. Then CaptureAll should be able to return it, too. But then it would be a breaking change to the method.
Actually, saying that outloud, python is nice in that you can assign defaults to arguments. So, if a future vision method was added, then the argument list could be extended then without breaking previous versions of the modules, because by default, the extra argument would be assigned a default value
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.
Essentially -- I was attempting to find a way to make it so there would not have to be a breaking change to the CaptureAll method if for some reason a method was added to the vision service in the future. If this is a futile task and creating a Request
class doesn't prevent a breaking change from happening, I'm willing to get rid of the class
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.
Agree, I don't think we need to have this class
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.
Apologies for making you do this, but could you base these changes off the rc-0.21.0
branch? That branch has changes that will affect this PR, and I don't want anyone to have to do this work twice, or go through a nasty rebase
class CaptureAllRequest: | ||
""" | ||
CaptureAllRequest represents the collection of fields you can ask the | ||
CaptureAllFromCamera method to return. If you request something that the service | ||
cannot provide, a warning message will be generated, and the service will return an empty | ||
version of the requested thing. | ||
""" | ||
def __init__(self, return_image=False, return_classifications=False, | ||
return_detections=False, return_object_point_clouds=False): | ||
""" | ||
Args: | ||
return_image (bool): Return the image from the GetImage of the underlying camera. | ||
Default is False. | ||
return_classifications (bool): Return the classifications from GetClassifications. | ||
Default is False. | ||
return_detections (bool): Return the detections from GetDetections. | ||
Default is False. | ||
return_objet_point_clouds (bool): Return the point cloud objects from GetObjectPointClouds. | ||
Default is False. | ||
|
||
Returns: | ||
None | ||
""" | ||
self.return_image: bool = return_image | ||
self.return_classifications: bool = return_classifications | ||
self.return_detections: bool = return_detections | ||
self.return_object_point_clouds: bool = return_object_point_clouds |
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.
Agree, I don't think we need to have this class
Closing this PR and opening the other one, based on rc-0.21.0 |
This adds two new methods the python SDK vision service
The mock vision service and tests were updated for these methods as well.