Skip to content
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

Allow creating CvMat over an existing buffer #426

Open
GoogleCodeExporter opened this issue Dec 5, 2015 · 1 comment
Open

Allow creating CvMat over an existing buffer #426

GoogleCodeExporter opened this issue Dec 5, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Currently, to create, say a NV12 image, one needs to do these 2 steps:
opencv_core.CvMat nv21Image = opencv_core.CvMat.create((int)(1.5 * height), 
width, opencv_core.CV_8UC2);
nv21Image.getByteBuffer().put(image_data); // byte[] image_data

Most of the time though, the image is placed into the same buffer by the 
caller. So, if we wrapped opencv_core.CvMat over an existing buffer, this would 
save some time on not having to copy the bytes over.

Original issue reported on code.google.com by eug...@wearableintelligence.com on 10 Feb 2014 at 9:52

@GoogleCodeExporter
Copy link
Author

The problem is with byte[]: It can't be pinned down across native function 
calls. There's a way to optimize that within a single JNI call by using 
GetPrimitiveArrayCritical() but I'm not sure how we could take advantage of 
that at a higher level... That would be a request for JavaCPP though:
http://code.google.com/p/javacpp/issues/

This difficult of Java array to be used on the native side efficiently is what 
prompted Sun to create direct NIO buffers in the first place, so we should ask 
Google to add support for NIO buffers there :)

BTW, there appears to be a better hack to capture from the camera on Android, 
as mentioned at issue #422.

Original comment by samuel.a...@gmail.com on 11 Feb 2014 at 1:52

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant