I develop OCR system based on JavaCV.
I use following libraries for my project:
In one case I need to find some part of an image and recognize letters on it.
I store a part of an image in IplImage type.
But for Tesseract I must use PIX format.
How can I convert IplImage to Pix ?
Posting the hack like solution found by the author of the question. It can also be found here.
IplImage prepareImg = ...
cvSaveImage("plate.jpg", prepareImg);
PIX pixImage = pixRead("/plate.jpg");
And from this question, you can convert IplImage to BufferedImage as follows.
public static BufferedImage toBufferedImage(IplImage src) {
OpenCVFrameConverter.ToIplImage iplConverter = new OpenCVFrameConverter.ToIplImage();
Java2DFrameConverter bimConverter = new Java2DFrameConverter();
Frame frame = iplConverter.convert(src);
BufferedImage img = bimConverter. convert(frame);
BufferedImage result = (BufferedImage)img.getScaledInstance(
img.getWidth(), img.getHeight(), java.awt.Image.SCALE_DEFAULT);
img.flush();
return result;
}
IplImage prepareImg = ...
cvSaveImage("test.jpg", prepareImg);
PIX pixImage = pixRead("/test.jpg");
--- Source : Same Github issues As mentioned by a comment by rajind ruparathna
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With