0

Is any one know how i can convert Mat to IplImage ? to achieve this i have converted Mat to BufferedImage but again not able to find conversion in BufferedImage to IplImage.

is there any way where i can convert Mat to IplImage?

Thanks

Vicky
  • 1
  • 2

1 Answers1

1

I believe you can convert BufferedImage to IplImage as follows.

public static IplImage toIplImage(BufferedImage src) {
  Java2DFrameConverter bimConverter = new Java2DFrameConverter();
  OpenCVFrameConverter.ToIplImage iplConverter = new OpenCVFrameConverter.ToIplImage();
  Frame frame = bimConverter.convert(src);
  IplImage img = iplConverter.convert(frame);
  IplImage result = img.clone();
  img.release();
  return result;
}

I got this from this question. Try this for now. I'll check if direct conversion is possible.

UPDATE: Please have a look at this api docs. I haven't tested the following. Wrote it just now. Please do try and let me know.

public static IplImage toIplImage(Mat src) {
 OpenCVFrameConverter.ToIplImage iplConverter = new OpenCVFrameConverter.ToIplImage();
 OpenCVFrameConverter.ToMat  matConverter = new OpenCVFrameConverter.ToMat();
 Frame frame =  matConverter.convert(src);
 IplImage img = iplConverter.convert(frame);
 IplImage result = img.clone();
 img.release();
 return result;
}
Community
  • 1
  • 1
Rajind Ruparathna
  • 2,215
  • 24
  • 55
  • Thanks rajind for your reply it seems work. but now am facing new issue : bytedeco IplImage to googlecode IplImage and bytedeco Mat to googlecode Mat conversion, can you please suggest how i can do that. (Actually have two independent models one is generate IplImage in bytedeco which is using updated jar and secound model accept IplImage in googlecode which is using older version jar ). Hope you understand what am trying to achieve. – Vicky Dec 31 '16 at 19:35
  • @Vicky why are you trying to go with two separate versions in the first place ? – Rajind Ruparathna Jan 01 '17 at 03:49
  • @Vicky, Since the original question is answered could you please consider accepting the answer? :-) – Rajind Ruparathna Jan 29 '18 at 01:01