Skip to content

Commit

Permalink
Fix up obstacle depth; Delete custom extra type;
Browse files Browse the repository at this point in the history
  • Loading branch information
hexbabe committed Nov 7, 2024
1 parent 16079fa commit 9084264
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 64 deletions.
2 changes: 1 addition & 1 deletion components/camera/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func newReadImageCollector(resource interface{}, params data.CollectorParams) (d
if err := mimeType.UnmarshalTo(mimeStr); err != nil {
return nil, err
}
img, _, err := camera.Image(ctx, mimeStr.Value, Extra{})
img, _, err := camera.Image(ctx, mimeStr.Value, nil)
if err != nil {
// A modular filter component can be created to filter the readings from a component. The error ErrNoCaptureToStore
// is used in the datamanager to exclude readings from being captured and stored.
Expand Down
22 changes: 0 additions & 22 deletions components/camera/extra.go

This file was deleted.

27 changes: 0 additions & 27 deletions components/camera/extra_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion robot/impl/local_robot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestConfig1(t *testing.T) {
c1, err := camera.FromRobot(r, "c1")
test.That(t, err, test.ShouldBeNil)
test.That(t, c1.Name(), test.ShouldResemble, camera.Named("c1"))
outBytes, mimeType, err := c1.Image(context.Background(), rutils.MimeTypeJPEG, camera.Extra{})
outBytes, mimeType, err := c1.Image(context.Background(), rutils.MimeTypeJPEG, nil)
test.That(t, err, test.ShouldBeNil)
pic, err := rimage.DecodeImage(context.Background(), outBytes, mimeType)
test.That(t, err, test.ShouldBeNil)
Expand Down
17 changes: 4 additions & 13 deletions services/vision/obstaclesdepth/obstacles_depth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"go.opencensus.io/trace"

"go.viam.com/rdk/components/camera"
"go.viam.com/rdk/gostream"
"go.viam.com/rdk/logging"
"go.viam.com/rdk/resource"
"go.viam.com/rdk/rimage"
Expand Down Expand Up @@ -118,18 +117,14 @@ func (o *obsDepth) buildObsDepth(logger logging.Logger) func(

// buildObsDepthNoIntrinsics will return the median depth in the depth map as a Geometry point.
func (o *obsDepth) obsDepthNoIntrinsics(ctx context.Context, src camera.VideoSource) ([]*vision.Object, error) {
ext, ok := camera.FromContext(ctx)
if !ok {
ext = camera.Extra{}
}
imgBytes, mimeType, err := src.Image(ctx, gostream.MIMETypeHint(ctx, utils.MimeTypeRawDepth), ext)
imgBytes, mimeType, err := src.Image(ctx, utils.MimeTypeRawDepth, nil)
if err != nil {
return nil, errors.Errorf("could not get image from %s", src)
}

pic, err := rimage.DecodeImage(ctx, imgBytes, mimeType)
if err != nil {
return nil, errors.Errorf("could not decode image from %s", src)
return nil, errors.New("could not decode image from obstacle depth source(1)")
}
dm, err := rimage.ConvertImageToDepthMap(ctx, pic)
if err != nil {
Expand Down Expand Up @@ -157,17 +152,13 @@ func (o *obsDepth) obsDepthWithIntrinsics(ctx context.Context, src camera.VideoS
if o.intrinsics == nil {
return nil, errors.New("tried to build obstacles depth with intrinsics but no instrinsics found")
}
ext, ok := camera.FromContext(ctx)
if !ok {
ext = camera.Extra{}
}
imgBytes, mimeType, err := src.Image(ctx, gostream.MIMETypeHint(ctx, utils.MimeTypeRawDepth), ext)
imgBytes, mimeType, err := src.Image(ctx, utils.MimeTypeRawDepth, nil)
if err != nil {
return nil, errors.Errorf("could not get image from %s", src)
}
pic, err := rimage.DecodeImage(ctx, imgBytes, mimeType)
if err != nil {
return nil, errors.Errorf("could not decode image from %s", src)
return nil, errors.New("could not decode image from obstacle depth source(2)")
}
dm, err := rimage.ConvertImageToDepthMap(ctx, pic)
if err != nil {
Expand Down

0 comments on commit 9084264

Please sign in to comment.