-
Notifications
You must be signed in to change notification settings - Fork 611
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
[wpiutil] Add a RawFrame JNI overload for byte[] #7179
base: main
Are you sure you want to change the base?
Conversation
49c9164
to
7c0b158
Compare
/format |
992a56b
to
d2caa5e
Compare
Allows avoiding two copies in wpilibsuite#7176 Signed-off-by: Jade Turner <[email protected]>
d2caa5e
to
e264c51
Compare
If desired an overload which just takes the |
Yeah this gets rid of one copy, but for use with opencv mats we need an overload that takes (long pData, int width/height/stride/format). Not sure if there's any other implications for making a RawFrame which doesn't own the underlying array. |
Hmm Peter raised concerns about that, how bad would the performance implications of the copy be in PhotonVision usecase? Is there any way to use RawFrame over Mat there? |
I don't think that the Mat constructor that takes a pointer to C++ backed data is accessible. Also cscore's USBCamera gives us a Mat right? Not a RawFrame? I will need to convert one to the other at some point, and it's not workable to incur an extra copy at any step (it's on the order of ms on embedded devices) |
What's the concern with making RawFrame not own the underlying data? Opencv's mats let you do this. |
We could change USBCamera to give a raw frame |
If we do that, someone should provide a way to get that data into a opencv Mat without extra copies happening. Thats possible in photon via our new JNI capabilities, I guess, if we wanna commit to nuking opencv entirely. |
USBCamera doesn't give a Mat by itself, it's instead added as a source to a CvSink, and the Mat is pulled from that. We could instead use a RawSink, which will allow us to use a RawFrame instead of a Mat. As for the dangers of taking the pointer stored in the Mat and using it in RawFrame, Mat uses |
It looks like the Java matrix wrapping the RawMat being released isn't a concern? See the release javadoc claim: https://docs.opencv.org/3.4/d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e
Also in Mat::Mat:
|
Allows avoiding two copies in #7176
cc @mcm001