@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");
}
}
}
}
}
Camera.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:Face-detection-and-recognition-desktop-application
作者:
评论列表
文章目录