First off the code:
for (int i = 0; i < 25; i++)
{
robot.delay(1000);// wait 1 second
Color pixel_4 = robot.getPixelColor(x-15, 30);
System.out.println(pixel_4.getRed() + " " + pixel_4.getGreen() + " " + pixel_4.getBlue());
}
That is not the exact code I am using, but it produces the same situation:
If I run this loop in a program and the screen is precisely the same for the entire loop it will occasionally output something like:
255 255 255
... (same color)
...
...
...
...
...
...
...
124 142 012
255 255 255
As far as I can tell, the screen is static, but the robot.getPixelColor(x,y) method returned a false set of values.
Does anyone have any experience or intuition about this? Is there anything I can do to prevent it from happening?
Thanks
解决方案
For obvious reasons; there is something wrong with your logic. Here is one thought:
Suppose you have a screen with width 200px, lets suppose your algorithm checks the color of a pixel that is outside of the bounds of the screen (i.e. 201, 0). What does robot.getPixelColor return? It would either return a color outside of the bounds of the image or return some kind of invalid result.
Having siad that, ensure that your algorithm checks valid pixels within the constraints of your image; this may be the cause of the obscurity of your results.
Hope this helps or leads to an appropriate solution