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

IplImage to PIX converter #224

Closed
gorcer opened this issue May 18, 2016 · 6 comments
Closed

IplImage to PIX converter #224

gorcer opened this issue May 18, 2016 · 6 comments

Comments

@gorcer
Copy link

gorcer commented May 18, 2016

For tesseract ocr i need use PIX format.
But i have IplImage as source.

How can i convert IplImage to PIX?

@saudet
Copy link
Member

saudet commented May 19, 2016

Would be nice to have! Shouldn't be hard to do. I'd see it as a LeptonicaFrameConverter or something like that, so we can convert not just to IplImage, but to and from all the other formats as well. Would you like to try? You could use OpenCVFrameConverter as a template.

@gorcer
Copy link
Author

gorcer commented May 19, 2016

I have some solution:

IplImage prepareImg = ...
cvSaveImage("plate.jpg", prepareImg);               
PIX pixImage = pixRead("/plate.jpg");

:)

And i will think above the LeptonicaFrameConverter.

@saudet
Copy link
Member

saudet commented May 21, 2018

I've finally implemented LeptonicaFrameConverter so we can now do something like this to convert efficiently an IplImage into a PIX for Tesseract:

    OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage();
    LeptonicaFrameConverter converter2 = new LeptonicaFrameConverter();

    PIX pix = converter2.convert(converter.convert(img));

Please give it a try with the snapshots (http://bytedeco.org/builds/) and let me know if you encounter any issues with it! Thanks

@Olka95
Copy link

Olka95 commented Aug 3, 2018

Hello! Can you please help me?

When I tried to use new converter, I got an error:

Exception in thread "main" java.lang.NoSuchMethodError: org.bytedeco.javacpp.lept$PIX.createHeader(III)Lorg/bytedeco/javacpp/lept$PIX;
at org.bytedeco.javacv.LeptonicaFrameConverter.convert(LeptonicaFrameConverter.java:59)

Also, when I tried to create class by myself by copying https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/LeptonicaFrameConverter.java
compiler can not resolve "PIX.createHeader" and "pix.createBuffer()".

Used dependency is:

org.bytedeco
javacv-platform
1.4.2

@saudet
Copy link
Member

saudet commented Aug 3, 2018

LeptonicaFrameConverter is now included in JavaCV 1.4.2, enjoy!

@Olka95 If you put all the JAR files in your class path, it will work, but let me know if that stills doesn't work for some reason.

@saudet saudet closed this as completed Aug 3, 2018
@Olka95
Copy link

Olka95 commented Aug 4, 2018

Thank you very much!

I found out, what the problem was. I didn't use late version of the leptonica library.
With next dependency it works well:

<dependency> <groupId>org.bytedeco.javacpp-presets</groupId> <artifactId>leptonica-platform</artifactId> <version>1.76.0-1.4.2</version> </dependency>

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

3 participants