Skip to content

Return Uint8Array image from captureAllFromCamera #342

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

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/services/vision/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,17 @@ export class VisionClient implements Vision {
pb.CaptureAllFromCameraRequest,
pb.CaptureAllFromCameraResponse
>(service.captureAllFromCamera.bind(service), request);

const image = response.getImage();

return {
image: response.getImage()?.toObject(),
image: image
? {
format: image.getFormat(),
sourceName: image.getSourceName(),
image: image.getImage_asU8(),
Comment on lines +198 to +200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the return value of this function strictly typed? If so, all good. If not, this image response could drift if someone changed the image definition (e.g. added a new field to Image)

Copy link
Member Author

@micheal-parks micheal-parks Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, it's following the definition of Image and a return type error will be thrown by TSC if it doesn't adhere to it.

}
: undefined,
classifications: response
.getClassificationsList()
.map((classification: pb.Classification) => classification.toObject()),
Expand Down