ON IOS :-Open cv issue when run compare image

when run this method to compare image

method
byte [] screenshot2 = Base64. encodeBase64 ( calendar_Screen .eventlabel.getScreenshotAs(OutputType. BYTES ));

FeaturesMatchingResult result = driver

.matchImagesFeatures(screenshot, screenshot2, new FeaturesMatchingOptions()

.withDetectorName(FeatureDetector. ORB )

.withGoodMatchesFactor(40)

.withMatchFunc(MatchingFunction. BRUTE_FORCE_HAMMING )

.withEnabledVisualization());

Assert. assertEquals (result.getVisualization().length>0, true );

Assert. assertEquals (result.getCount()>0, true );

Assert. assertEquals (result.getTotalCount()>0, true );

assertFalse (result.getPoints1().isEmpty());

assertNotNull (result.getRect1());

assertFalse (result.getPoints2().isEmpty());

assertNotNull (result.getRect2());

log .info("the result is "+result);

i got this issue in log

Executing command ‘compareImages’

[debug] [Support] Initializing opencv

[debug] [Support] Loading local package ‘opencv4nodejs’

[debug] [Support] Failed to load local package ‘opencv4nodejs’: Cannot find module ‘/opt/homebrew/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs’

[debug] [Support] Require stack:

[debug] [Support] - /opt/homebrew/lib/node_modules/opencv4nodejs/lib/cv.js

[debug] [Support] - /opt/homebrew/lib/node_modules/opencv4nodejs/lib/opencv4nodejs.js

[debug] [Support] - /opt/homebrew/lib/node_modules/appium/node_modules/appium-support/build/lib/node.js

[debug] [Support] - /opt/homebrew/lib/node_modules/appium/node_modules/appium-support/build/lib/image-util.js

[debug] [Support] - /opt/homebrew/lib/node_modules/appium/node_modules/appium-support/build/index.js

[debug] [Support] - /opt/homebrew/lib/node_modules/appium/build/lib/logsink.js

[debug] [Support] - /opt/homebrew/lib/node_modules/appium/build/lib/main.js

[debug] [Support] Failed to load global package ‘opencv4nodejs’: The “path” argument must be of type string. Received undefined

[debug] [Support] Linking package ‘opencv4nodejs’

[debug] [Support] Unable to load package ‘opencv4nodejs’, linking failed: Command ‘npm link opencv4nodejs’ exited with code 1

[debug] [Support] info install if you want to use an own OpenCV installation set OPENCV4NODEJS_DISABLE_AUTOBUILD

[debug] [Support] info readAutoBuildFile file does not exists: /usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/auto-build.json /usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/auto-build.json

[debug] [Support] info install failed to find auto-build.json: /usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/auto-build.json

[debug] [Support] info install

[debug] [Support] info install running install script…

[debug] [Support] info install

[debug] [Support] info install opencv version: 3.4.6

[debug] [Support] info install with opencv contrib: yes

[debug] [Support] info install custom build flags:

[debug] [Support] info install

[debug] [Support] info install executing: git --version

[debug] [Support] info install git --version: git version 2.30.1 (Apple Git-130)

[debug] [Support] info install

[debug] [Support] info install executing: cmake --version

[debug] [Support] ERR! Error: failed to execute cmake --version, cmake is required to build opencv, error is: Error: Command failed: cmake --version

[debug] [Support] /bin/sh: cmake: command not found

[debug] [Support]

[debug] [Support] npm ERR! code ELIFECYCLE

[debug] [Support] npm ERR! errno 1

[debug] [Support] npm ERR! [email protected] install: node ./install.js

[debug] [Support] npm ERR! Exit status 1

[debug] [Support] npm ERR!

[debug] [Support] npm ERR! Failed at the [email protected] install script.

[debug] [Support] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

[debug] [Support]

[debug] [Support] npm ERR! A complete log of this run can be found in:

