-
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
[DATA-535] Create an orbslam integration test that runs mono YCbCr im… #1502
Conversation
@@ -508,3 +508,51 @@ func EdgeHysteresisFiltering(mag *mat.Dense, low, high float64) (*image.Gray, er | |||
} | |||
return edges, nil | |||
} | |||
|
|||
// ImageToYCbCrForTesting converts an image to YCbCr. It is only to be used for testing. | |||
func ImageToYCbCrForTesting(dst *image.YCbCr, src image.Image) { |
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 couldn't find another was to convert to YCbCr, so I exported this function. Let me know if you have another idea!
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.
you can probably use the draw.Draw function to do this
import "image/draw"
func MakeYCbCr(pic image.Image) *image.YCbCr {
result := image.NewYCbCr(pic.Bounds())
draw.Draw(result, result.Bounds(), pic, pic.Bounds().Min, draw.Src)
return result
}
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.
It doesn't look like I can do this, since image.YCbCr doesn't implement draw.Image (missing method Set).
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.
oh wow, yea it looks like YCbCr isn't pixel addressable! So, yea, this function seems like the best bet for now
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.
Just found an alternative - but if you would like to stick to using one set of images (the png sources) then what you have now seems like the way to go
"mode": "rgbd", | ||
"orb_n_features": "1000", | ||
"mode": reflect.ValueOf(mode).String(), | ||
"orb_n_features": "1250", |
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 decided to change orb_n_features
to its default here.
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.
LGTM, as an alternative, you can decode JPEG images directly to YCbCr rather than converting the PNG images to to YCbCr
imgBytes, err := os.ReadFile(artifact.MustPath("slam/mock_mono_camera/rgb/" + strconv.FormatUint(i, 10) + ".png")) | ||
if err != nil { | ||
return nil, err | ||
} | ||
img, _, err := image.Decode(bytes.NewReader(imgBytes)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var ycbcrImg image.YCbCr | ||
rimage.ImageToYCbCrForTesting(&ycbcrImg, img) | ||
return gostream.NewEmbeddedVideoStreamFromReader( | ||
gostream.VideoReaderFunc(func(ctx context.Context) (image.Image, func(), error) { | ||
return &ycbcrImg, func() {}, nil | ||
}), | ||
), nil |
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.
If you had JPEG images, you could use the github.com/pixiv/go-libjpeg package and use its Decode function, which outputs YCbCr images directly: github.com/pixiv/go-libjpeg
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.
But you need the libjpeg library to use that package - which may not be present on our CI/canon
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.
Thanks for the idea! I think I'll leave as is.
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.
LGTM
|
…ages