将IplImage转换为BufferedImage进行集成 [英] Converting IplImage to BufferedImage to integrate

查看:389
本文介绍了将IplImage转换为BufferedImage进行集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作我自己的完全在BufferedImage中运行的图像处理应用程序。
现在我在[OpenShift.com]的博客中偶然发现了面部检测的代码
现在我想将该代码集成到我自己的GUI应用程序中。但面对问题,因为面部检测器对图像进行编码是iplImage对象的一个​​实例,为此我需要先将缓冲的图像转换为IplImage,以便该方法接受现在转换的图像。
请帮助..
i我将离开面部检测器代码。

I'm making my own Image processing application that completely operates in BufferedImage. Now i have stumbled upon a code on Face detection in a blog of [OpenShift.com] Now i want to integrate that code into my own GUI application.But facing problems as the Face Detector code the image is an instance of iplImage object and for that i need to first convert the buffered image to IplImage so that the method accepts the now converted image. Please help.. i am leaving below the Face detector code.

public class FaceDetection{

    //Load haar classifier XML file
    public static final String XML_FILE = 
            "C:\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt2.xml";

    public static void main(String[] args){

        //Load image
        IplImage img = cvLoadImage("C:\\Users\\The Blue Light\\Desktop\\13.jpg");       
        detect(img);        
    }   

    //Detect for face using classifier XML file 
    public static void detect(IplImage src){

        //Define classifier 
        CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(XML_FILE));

        CvMemStorage storage = CvMemStorage.create();

        //Detect objects
        CvSeq sign = cvHaarDetectObjects(
                src,
                cascade,
                storage,
                1.5,
                3,
                CV_HAAR_DO_CANNY_PRUNING);

        cvClearMemStorage(storage);


        int total_Faces = sign.total();     

        //Draw rectangles around detected objects
        for(int i = 0; i < total_Faces; i++){
            CvRect r = new CvRect(cvGetSeqElem(sign, i));
            cvRectangle (
                    src,
                    cvPoint(r.x(), r.y()),
                    cvPoint(r.width() + r.x(), r.height() + r.y()),
                    CvScalar.CYAN,
                    2,
                    CV_AA,
                    0);

        }

        //Display result
        cvShowImage("Result", src);
        cvWaitKey(0);

    }           
}


推荐答案

IplImage image = IplImage.createFrom(yourBufferedImage);

IplImage image = IplImage.createFrom(yourBufferedImage);

谢谢@ Marco13
正是我需要的......

Thanks @Marco13 exactly what i needed..

这篇关于将IplImage转换为BufferedImage进行集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