[debug] [35m[Support] Unable to load package ‘opencv4nodejs’: Unable[35m[Support] npm ERR! /Users/mohamedgamal/.np to load package ‘opencv4nodejs’, linking failed: Command 'm/_logs/2021-0n8-19T15_02_16_672Z-debug.log

[debug] pm link opencv4nodejs’ exited with code 1

[35m[Support]

[Support] Unable to load ‘opencv4nodejs’: Unable to load package ‘opencv4nodejs’: Unable to load package ‘opencv4nodejs’, linking failed: Command ‘npm link opencv4nodejs’ exited with code 1

[debug] [W3C (4e730ba6)] Encountered internal error running command: Error: ‘opencv4nodejs’ module is required to use OpenCV features. Please install it first (‘npm i -g opencv4nodejs’) and restart Appium. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.

[debug] [W3C (4e730ba6)] at initOpenCV (/opt/homebrew/lib/node_modules/appium/node_modules/appium-support/lib/image-util.js:110:11)

[debug] [W3C (4e730ba6)] at Object.getImagesMatches (/opt/homebrew/lib/node_modules/appium/node_modules/appium-support/lib/image-util.js:248:3)

[debug] [W3C (4e730ba6)] at XCUITestDriver.compareImages (/opt/homebrew/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/images.js:55:16)

**although i installed OpenCV **
and when run appium-doccotor >> no issue appeared

Check Is there an alternative for Opencv4nodejs?

you mean that i need to run this command before running test script ?

OPENCV4NODEJS_AUTOBUILD_FLAGS=-DBUILD_opencv_text=OFF npm i -g opencv4nodejs

@mykola-mokhnach
i had now issue when run your script

#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
In file included from …/cc/core/Point.cc:1:
In file included from …/cc/core/Point.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
In file included from …/cc/core/HistAxes.cc:5:
In file included from …/cc/core/HistAxes.h:4:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
In file included from …/cc/ExternalMemTracking.cc:1:
In file included from …/cc/ExternalMemTracking.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/coreConstants.o] Error 1
make: *** Waiting for unfinished jobs…
make: *** [Release/obj.target/opencv4nodejs/cc/core/HistAxes.o] Error 1
In file included from …/cc/core/core.cc:1:
In file included from …/cc/core/core.h:1:
In file included from …/cc/core/Mat.h:1:
In file included from …/cc/core/coreUtils.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
make: *** [Release/obj.target/opencv4nodejs/cc/core/Point.o] Error 1
In file included from …/cc/opencv4nodejs.cc:2:
In file included from …/cc/ExternalMemTracking.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/CustomMatAllocator.o] Error 1
In file included from …/cc/core/Mat.cc:1:
In file included from …/cc/opencv_modules.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/ExternalMemTracking.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/core.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/Mat.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/opencv4nodejs.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:376:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command “/usr/local/nodejs/bin/node” “/usr/local/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild” “–jobs” “max”
gyp ERR! cwd /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
ERR! Error: Command failed: node-gyp rebuild --jobs max
In file included from In file included from …/cc/CustomMatAllocator.cc:1:
In file included from …/cc/CustomMatAllocator.h:8:
…/cc/core/Size.h:1:10: …/cc/core/coreConstants.cc:1:
In file included from …/cc/core/coreConstants.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
In file included from …/cc/core/Point.cc:1:
In file included from …/cc/core/Point.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
In file included from …/cc/core/HistAxes.cc:5:
In file included from …/cc/core/HistAxes.h:4:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
In file included from …/cc/ExternalMemTracking.cc:1:
In file included from …/cc/ExternalMemTracking.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/coreConstants.o] Error 1
make: *** Waiting for unfinished jobs…
make: *** [Release/obj.target/opencv4nodejs/cc/core/HistAxes.o] Error 1
In file included from …/cc/core/core.cc:1:
In file included from …/cc/core/core.h:1:
In file included from …/cc/core/Mat.h:1:
In file included from …/cc/core/coreUtils.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
make: *** [Release/obj.target/opencv4nodejs/cc/core/Point.o] Error 1
In file included from …/cc/opencv4nodejs.cc:2:
In file included from …/cc/ExternalMemTracking.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/CustomMatAllocator.o] Error 1
In file included from …/cc/core/Mat.cc:1:
In file included from …/cc/opencv_modules.h:1:
…/cc/macros.h:2:10: fatal error: ‘opencv2/core.hpp’ file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/ExternalMemTracking.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/core.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/Mat.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/opencv4nodejs.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:376:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command “/usr/local/nodejs/bin/node” “/usr/local/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild” “–jobs” “max”
gyp ERR! cwd /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok