Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to subtract two different .Rect values from image find?
#1
Im scanning for two different images and i want to subtract their positions but it seems the .Rect outputs cant be substracted from another.
Is there a way to convert rect values? I only need the first x and y values, the upper left position of the images. Maybe .Rect is the wrong way.
#2
Code:
Copy      Help
var w = wnd.find(1, "Document - WordPad", "WordPadClass");
IFImage[] image = {
    @"image:iVBORw0KGgoAAAANSUhEUgAAABcAAAASCAYAAACw50UTAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE5SURBVDhP7ZPNSoRQGIbrDroCN11By66lfd1Bi+6ghT8ImiKCKAriz7IZpph2E4zTsl2brqA2KYr5xffBDJ5zRprJ2nXgQQ76Phze73jwUVbwV/zLtyLIi2IFeZ5vSNMU4jiGMAzB931wXRds2wbTNGE2u2OyPIIchbsuVVWZLM+g/FaSfkTfNerksiwzWR5BvlwWgx3ruk5VoBSZTKZMlkeQj+Hk5pPZ/6r8+PqN2Qvy/lXMsgySJKGaoiiCIAjA8zyqynEcmM8fKHN0+QL3z+/07LtGDdQwDMocXjwRV/kr4xqUS6dng1RVRd/ggElyvtrQdwlyrKK/uq6Dtm2haRqo65rEZVnSO03TmCyPIMeOcW078Zq1XFEUJssjyHF4u669f6LF4lG4FZZl0fCwY6wCT/z9T1TBF/suxcMGYCvTAAAAAElFTkSuQmCC",
    @"image:iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEwSURBVDhPY/j67ft/amLaGjht6e7/Ulmr4RhZDh3jUoti4PRle/6DwLdf/wkaiEstioEzlu/9L2cZDcaEDASpBYFPPwgY+Pfv//9vvxJ2IS7LUQycuWLf/19//hPlQpjal5/xuHDWyv3gMHnyHtOFk479ROHjUoti4OxVB3CGoXzr6/+dez+gqAWF3/23BAwEhd+tVwhFHpPv/pevuvafPfcyGNdufIKiFm8Yzll98P+LT9jDkCHtzP+qdQ8x1F59gceFc9cc+v/kw///559ihiGyYSCMSy2KgfPWHsYZhugYpPYeMPxOPyRg4E1g+B2/j+lCdIzLchQD56878v8KMEyIcSFM7aG7eFy4YP3R/+ef/P+//zZhF+JSi2EgCIO8A8LIcugYl1oUAynH3/8DABFn8ej01U9GAAAAAElFTkSuQmCC",
};

var a = new List<uiimage>();
uiimage.find(1, w, image, IFFlags.WindowDC, also: o => { a.Add(o); return IFAlso.OkFindMoreOfList; });
if (a.Count == 2) {
    int dx = a[1].Rect.left - a[0].Rect.left, dy = a[1].Rect.top - a[0].Rect.top;
    print.it(dx, dy);
}
#3
Now i understand. I will try that soon. Thank you very much! Smile
#4
I tried it, but it couldnt find the image. The next thing i tried was to add diff: but no matter what value i give it, no images are found.
Can you please help me Gintaras?

Maybe it finds images but more than two? This could be possible.
Can i choose to pick the closest one and ignore other images?
 
Code:
Copy      Help
[code]var w = wnd.find(1, "Document - WordPad", "WordPadClass");
IFImage[] image = {
@"C:\Users\User\Documents\IMG\pos1.bmp",
@"C:\Users\User\Documents\IMG\pos2.bmp",
};

var a = new List<uiimage>();
uiimage.find(w, image, IFFlags.WindowDC, diff: 70, also: o => { a.Add(o); return IFAlso.OkFindMoreOfList; });
if (a.Count == 2) {
    int dx = a[1].Rect.left - a[0].Rect.left, dy = a[1].Rect.top - a[0].Rect.top;
    print.it("1 Pos difference: ", dx, dy);
    wait.s(1);
}
else {
    print.it("Pos not found");
    wait.s(1);
}

[/code]
#5
This code can find 0, 1 or 2 images, not more. Insert print.it(a.Count).

The original question was about subtracting two .Rect from image.find results, but you did not provide code that shows how you get that 2 results. Maybe my code is not what you need.


Forum Jump:


Users browsing this thread: 1 Guest(s)