Camera.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:Face-detection-and-recognition-desktop-application 作者:
@Override
public void run() {
    synchronized (this) {
        while (runnable) {
            if (webSource.grab()) {
                try {
                    webSource.retrieve(fm);
                    Graphics g = jPanel1.getGraphics();
                    faceDetector.detectMultiScale(fm, faceDetections);
                    for (Rect rect : faceDetections.toArray()) {
                        Imgproc.rectangle(fm, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
                    }
                    Highgui.imencode(".bmp", fm, mem);
                    Image im = ImageIO.read(new ByteArrayInputStream(mem.toArray()));
                    BufferedImage buff = (BufferedImage) im;
                    if (g.drawImage(buff, 0, 0, getWidth(), getHeight(), 0, 0, buff.getWidth(), buff.getHeight(), null)) {
                        if (runnable == false) {
                            System.out.println("Paused ..... ");
                            this.wait();
                        }
                    }
                } catch (Exception ex) {
                    System.out.println("Error");
                }
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号