mirror of
https://github.com/appium/appium.git
synced 2026-05-03 00:41:07 -05:00
5070a34739
* docs: update universal-xml-plugin readme * chore: fix line lengths * docs: update relaxed-caps-plugin readme * docs: update images-plugin readme * docs: update fake-plugin readme * docs: add readme for execute-driver-plugin * docs: update base-plugin readme * docs: update test-support readme * docs: update support readme * docs: update opencv readme * docs: update fake-driver readme * docs: update docutils readme * docs: update doctor readme * docs: update base-driver readme * docs: fix badge for base-driver * docs: slightly improve base-driver/plugin readme * docs: fix title for eslint-config-appium-ts * docs: add badges for non-prerelease packages * docs: update appium readme * docs: update some readme links * chore: address review comments
1.9 KiB
1.9 KiB
@appium/opencv
OpenCV-related helper methods
Installation
npm install @appium/opencv
Usage
initOpenCv
Loads the opencv bindings. You only need to explicitly call this if you want to use your own opencv methods that are not included in this module.
import {initOpenCv} from '@appium/opencv';
await initOpenCv();
getImagesMatches
Calculates the count of common edges between two images. The images might be rotated or resized relatively to each other. See the function definition for more details.
import {getImagesMatches} from '@appium/opencv';
import {fs} from '@appium/support';
const image1 = await fs.readFile('image1.jpg')
const image2 = await fs.readFile('image2.jpg')
const {points1, rect1, points2, rect2, totalCount, count} = await getImagesMatches(image1, image2);
getImagesSimilarity
Calculates the similarity score between two images. It is expected that both images have the same resolution. See the function definition for more details.
import {getImagesSimilarity} from '@appium/opencv';
import {fs} from '@appium/support';
const image1 = await fs.readFile('image1.jpg')
const image2 = await fs.readFile('image2.jpg')
const {score} = await getImagesSimilarity(image1, image2);
getImageOccurrence
Calculates the occurrence position of a partial image in the full image. See the function definition for more details.
import {getImageOccurrence} from '@appium/opencv';
import {fs} from '@appium/support';
const fullImage = await fs.readFile('image1.jpg')
const partialImage = await fs.readFile('image2.jpg')
const {rect, score} = await getImageOccurrence(fullImage, partialImage);
License
Apache-2.0