For tesseract ocr i need use PIX format.
But i have IplImage as source.
How can i convert IplImage to PIX?
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.
I have some solution:
IplImage prepareImg = ...
cvSaveImage("plate.jpg", prepareImg);
PIX pixImage = pixRead("/plate.jpg");
:)
And i will think above the LeptonicaFrameConverter.
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
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:
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.
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>