1

I am a java programmer,I am trying to use the screen which are open and take a screen shot and compare it with an other picture and see how many of that object is on my screen. I tried to look for examples in java, but they were all in c++ and i couldn't convert them. I know my problem is in the first line, since CascadeClassifier wants a .xml file not a .png. Can someone help me with this, all I want is a program in java that do the same as this example but using the screen shot, or using screen-capture.

CascadeClassifier balDec = new CascadeClassifier("img/ball.png");
BufferedImage screenShot = r.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

try {
    ImageIO.write(screenShot, "png", new File("screenShot"+i+".png"));
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Mat screen =Highgui.imread("screenShot0.png");
MatOfRect  balls = new MatOfRect();
balDec.detectMultiScale(screen, balls);
4

0 回答 0