[request] get color of one pixel very fast

Bug #810301 reported by RaiMan
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SikuliX
Fix Released
Medium
RaiMan

Bug Description

I would like a function that can return to me the RGB value of a single pixel either within a Region or relative to a Screen (I don't care which), but it must be fast. By fast, I mean that I should be able to sample roughly 500 different pixels at 30Hz. Therefore, I don't want any image processing going on during this operation.

AutoIt3 (on Windows) can (in conjunction with OLE) sample individual pixels from any scripting language incredibly fast, and I would like the same capabilities on Mac and Linux. Sikuli looks very promising, but appears to be missing this feature, so I would like to request it.

Thank you!

-- Glenn

Tags: fkt-general
Revision history for this message
RaiMan (raimund-hocke) wrote :

Have you tried the Java Robot class, which provides a getColor function?

Changed in sikuli:
importance: Undecided → Wishlist
Revision history for this message
Glenn Lewis (w-glenn) wrote :

Yes, shortly after I posted this feature request, I discovered the Java Robot class and was able to use it from Scala.
It has met all my needs perfectly.
Thanks, RaiMan!

-- Glenn

Revision history for this message
Brian Parma (bj0) wrote :

Unfortunately, using it at the python level is pretty slow :(

It would be nice if there was a way to "push" it to a lower level to speed it up.

RaiMan (raimund-hocke)
Changed in sikuli:
assignee: nobody → RaiMan (raimund-hocke)
RaiMan (raimund-hocke)
Changed in sikuli:
status: New → In Progress
RaiMan (raimund-hocke)
tags: added: fkt-general
RaiMan (raimund-hocke)
Changed in sikuli:
importance: Wishlist → Medium
milestone: none → x1.1
Revision history for this message
obiwan-92 (obiwan-92) wrote :

-- @Brian Parma (bj0)
Hello.
Actually, Python is faster tha Java. But you use the java.robot and work in jython doesn't change anything about this.
To accelerate your program, you can use the class BufferedImage of Java. The color of a pixel is faster when you obtain from your buffer.

-- @RailMan
In Jython :

from java.awt import Robot
from java.awt import Color
from java.awt import Rectangle

def getListColor(SCREEN, r, g, b):
    i = Robot().createScreenCapture(Rectangle(SCREEN.getX(),
                SCREEN.getY(), SCREEN.getW(), SCREEN.getH()))
    c = Color(r, g, b)
    l = []
    for x in range(0, SCREEN.getW()):
        for y in range(0, SCREEN.getH()):
            if c == Color(i.getRGB(x, y)):
                l.append(Location(x, y))
    return l
# For the list of black Pixel
l = getListColor(SCREEN, 0, 0, 0)

-- @EveryOne
Hope it's help.
Regards.

Revision history for this message
Glenn Lewis (w-glenn) wrote :

Thanks!

RaiMan (raimund-hocke)
Changed in sikuli:
milestone: 1.1.0 → 1.2.0
RaiMan (raimund-hocke)
Changed in sikuli:
status: In Progress → Fix Released
milestone: 2.0.0 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.