5

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 ?

Guillaume Jacquenot
  • 11,217
  • 6
  • 43
  • 49
Gorcer
  • 188
  • 2
  • 9

2 Answers2

3

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;
}
Community
  • 1
  • 1
Rajind Ruparathna
  • 2,215
  • 24
  • 55
1
IplImage prepareImg = ...
cvSaveImage("test.jpg", prepareImg);               
PIX pixImage = pixRead("/test.jpg");

--- Source : Same Github issues As mentioned by a comment by rajind ruparathna

c0degeas
  • 762
  • 9
  • 19