-3
因此,我想快速分析屏幕上每個像素的顏色。爲此,我在使用Robot.getPixelColor(i, j)
的雙嵌套循環中,其中i
是我的屏幕寬度,j
是我的屏幕高度。這當然需要很長時間,因爲我有1080屏幕。關於如何加快這個過程的任何建議?現在大約需要一個小時,我需要大約5秒。或者這是不可能的?提前致謝!!快速分析大型陣列
因此,我想快速分析屏幕上每個像素的顏色。爲此,我在使用Robot.getPixelColor(i, j)
的雙嵌套循環中,其中i
是我的屏幕寬度,j
是我的屏幕高度。這當然需要很長時間,因爲我有1080屏幕。關於如何加快這個過程的任何建議?現在大約需要一個小時,我需要大約5秒。或者這是不可能的?提前致謝!!快速分析大型陣列
機器人有利於獲得大畫面,也許單個像素
爲去OVEL你得到的圖像的所有像素 - 我獲得約50倍的加速比。
long tm=System.currentTimeMillis();
int i;
Toolkit it=Toolkit.getDefaultToolkit();
Dimension d=it.getScreenSize();
int w=(int)d.getWidth(), h=(int)d.getHeight();
Rectangle rect=new Rectangle(0, 0, w, h);
Robot r=null;
try {
r=new Robot();
}
catch(AWTException awte){ };
BufferedImage ib=r.createScreenCapture(rect);
int[] pix=ib.getRGB(0, 0, w, h, null, 0, w);
for(i=0; i<pix.length; i++) pix[i]=pix[i]&0x00ffffff;
System.out.println("t1 "+(System.currentTimeMillis()-tm));
tm=System.currentTimeMillis();
for(i=0; i<pix.length; i++) r.getPixelColor(i%w, i/w);
System.out.println("t2 "+(System.currentTimeMillis()-tm));
如何分析它?請輸入密碼? –
您的*像素分析*是否依賴於任何其他像素? –
這取決於你想要做什麼樣的分析。您可以截取屏幕截圖,縮小其大小並在這個較小的圖像上進行分析。 – Titus