-
Notifications
You must be signed in to change notification settings - Fork 111
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-4333] negative resolutions ignored in camera configs. #3811
Changes from all commits
c0a9e06
b45d6f0
9a2c2e6
ff18556
5f32c40
a7d475d
fedb5b0
e54fb28
9815ddd
c9639a7
b8f691d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,6 @@ func init() { | |
|
||
// transformConfig specifies a stream and list of transforms to apply on images/pointclouds coming from a source camera. | ||
type transformConfig struct { | ||
resource.TriviallyValidateConfig | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was weird. We had a double implementation of Validate in pipeline, so I don't know which one it could have called, if it was deterministic at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Golang moment |
||
CameraParameters *transform.PinholeCameraIntrinsics `json:"intrinsic_parameters,omitempty"` | ||
DistortionParameters *transform.BrownConrady `json:"distortion_parameters,omitempty"` | ||
Debug bool `json:"debug,omitempty"` | ||
|
@@ -74,6 +73,16 @@ func (cfg *transformConfig) Validate(path string) ([]string, error) { | |
if len(cfg.Source) == 0 { | ||
return nil, resource.NewConfigValidationFieldRequiredError(path, "source") | ||
} | ||
|
||
if cfg.CameraParameters != nil { | ||
if cfg.CameraParameters.Height < 0 || cfg.CameraParameters.Width < 0 { | ||
return nil, errors.Errorf( | ||
"got illegal negative dimensions for width_px and height_px (%d, %d) fields set in intrinsic_parameters for transform camera", | ||
cfg.CameraParameters.Width, cfg.CameraParameters.Height, | ||
) | ||
} | ||
} | ||
|
||
deps = append(deps, cfg.Source) | ||
return deps, nil | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ package videosource | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
"image" | ||
"time" | ||
|
||
|
@@ -64,7 +65,6 @@ type fileSource struct { | |
|
||
// fileSourceConfig is the attribute struct for fileSource. | ||
type fileSourceConfig struct { | ||
resource.TriviallyValidateConfig | ||
CameraParameters *transform.PinholeCameraIntrinsics `json:"intrinsic_parameters,omitempty"` | ||
DistortionParameters *transform.BrownConrady `json:"distortion_parameters,omitempty"` | ||
Debug bool `json:"debug,omitempty"` | ||
|
@@ -73,6 +73,19 @@ type fileSourceConfig struct { | |
PointCloud string `json:"pointcloud_file_path,omitempty"` | ||
} | ||
|
||
// Validate ensures all parts of the config are valid. | ||
func (c fileSourceConfig) Validate(path string) ([]string, error) { | ||
if c.CameraParameters != nil { | ||
if c.CameraParameters.Width < 0 || c.CameraParameters.Height < 0 { | ||
return nil, fmt.Errorf( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here for fmt vs errors package |
||
"got illegal negative dimensions for width_px and height_px (%d, %d) fields set in intrinsic_parameters for image_file camera", | ||
c.CameraParameters.Height, c.CameraParameters.Width) | ||
} | ||
} | ||
|
||
return []string{}, nil | ||
} | ||
|
||
// Read returns just the RGB image if it is present, or the depth map if the RGB image is not present. | ||
func (fs *fileSource) Read(ctx context.Context) (image.Image, func(), error) { | ||
if fs.ColorFN == "" && fs.DepthFN == "" { | ||
|
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.
[optional]
errors.Errorf
does the same thing asfmt.Errorf
and you won't need to import a new packageThere 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.
That's part of "github.com/pkg/errors" not the standard "errors" go library (always gets me too). Not changing since that's a public archive.
We'll move away from the archived package in static.go eventually.