sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #48516
Re: [Question #673704]: How to get program to capture part of the App.focusedWindow()?
Question #673704 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/673704
Status: Answered => Open
Winnie Hsu is still having a problem:
The output makes me confused. Why screenshot Masked matches score
max/min below 0.8, the image is same as shotMasked. But shotMasked's
score is so higher.
The Output is :
##### searching for: (1536898174.png) original image
found: 1 matches score max/min: 0.7643 / 0.7643
##### searching for: (P(test20180914-1.png) S: 0.7 masked) masked with
other image (image-masked)
found: 1 matches score max/min: 0.9995 / 0.9995
##### searching for:
(P(D:/Sikuli1.1.3/Reports/Screenshot/test20180914.png) S: 0.7 masked)
masked with screen image (image-masked)
found: 1 matches score max/min: 0.7790 / 0.7790
-----------------------------------------------------------------------------------
My Code is as Follows:
some_region = App.focusedWindow()
imgabc = capture(some_region)
screenshotsDir = "D:\Sikuli1.1.3\Reports\Screenshot"
shutil.move(imgabc, os.path.join(screenshotsDir, "test"+ time.strftime('%Y%m%d') +".png"))
wait(1)
#baseimg = os.path.join(screenshotsDir, "test"+ time.strftime('%Y%m%d') +".png")
baseimg = os.path.join(screenshotsDir, "test20180914.png")
wait(1)
shot = "1536898174.png"
shotA = "test20180914-1.png"
# image with black/white parts useable as mask
shotMask = "bbb-1.png"
wait(5)
# Image masked with black/white image shotMask (image-masked)
shotMasked = Pattern("test20180914-1.png").mask(shotMask)
shotMaskedscreen = Pattern(baseimg).mask(shotMask)
# find the search area
# the image shot-tile-small.png must be visible on screen
reg = None
for match in findAllList(shot):
if reg: reg = reg.union(match)
else: reg = match
if reg:
reg = reg.grow(0)
reg.highlight(2, "green")
else:
print "search area not visible"
exit(-1)
# a generalized function for this demonstration
def search(image, descr = ""):
print "##### searching for: (%s) %s" % (image, descr)
matches = reg.findAllList(image)
if len(matches) > 0:
scoreMax = 0
scoreMin = 1
for match in matches:
match.highlight()
score = match.getScore()
if score > scoreMax:
scoreMax = score
if score < scoreMin:
scoreMin = score
print "found: %d matches score max/min: %.4f / %.4f" % (len(matches), scoreMax, scoreMin)
else:
print " found: no matches"
wait(2)
highlightOff()
# showcase original image
search(shot, "original image")
# showcase image-masked
search(shotMasked, "masked with other image (image-masked)")
search(shotMaskedscreen, "masked with screen image (image-masked)")
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.