Skip to content

Commit

Permalink
cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob1in committed May 6, 2024
1 parent 5dda24a commit 0c0f3ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion services/vision/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ func (c *client) CaptureAllFromCamera(
returnObject bool,
extra map[string]interface{},
) (viscapture.VisCapture, error) {
fmt.Println("REACHED CLIENT.GO CAPTUREALL()")
ctx, span := trace.StartSpan(ctx, "service::vision::client::ClassificationsFromCamera")
defer span.End()
ext, err := protoutils.StructToStructPb(extra)
Expand Down
20 changes: 17 additions & 3 deletions services/vision/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
pb "go.viam.com/api/service/vision/v1"
"go.viam.com/rdk/vision/classification"
"go.viam.com/rdk/vision/objectdetection"
"image"

"go.viam.com/rdk/pointcloud"
"go.viam.com/rdk/protoutils"
Expand Down Expand Up @@ -263,24 +264,37 @@ func (server *serviceServer) CaptureAllFromCamera(ctx context.Context, req *pb.C
return nil, err
}
capt, err := svc.CaptureAllFromCamera(ctx, req.CameraName, req.ReturnImage, req.ReturnDetections, req.ReturnClassifications, req.ReturnObjectPointClouds, req.Extra.AsMap())
if err != nil {
return nil, err
}

//objectsPCD
objProto, err := segmentsToProto(req.CameraName, capt.PointCloudObject())
if err != nil {
return nil, err
}

img := capt.Image()
imgBytes, err := rimage.EncodeImage(ctx, img, utils.MimeTypeJPEG)
imgProto, err := imageToProto(ctx, capt.Image(), utils.MimeTypeJPEG)
if err != nil {
return nil, err
}

return &pb.CaptureAllFromCameraResponse{

Check failure on line 282 in services/vision/server.go

View workflow job for this annotation

GitHub Actions / macos / build

undefined: pb.CaptureAllFromCameraResponse
Image: &v11.Image{Image: imgBytes},
Image: imgProto,
Detections: detsToProto(capt.Detections()),
Classifications: clasToProto(capt.Classifications()),
Objects: objProto,
}, nil
}

func imageToProto(ctx context.Context, img image.Image, mimeType string) (*v11.Image, error) {
imgBytes, err := rimage.EncodeImage(ctx, img, mimeType)
if err != nil {
return nil, err
}
return &v11.Image{Image: imgBytes}, nil
}

// DoCommand receives arbitrary commands.
func (server *serviceServer) DoCommand(ctx context.Context,
req *commonpb.DoCommandRequest,
Expand Down
2 changes: 0 additions & 2 deletions services/vision/vision.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package vision

import (
"context"
"fmt"
"go.viam.com/rdk/vision/viscapture"
"image"

Expand Down Expand Up @@ -207,7 +206,6 @@ func (vm *vizModel) GetObjectPointClouds(ctx context.Context, cameraName string,
}

func (vm *vizModel) CaptureAllFromCamera(ctx context.Context, cameraName string, returnImage bool, returnClass bool, returnDet bool, returnObjPCD bool, extra map[string]interface{}) (viscapture.VisCapture, error) {
fmt.Println("REACHED VISION.GO CAPTUREALL()")
ctx, span := trace.StartSpan(ctx, "service::vision::ClassificationsFromCamera::"+vm.Named.Name().String())
defer span.End()
cam, err := camera.FromRobot(vm.r, cameraName)
Expand Down

0 comments on commit 0c0f3ec

Please sign in to comment.