How to use matchImagesFeatures method of io.appium.java_client.ComparesImages class

Best io.appium code snippet using io.appium.java_client.ComparesImages.matchImagesFeatures

pureDrivers.java

Source:pureDrivers.java Github

copy

Full Screen

...1531				currentDriver.mainDriver.getClass().toString(), (Object)null );1532	}1533	1534	// ********************************************************************************************************************************************************1535	// AndroidDriver		   [105] = public default io.appium.java_client.imagecomparison.FeaturesMatchingResult io.appium.java_client.ComparesImages.matchImagesFeatures(java.io.File, java.io.File, io.appium.java_client.imagecomparison.FeaturesMatchingOptions ) throws java.io.IOException1536	public io.appium.java_client.imagecomparison.FeaturesMatchingResult matchImagesFeatures( java.io.File image1, java.io.File image2, io.appium.java_client.imagecomparison.FeaturesMatchingOptions fileOptions ) throws java.io.IOException {1537		pureDriverDetails currentDriver = getCurrentDriverDetails();1538		Class<?>[] myClasses = new Class[3];1539		myClasses[ 0 ] = java.io.File.class;1540		myClasses[ 1 ] = java.io.File.class;1541		myClasses[ 2 ] = io.appium.java_client.imagecomparison.FeaturesMatchingOptions.class;1542		Object[] myTrueParam = new Object[3];1543		myTrueParam[ 0 ] = (Object)image1;1544		myTrueParam[ 1 ] = (Object)image2;1545		myTrueParam[ 2 ] = (Object)fileOptions;1546		return (io.appium.java_client.imagecomparison.FeaturesMatchingResult)pureCore.callMethod( currentDriver.mainDriver, currentDriver.mainDriver.getClass(),1547				"matchImagesFeatures", myClasses, currentDriver.mainDriver.getClass().toString(), myTrueParam );1548	}1549	// ********************************************************************************************************************************************************1550	// AndroidDriver		   [106] = public default io.appium.java_client.imagecomparison.FeaturesMatchingResult io.appium.java_client.ComparesImages.matchImagesFeatures(java.io.File, java.io.File) throws java.io.IOException1551	public io.appium.java_client.imagecomparison.FeaturesMatchingResult matchImagesFeatures( java.io.File image1, java.io.File image2 ) throws java.io.IOException {1552		pureDriverDetails currentDriver = getCurrentDriverDetails();1553		Class<?>[] myClasses = new Class[2];1554		myClasses[ 0 ] = java.io.File.class;1555		myClasses[ 1 ] = java.io.File.class;1556		Object[] myTrueParam = new Object[2];1557		myTrueParam[ 0 ] = (Object)image1;1558		myTrueParam[ 1 ] = (Object)image2;1559		return (io.appium.java_client.imagecomparison.FeaturesMatchingResult)pureCore.callMethod( currentDriver.mainDriver, currentDriver.mainDriver.getClass(),1560				"matchImagesFeatures", myClasses, currentDriver.mainDriver.getClass().toString(), myTrueParam );1561	}1562	1563	// ********************************************************************************************************************************************************1564	// AndroidDriver		   [107] = public default io.appium.java_client.imagecomparison.FeaturesMatchingResult io.appium.java_client.ComparesImages.matchImagesFeatures(byte[], byte[], io.appium.java_client.imagecomparison.FeaturesMatchingOptions )1565	public io.appium.java_client.imagecomparison.FeaturesMatchingResult matchImagesFeatures( byte[] base64image1, byte[] base64image2, io.appium.java_client.imagecomparison.FeaturesMatchingOptions fileOptions ){1566		pureDriverDetails currentDriver = getCurrentDriverDetails();1567		Class<?>[] myClasses = new Class[3];1568		myClasses[ 0 ] = byte[].class;1569		myClasses[ 1 ] = byte[].class;1570		myClasses[ 2 ] = io.appium.java_client.imagecomparison.FeaturesMatchingOptions.class;1571		Object[] myTrueParam = new Object[3];1572		myTrueParam[ 0 ] = (Object)base64image1;1573		myTrueParam[ 1 ] = (Object)base64image2;1574		myTrueParam[ 2 ] = (Object)fileOptions;1575		return (io.appium.java_client.imagecomparison.FeaturesMatchingResult)pureCore.callMethod( currentDriver.mainDriver, currentDriver.mainDriver.getClass(),1576				"matchImagesFeatures", myClasses, currentDriver.mainDriver.getClass().toString(), myTrueParam );1577	}1578	1579	// ********************************************************************************************************************************************************1580	// AndroidDriver		   [108] = public default io.appium.java_client.imagecomparison.FeaturesMatchingResult io.appium.java_client.ComparesImages.matchImagesFeatures(byte[] ,byte[] )1581	public io.appium.java_client.imagecomparison.FeaturesMatchingResult matchImagesFeatures( byte[] base64image1, byte[] base64image2 )  {1582		pureDriverDetails currentDriver = getCurrentDriverDetails();1583		Class<?>[] myClasses = new Class[2];1584		myClasses[ 0 ] = byte[].class;1585		myClasses[ 1 ] = byte[].class;1586		Object[] myTrueParam = new Object[2];1587		myTrueParam[ 0 ] = (Object)base64image1;1588		myTrueParam[ 1 ] = (Object)base64image2;1589		return (io.appium.java_client.imagecomparison.FeaturesMatchingResult)pureCore.callMethod( currentDriver.mainDriver, currentDriver.mainDriver.getClass(),1590				"matchImagesFeatures", myClasses, currentDriver.mainDriver.getClass().toString(), myTrueParam );1591	}1592	1593	// ********************************************************************************************************************************************************1594	// AndroidDriver		   [109] = public default io.appium.java_client.imagecomparison.OccurrenceMatchingResult io.appium.java_client.ComparesImages.findImageOccurrence(java.io.File ,java.io.File ) throws java.io.IOException1595	public io.appium.java_client.imagecomparison.OccurrenceMatchingResult findImageOccurrence( java.io.File image1, java.io.File image2 ) throws java.io.IOException {1596		pureDriverDetails currentDriver = getCurrentDriverDetails();1597		Class<?>[] myClasses = new Class[2];1598		myClasses[ 0 ] = java.io.File.class;1599		myClasses[ 1 ] = java.io.File.class;1600		Object[] myTrueParam = new Object[2];1601		myTrueParam[ 0 ] = (Object)image1;1602		myTrueParam[ 1 ] = (Object)image2;1603		return (io.appium.java_client.imagecomparison.OccurrenceMatchingResult)pureCore.callMethod( currentDriver.mainDriver, currentDriver.mainDriver.getClass(),1604				"findImageOccurrence", myClasses, currentDriver.mainDriver.getClass().toString(), myTrueParam );...

