can I suggest adding a new version of
ITextureEffect which accepts java.nio.Buffer and channel ordering?
I'm experimenting with the idea of mixing OpenCV with jPCT and making them to render to same GLSurfaceView as I mentioned in
this thread. the pipeline is something like:
* take android's camera preview data (byte[]) and put into an OpenCV Mat
1 object
* modify and/or process Mat via OpenCV
* copy final contents of Mat into a jPCT texture via an ITextureEffect
* blit that texture as background
* render 3d content over that
all is fine for now except the fps. some profiling suggests most of the time is spent in ITextureEffect.apply(..) method.
there are two issues:
* jPCT wants texture data in ARGB channel order but OpenCV supports RGBA and BGRA, not ARGB
* jPCT wants all channels embedded into an int but OpenCV gives chanels as different bytes (or float/short/int whatever depth is used)
so I take the byte array from OpenCV, iterate over that, re-arrange the bytes and create an int out of that. jPCT takes that and puts them into a nio.Buffer, quite a waste.
long story short, it may be good idea to add a new version of
ITextureEffect which accepts java.nio.Buffer and channel ordering. unless of course there is a better way?
as an implementation detail, this new one can extend from the current ITextureEffect to keep things simple:
interface INioBufferTextureEffect extends ITextureEffect {
// channel order maybe return type or a setting in Config.
// if filling in source is costly, it can even be skipped based on a setting in Config
void apply(java.nio.Buffer dest, java.nio.Buffer source);
}
1: Mat is an OpenCV matrix like structure which can hold and convert to a matrix of arbitrary depth. pixels of an image or a perspective transform for example.