1. ## Recognizing gold

I ran into a problem where I was trying to recognize gold on the ground so I wouldnt miss any and I couldnt figure out a solution that didnt get false positives.

Well I figured out a solution and am posting it incase someone else was having the same problem. It probably needs to be modified for different screen setups but the method will still work.

I took a screen shot of the gold label and noted points on the image that would not change due to the background or anything else.

I got the color for each point and made a function that checked each point relative to an x,y (and just loop for all the pixels on the screen) and if it matches then its a gold label.

I havent gotten any false positives from it and it's pretty quick. Please excuse the not so sexy C, but whatevs.

Code:
```int IsGold(int x,int y){
if (GetPixel(ndc,x+4,y)!=16777215) return 0;
if (GetPixel(ndc,x+5,y)!=16777215) return 0;
if (GetPixel(ndc,x+18,y)!=16777215) return 0;
if (GetPixel(ndc,x+1,y+3)!=16777215) return 0;
if (GetPixel(ndc,x+13,y+3)!=16777215) return 0;
if (GetPixel(ndc,x+18,y+3)!=16777215) return 0;
if (GetPixel(ndc,x+23,y+3)!=16777215) return 0;
return 1;
}```
This solution could be used for recognizing other shits with labels as well.

2. Brilliant idea, that's much better than trying to match a whole image. It has the potential to be much more efficient than comparing every single pixel in a rectangular area.

It could be generalized, too. What if you made a generic function that you passed a pointer to a two dimensional array of coordinate pairs? Each pair would have an x modifier, y modifier, and color to match against. Your function could then iterate over each pixel in the target area and iterate through the array, checking each pixel. This is essentially what an image search does, except it checks every pixel in the target area against every pixel in the search image, which ends up being something like O(n^3) time.

I'm probably not very clear, so if you happen to know the function that returns a screen area as an array of pixels, I could write an example.

Anyway, great work, its very inspiring. +rep!

3. Originally Posted by KcDan
I ran into a problem where I was trying to recognize gold on the ground so I wouldnt miss any and I couldnt figure out a solution that didnt get false positives.

Well I figured out a solution and am posting it incase someone else was having the same problem. It probably needs to be modified for different screen setups but the method will still work.

I took a screen shot of the gold label and noted points on the image that would not change due to the background or anything else.

I got the color for each point and made a function that checked each point relative to an x,y (and just loop for all the pixels on the screen) and if it matches then its a gold label.

I havent gotten any false positives from it and it's pretty quick. Please excuse the not so sexy C, but whatevs.

Code:
```int IsGold(int x,int y){
if (GetPixel(ndc,x+4,y)!=16777215) return 0;
if (GetPixel(ndc,x+5,y)!=16777215) return 0;
if (GetPixel(ndc,x+18,y)!=16777215) return 0;
if (GetPixel(ndc,x+1,y+3)!=16777215) return 0;
if (GetPixel(ndc,x+13,y+3)!=16777215) return 0;
if (GetPixel(ndc,x+18,y+3)!=16777215) return 0;
if (GetPixel(ndc,x+23,y+3)!=16777215) return 0;
return 1;
}```
This solution could be used for recognizing other shits with labels as well.
How to code that for autoit?

All times are GMT -5. The time now is 04:59 PM. Powered by vBulletin® Version 4.2.3