Comments (9)
Thanks.
Will check and fix asap.
from sikulix1.
Ok, looked into the code and could not find any (obvious ;-) problem.
Using the converters (forth and backwards)
What converters?
Could you please give me a code sample?
from sikulix1.
See attached method. simply using getSubImage wont return success even if image "img" clearly is contained in Component's screenie
Workaround is creating a new BufferedImage with smaller size and drawing the screenie onto it...
protected boolean isImageInComponent(Component c, Rectangle region, BufferedImage img, double wantedScore) {
BufferedImage screenshot = shooter.takeScreenshotOf(c);
BufferedImage regionImg = new BufferedImage(region.width, region.height, BufferedImage.TYPE_INT_RGB);
Graphics2D imageGraphics = regionImg.createGraphics();
imageGraphics.drawImage(screenshot, -region.x, -region.y, null);
//getSubimage(region.x, region.y, region.width, region.height); causes Mats conversion and comparison to fail
int match_method = Imgproc.TM_SQDIFF;
Mat scrMat = bufferedImageToMat(regionImg);
Mat tokMat = bufferedImageToMat(img);
BufferedImage bscreen = Finder2.getBufferedImage(scrMat);
BufferedImage btoken = Finder2.getBufferedImage(tokMat);
// / Create the result matrix
int result_cols = scrMat.cols() - tokMat.cols() + 1;
int result_rows = scrMat.rows() - tokMat.rows() + 1;
Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
// / Do the Matching and Normalize
Imgproc.matchTemplate(scrMat, tokMat, result, match_method);
//Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());
// / Localizing the best match with minMaxLoc
Core.MinMaxLocResult mmr = Core.minMaxLoc(result);
Point matchLoc = mmr.minLoc;
return (mmr.minVal < 10);
}
from sikulix1.
Mat scrMat = bufferedImageToMat(regionImg);
Cannot find this method in the 1.1.4 SikuliX.
//getSubimage(region.x, region.y, region.width, region.height);
If this is a method from SikuliX, then the containing class must be a subclass of SikuliX Image.
If not, then where is it?
IMHO: Generally in the SikuliX code, BufferedImages are only read (even subimages). If a writable version is needed, then a new Buffered image is returned, which is created the way you said above.
So what has this to do with SikuliX?
from sikulix1.
ok, made some quick tests:
BufferedImage.getSubimage() objects apparently are not converted correctly to OpenCV Mat by the conversion method in Finder2. Might be a problem with the fact, that such a subimage is only a "pointer" to the same imagebuffer as the original.
I will check and fix it somehow.
Additionally it makes sense to generally allow the usage of BufferedImage objects all over the place for usages in Java.
from sikulix1.
Excellent! Thanx a ton. I have a list of a few other issues, that might be worth discussing. Would you mind / have time for a chat or phone call? Topics are more complicated so doing it via voice would be more efficient me thinks ;)
br
Thomas
from sikulix1.
Would you mind / have time for a chat or phone call?
Principally yes.
So let us first talk on that offline via mail: sikulix---at---outlook---dot--com
from sikulix1.
I decided to make a new branch as version 1.1.5.
From the ReadMe:
Main intention is, to make the the base for image/text searching and OCR more general:
Image should be an extension of a Region with the same features (except that it is not bound to a screen, but to some image content and you cannot click or type on it)
This in the end will make class Finder obsolete and allow to fully integrate BufferedImage as source (or other image sources).
So if you have any ideas for SikuliX:
- the master branch 1.1.4 is the place for minor revisions/fixes
- 1.1.5 is for really new features and major revisions (like the new Image implementation)
from sikulix1.
If still interested, get familiar with the new release situation and feel free to come back with issues.
from sikulix1.
Related Issues (20)
- IDE: NameError after editing script
- IDE: Add utf-8 spec when running a selection of lines
- IDE: A region changed by clicking on region image is still the old one at next run - workaround
- App class: Windows: identify app by process name
- TERMINATING: problem with native library: libopencv_java430.dylib HOT 2
- UI Scaling for HDPI Screens does not work
- isValidImageFilename throws java.lang.IllegalArgumentException
- Issue when trying to connect a tiger vnc server HOT 1
- sikulixIDE 2.0.x ImportError HOT 1
- VS Code extension for SikuliX scripts HOT 1
- Is there a way to generate long clicks (10 seconds +) on actionable elements? HOT 2
- Screen.click(pattern) returns FindFailed error right after screen.has(pattern) returned true. HOT 2
- Latest sikulix1api library contains dependencies with reported security vulmeralibilies
- OCR(region.text()) is detecting wrong text, when text is underlined HOT 6
- Write access to repository's wiki HOT 1
- Wiki cannot be checked out in windows HOT 2
- Exception in thread "Thread-22" java.lang.ExceptionInInitializerError HOT 9
- How to connect database influxdb HOT 1
- Problem with transparency
- Easy way to ignore the background for image search? --- use images with transparent background HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sikulix1.