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

Image(BufferedImage) --> Image(Mat) is slow #424

Open
AlexDBlack opened this issue Jun 30, 2020 · 4 comments
Open

Image(BufferedImage) --> Image(Mat) is slow #424

AlexDBlack opened this issue Jun 30, 2020 · 4 comments
Assignees

Comments

@AlexDBlack
Copy link
Contributor

For large images it's seconds per frame, and everything has a red hue when visualized via ShowImageStep

@AlexDBlack
Copy link
Contributor Author

Possibly related: #426

https://stackoverflow.com/a/3432532

AFAIK, regarding the "pinkish tint", Java saves the JPEG as ARGB (still with transparency information). Most viewers, when opening, assume the four channels must correspond to a CMYK (not ARGB) and thus the red tint.

@AlexDBlack AlexDBlack self-assigned this Jun 30, 2020
@AlexDBlack AlexDBlack changed the title Image(BufferedImage) --> Image(Mat) is slow and broken? Image(BufferedImage) --> Image(Mat) is slow Jun 30, 2020
@AlexDBlack
Copy link
Contributor Author

This PR fixes the tint issue: #427

However it's still slow (though perhaps less slow than in was with the alpha channel...)

@saudet
Copy link
Contributor

saudet commented Jul 1, 2020

Java 2D in general is slow. It should be used only for legacy support or for where performance isn't a problem.

@AlexDBlack
Copy link
Contributor Author

Yeah, it's more for interop, all image steps in KS use javacv. We're using BufferedImage as the source of some generated data in a demo. What we're doing there is not complex (combining a couple of images that have alpha channels). It could simply be easier to rewrite that part in javacv if it proves to be a bottleneck in practice than worrying about optimizing this right now.

More generally for the conversion, it should be possible (at least in some circumstances) to pass or adapt the DataBuffer from the BufferedImage Raster to javacv; currently this is using the (not exactly performant/elegant/well designed) approach of using png as an intermediate format.

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

2 participants