find a highlighted section of the screen

Asked by Abhilash Ravi

Hi,

So here's what i'm trying to do, I have a section of the screen that has been defined in a region. This region displays the activities being performed on a device's screen relayed in using some hardware. The image is like a web page and has some
text which is highlighted (solid color). Is there a way I can capture only the highlighted text .

I have tried defining a delta (distinguishing factor) between a highlighted item and a non highlighted item (highlighted item
has a grey background and non highlighted has white). I would like to find the area that is grey onscreen and grow the region
until it finds an edge(different color) on all sides and stop it there because the region would now have the highlighted item.

or maybe find a rectangular region which has white color inside and has some text.

Appreciate any help

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Abhilash Ravi (abhilash-ravee) said :
#1

Also an alternative would be if i can find a region with the background pixel color as white or gray and the text color as black

Revision history for this message
RaiMan (raimund-hocke) said :
#2

Can you put a screenshot somewhere in the net and post the link here.

If this is not possible or wanted, you might send me a screenshot to my mail at https://launchpad.net/~raimund-hocke

Since there are so many possible approaches, this is the best way to give you some hints.

Revision history for this message
Abhilash Ravi (abhilash-ravee) said :
#3

have sent you an email on this.

Revision history for this message
Abhilash Ravi (abhilash-ravee) said :
#4

.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

based on your screen shot
(https://dl.dropbox.com/u/42895525/findWhiteShot.png)
this is my solution:

(download zipped findWhite.sikuli:
https://dl.dropbox.com/u/42895525/findWhite.sikuli.zip)

# findWhite.sikuli
header = "Header-1.png"
bottom = "bottom.png"
white = "white.png"
mHeader = find(header)
mHeader.highlight(1)
area = mHeader.below()
area.find(bottom).highlight(1)
area.y += 15
area.x += 50
area.w -= 50
area.h = area.getLastMatch().y - mHeader.y - mHeader.h -10
area.highlight(2)
wLine = area.find(white)
wLine.highlight(1)
spot = wLine.y
ah = area.h/5
line = Region(area); line.h = ah
lines = range(0, area.h, area.h/5)
text = None
for off in lines:
    currLine = line.offset(Location(0,off))
    if spot < currLine.y+currLine.h:
        currLine.highlight(1)
        text = currLine.text()
        break
if text: print text
else: print "sorry, not Found"

Can you help with this problem?

Provide an answer of your own, or ask Abhilash Ravi for more information if necessary.

To post a message you must log in.