← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #242405]: Get the BufferedImage reference when calling Region.findAll()

 

Question #242405 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/242405

Description changed to:
Hi Ray !

First of all, let me say you that Sikuli is a beautiful work and a very
usable library. I played with some years ago and enjoyed it. Now I
decided to base a bot project on it and my choice was obvious... ;)

I have one question :

I have to extract all matches founds in a specified regions and then
work again to extract larger images from the specified matches
coordinates on the screen.

The problem is that my screen is very dynamic and that's why for performance I'm looking for the minimum pattern size.
But when I call Region.findAll(), I get match regions relatives to the full screen.
I didn't found a way to get the source bufferedImage. I have to be sure to work on the same image used to search because after that I extract my datas from the matches. Here is my piece of code :

		try {
			image = Screen.getPrimaryScreen().capture().getImage();
			matchs = searchArea.findAll(lookingFor);
		} catch (FindFailed e) {
			return;
		}

		while (matchs.hasNext() && (cards.size() < 52)) {
			Match m = matchs.next();
			BufferedImage card = image.getSubimage(m.getX(), m.getY(),
					extractW, extractH);

			CardsElector elector = new CardsElector(card);
			elector.start();
		}

I extract subImages from the screen BufferedImage, relative to the "matching" Regions. But in my case, if there is a screen change between the screenCature and the findAll, I exctract bad datas.
So I would like to get the same BufferedImage the Finder worked on when I called the findAll() method.

Could you tell me please how to do that ?
Maybe it could be usefull for peoples like me to add the capacity work directly on BufferedImages and apply finAll(Pattern), find(Pattern) contains(Pattern). Like that, we could get the LastScreenImage and work directly on it. Because when we actually call the findAll method, we don't know on which image reference it's done.

Thanks for your help and your work !

Best regards,
David


PS : I'm waiting for the SikuliX 2014 because I got some troubles with observers. So I did my own RegionObserver that uses the find() method to detect changes and invoke onFind(), onNotFind(), onAppear(), onVanish() home made FindObserverEvent implementations.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.