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

Converting java.awt.image to IplImage #2

Closed
GoogleCodeExporter opened this issue Jan 31, 2016 · 1 comment
Closed

Converting java.awt.image to IplImage #2

GoogleCodeExporter opened this issue Jan 31, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hi,
Is there a performant method to convert a java.awt.image or an array of
floats or int to an IplImage?
I tried set2D, but it's slow, like 7 seconds for 200x200 on 2GHz.

Original issue reported on code.google.com by markus.l...@gmail.com on 20 Apr 2010 at 3:58

@GoogleCodeExporter
Copy link
Author

This can be done in the usual Java way, by first copying the Image object into a
BufferedImage, and then copying that into an IplImage. Although copying is 
efficient,
it still involves two copies, but that's the best that can done. For example, 
given
an Image object "image", this should work:

BufferedImage bufferedImage = new BufferedImage(image.getWidth(null),
image.getHeight(null), BufferedImage.TYPE_3BYTE_BGR /* or whatever type you 
like */);
Graphics g = bufferedImage.getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
IplImage iplImage = IplImage.createFrom(bufferedImage);

Original comment by samuel.a...@gmail.com on 21 Apr 2010 at 4:41

  • Changed state: Done

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

No branches or pull requests

1 participant