Full Screen

Full Screen

ComparesImages.java

Source:ComparesImages.java Github

copy

Full Screen

...37     * @param base64image1 base64-encoded representation of the first image38     * @param base64Image2 base64-encoded representation of the second image39     * @return The matching result.40     */41    default FeaturesMatchingResult matchImagesFeatures(byte[] base64image1, byte[] base64Image2) {42        return matchImagesFeatures(base64image1, base64Image2, null);43    }44    /**45     * Performs images matching by features. Read46     * https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html47     * for more details on this topic.48     *49     * @param base64image1 base64-encoded representation of the first image50     * @param base64Image2 base64-encoded representation of the second image51     * @param options comparison options52     * @return The matching result. The configuration of fields in the result depends on comparison options.53     */54    default FeaturesMatchingResult matchImagesFeatures(byte[] base64image1, byte[] base64Image2,55                                                       @Nullable FeaturesMatchingOptions options) {56        Object response = CommandExecutionHelper.execute(this,57                compareImagesCommand(ComparisonMode.MATCH_FEATURES, base64image1, base64Image2, options));58        //noinspection unchecked59        return new FeaturesMatchingResult((Map<String, Object>) response);60    }61    /**62     * Performs images matching by features with default options. Read63     * https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html64     * for more details on this topic.65     *66     * @param image1 The location of the first image67     * @param image2 The location of the second image68     * @return The matching result.69     */70    default FeaturesMatchingResult matchImagesFeatures(File image1, File image2) throws IOException {71        return matchImagesFeatures(image1, image2, null);72    }73    /**74     * Performs images matching by features. Read75     * https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html76     * for more details on this topic.77     *78     * @param image1 The location of the first image79     * @param image2 The location of the second image80     * @param options comparison options81     * @return The matching result. The configuration of fields in the result depends on comparison options.82     */83    default FeaturesMatchingResult matchImagesFeatures(File image1, File image2,84                                                       @Nullable FeaturesMatchingOptions options) throws IOException {85        return matchImagesFeatures(Base64.encodeBase64(FileUtils.readFileToByteArray(image1)),86                Base64.encodeBase64(FileUtils.readFileToByteArray(image2)), options);87    }88    /**89     * Performs images matching by template to find possible occurrence of the partial image90     * in the full image with default options. Read91     * https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html92     * for more details on this topic.93     *94     * @param fullImage base64-encoded representation of the full image95     * @param partialImage base64-encoded representation of the partial image96     * @return The matching result.97     */98    default OccurrenceMatchingResult findImageOccurrence(byte[] fullImage, byte[] partialImage) {99        return findImageOccurrence(fullImage, partialImage, null);...

Full Screen

Full Screen

matchImagesFeatures

Using AI Code Generation

copy

Full Screen

1package appium.java;2import java.net.URL;3import java.util.concurrent.TimeUnit;4import org.openqa.selenium.By;5import org.openqa.selenium.remote.DesiredCapabilities;6import io.appium.java_client.AppiumDriver;7import io.appium.java_client.MobileElement;8import io.appium.java_client.TouchAction;9import io.appium.java_client.android.AndroidDriver;10import io.appium.java_client.android.AndroidElement;11public class MatchImagesFeatures {12	public static void main(String[] args) throws Exception {13		DesiredCapabilities cap = new DesiredCapabilities();14		cap.setCapability("deviceName", "Android Emulator");15		cap.setCapability("platformName", "Android");16		cap.setCapability("platformVersion", "9.0");17		cap.setCapability("appPackage", "com.android.settings");18		cap.setCapability("appActivity", ".Settings");19		cap.setCapability("noReset", true);

Full Screen

Full Screen

matchImagesFeatures

Using AI Code Generation

copy

Full Screen

1package appium;2import java.io.File;3import java.net.MalformedURLException;4import java.net.URL;5import java.util.concurrent.TimeUnit;6import org.openqa.selenium.By;7import org.openqa.selenium.WebElement;8import org.openqa.selenium.remote.DesiredCapabilities;9import io.appium.java_client.MobileElement;10import io.appium.java_client.android.AndroidDriver;11import io.appium.java_client.android.AndroidElement;12import io.appium.java_client.android.AndroidKeyCode;13import io.appium.java_client.android.AndroidTouchAction;14import io.appium.java_client.android.Connection;15import io.appium.java_client.android.GsmCallActions;16import io.appium.java_client.android.nativekey.AndroidKey;17import io.appium.java_client.android.nativekey.KeyEvent;18import io.appium.java_client.android.nativekey.PressesKey;19public class appium {20	public static void main(String[] args) throws MalformedURLException, InterruptedException {21		DesiredCapabilities cap = new DesiredCapabilities();22		cap.setCapability("deviceName", "Moto G5 Plus");23		cap.setCapability("udid", "ZY322Z9H2J");24		cap.setCapability("platformName", "Android");25		cap.setCapability("platformVersion", "7.0");26		cap.setCapability("appPackage", "com.android.calculator2");27		cap.setCapability("appActivity", "com.android.calculator2.Calculator");28		cap.setCapability("noReset", "true");

Full Screen

Full Screen

matchImagesFeatures

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebElement;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.testng.Assert;4import org.testng.annotations.BeforeClass;5import org.testng.annotations.Test;6import io.appium.java_client.AppiumDriver;7import io.appium.java_client.MobileBy;8import io.appium.java_client.MobileElement;9import io.appium.java_client.android.AndroidDriver;10import io.appium.java_client.android.AndroidElement;11import io.appium.java_client.android.ComparesImages;12import io.appium.java_client.android.Connection;13import io.appium.java_client.android.HasNetworkConnection;14import io.appium.java_client.android.NetworkConnectionSetting;15import java.net.MalformedURLException;16import java.net.URL;17import java.util.concurrent.TimeUnit;18public class AppiumTest {19    public static AppiumDriver<MobileElement> driver;20    public void setUp() throws MalformedURLException {21        DesiredCapabilities caps = new DesiredCapabilities();22        caps.setCapability("deviceName", "Android Emulator");23        caps.setCapability("platformName", "Android");24        caps.setCapability("appPackage", "com.android.calculator2");25        caps.setCapability("appActivity", ".Calculator");26        caps.setCapability("automationName", "UiAutomator2");

Full Screen

Full Screen

matchImagesFeatures

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.android.AndroidDriver;2import io.appium.java_client.android.AndroidElement;3import io.appium.java_client.android.nativekey.AndroidKey;4import io.appium.java_client.android.nativekey.KeyEvent;5import io.appium.java_client.remote.MobileCapabilityType;6import java.io.File;7import java.net.MalformedURLException;8import java.net.URL;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.testng.Assert;11import org.testng.annotations.AfterTest;12import org.testng.annotations.BeforeTest;13import org.testng.annotations.Test;14public class MatchImagesFeatures {15	AndroidDriver<AndroidElement> driver;16	public void setup() throws MalformedURLException {17		DesiredCapabilities caps = new DesiredCapabilities();18		caps.setCapability("deviceName", "Pixel 3 API 30");19		caps.setCapability("platformName", "Android");20		caps.setCapability("platformVersion", "11.0");21		caps.setCapability("skipUnlock", "true");22		caps.setCapability("appPackage", "com.example.android.apis");23		caps.setCapability("appActivity", "com.example.android.apis.ApiDemos");24		caps.setCapability("noReset", "true");

Full Screen

Full Screen

matchImagesFeatures

Using AI Code Generation

copy

Full Screen

1import java.io.File;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.List;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.remote.DesiredCapabilities;8import io.appium.java_client.AppiumDriver;9import io.appium.java_client.MobileElement;10import io.appium.java_client.TouchAction;11import io.appium.java_client.android.AndroidDriver;12import io.appium.java_client.android.AndroidElement;13import io.appium.java_client.android.connection.ConnectionState;14import io.appium.java_client.android.nativekey.AndroidKey;15import io.appium.java_client.android.nativekey.KeyEvent;16import io.appium.java_client.android.nativekey.PressesKey;17import io.appium.java_client.android.nativekey.KeyEventFlag;18import io.appium.java_client.android.nativekey.PressesKey;19import io.appium.java_client.imagecomparison.Feature;20import io.appium.java_client.imagecomparison.MatchResult;21import io.appium.java_client.imagecomparison.MatchSettings;22import io.appium.java_client.imagecomparison.OccurrenceMatchingOptions;23import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;24import io.appium.java_client.imagecomparison.OccurrenceMatchingSettings;25import io.appium.java_client.imagecomparison.OccurrenceType;26import io.appium.java_client.touch.offset.PointOption;27public class AppiumJavaClient {28public static AppiumDriver<MobileElement> driver;29public static void main(String[] args) throws MalformedURLException, InterruptedException {30DesiredCapabilities cap = new DesiredCapabilities();31cap.setCapability("deviceName", "Android Emulator");32cap.setCapability("platformName", "Android");33cap.setCapability("platformVersion", "7.1.1");34cap.setCapability("appPackage", "com.android.calculator2");35cap.setCapability("appActivity", "com.android.calculator2.Calculator");36cap.setCapability("automationName", "UiAutomator2");

Full Screen

Full Screen

matchImagesFeatures

Using AI Code Generation

copy

Full Screen

1driver = new AndroidDriver();2driver.matchImagesFeatures("path to image1", "path to image2", 0.9);3driver.match_images_features("path to image1", "path to image2", 0.9)4var driver = wd.promiseChainRemote("localhost", 4723);5driver.matchImagesFeatures("path to image1", "path to image2", 0.9);6driver = Appium::Driver.new(opts, true).start_driver7driver.match_images_features("path to image1", "path to image2", 0.9)8driver = new AndroidDriver();9driver.MatchImagesFeatures("path to image1", "path to image2", 0.9);10XCUIElement *element = self.wdElement;11[element matchImagesFeatures:element1 element2:element2 threshold:threshold];12XCUIElement *element = self.wdElement;13[element matchImagesFeatures:element1 element2:element2 threshold:threshold];

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful