0
빠른 이미지 검색 방법이 있습니까?화면에서 자바 검색 이미지
public static Point search(BufferedImage big, BufferedImage small) {
Robot robot = null;
try {
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
long time=System.currentTimeMillis();
for (int x = 0; x < big.getWidth() - small.getWidth(); x++) {
for (int y = 0; y < big.getHeight() - small.getHeight(); y++) {
if (compare(x, y, big, small)) {
return new Point(x, y);
}
}
}
System.out.println(System.currentTimeMillis()-time);
return null;
}
private static boolean compare(int xs, int ys, BufferedImage img1, BufferedImage img2) {
for (int x = 0; x < img2.getWidth(); x++) {
for (int y = 0; y < img2.getHeight(); y++) {
if (img1.getRGB(x + xs, y + ys) != img2.getRGB(x, y)) {
return false;
}
}
}
return true;
}
(즉 내가 Robot.createScreenCapture (...)로 화면을 캡처하기 전에)하지만 때로는 200 밀리하지만 때로는 10000ms를 취합니다
나는 그렇게했다! (C에서 + + 내가 생각하는 기준) 사람이 AutoHotkey를 알고 있다면, 다른 프로그래밍 언어의 몇 밀리 초 단위로 그 이미지를 발견 "ImageSearch"라는 함수가있다 ...
그리고 그 KMP를 검색에 사용하면 훨씬 빨라 집니까? 아니면 autohotkey에서 exe를 만드는 것이 더 좋을까요? – TeNNoX
아마도 그렇 겠지만 빠른 문자열 매칭 알고리즘을 구현하는 라이브러리를 검색하는 것이 훨씬 더 좋습니다. 그리고 당신이 그것을 언급 할 때까지 autohotkey에 대해 들어 본 적이 없기 때문에 나는 그것에 대해 말할 수있는 것이 아무것도 없습니다. 아마 나는 그것을 약간의 시간 시험해야한다! –
그래서 여기 하나 있습니다 ...하지만 어떻게 픽셀에 사용할 수 있습니까? http://johannburkard.de/software/stringsearch/ – TeNNoX