← Back to team overview

sikuli-driver team mailing list archive

[Question #404041]: Compare two colors

 

New question #404041 on Sikuli:
https://answers.launchpad.net/sikuli/+question/404041

Hi, I want to search an image, then pick a pixel on that image then compare it to a color I've choosen (191,255,42 or #BFFF2A), here's my code :


import java.awt.Color as Color

image = Pattern("image.png").targetOffset(34,-4)
x=0
y=0

# VERT r=191 g=255 b=42

Color_vert=Color(0xbfff2a)

setFindFailedResponse(SKIP)
if find(image):
    setFindFailedResponse(ABORT)
    x = find(image).getX()+81
    y = find(image).getY()+10
    if Location(x,y).getColor()==Color_vert:
        print ("OK")
    else:
        print ("PAS OK")

    print Location(x,y).getColor().toString()
    print Color_vert



I get :

PAS OK
java.awt.Color[r=191,g=225,b=42]
java.awt.Color[r=191,g=255,b=42]

It should be "OK", the two resuslts seems equals... no ?

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.