0

I am trying to use opencv4nodejs for image comparison with appium but getting the error.

Version Information

  • System - mac
  • OS : Catalina 10.15.7
  • appium : CLI - 1.22.0
  • node : v17.0.1
  • npm : 8.1.0

Set up done till now

  1. export OPENCV4NODEJS_DISABLE_AUTOBUILD=1 -----in bash.profile
  2. npm install -g appium ----- [Location : /usr/local/lib/node_modules]
  3. npm i -g opencv4nodejs ----- [Location : /usr/local/lib/node_modules]
  4. went to appium folder using 'cd' ---- npm link opencv4nodejs ----- [created link is displayed in appium folder]

Error

1. In eclipse

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: 'opencv4nodejs' module is required to use OpenCV features. Please install it first ('npm i -g opencv4nodejs') and restart Appium.

2. On appium server log

[debug] [XCUITest] Executing command 'compareImages'

dbug Support Initializing opencv

dbug Support Loading local package 'opencv4nodejs'

dbug Support Failed to load local package 'opencv4nodejs': Cannot find module '/usr/local/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs'

dbug Support Require stack: dbug Support - /usr/local/lib/node_modules/opencv4nodejs/lib/cv.js

dbug Support - /usr/local/lib/node_modules/opencv4nodejs/lib/opencv4nodejs.js

dbug Support - /usr/local/lib/node_modules/appium/node_modules/appium-support/build/lib/node.js

dbug Support - /usr/local/lib/node_modules/appium/node_modules/appium-support/build/lib/image-util.js

dbug Support - /usr/local/lib/node_modules/appium/node_modules/appium-support/build/index.js

dbug Support - /usr/local/lib/node_modules/appium/build/lib/logsink.js

dbug Support - /usr/local/lib/node_modules/appium/build/lib/main.js

dbug Support Failed to load global package 'opencv4nodejs': The "path" argument must be of type string. Received undefined

dbug Support Linking package 'opencv4nodejs'

[debug] [WebDriverAgent] Parsed BUILD_DIR configuration value: '/Users/-username-/Library/Developer/Xcode/DerivedData/WebDriverAgent-(some data)/Build/Products'

[debug] [WebDriverAgent] Got derived data root: '/Users/-username-/Library/Developer/Xcode/DerivedData/WebDriverAgent-(some data)'

dbug Support Unable to load package 'opencv4nodejs', linking failed: Command 'npm link opencv4nodejs' exited with code 236

dbug Support npm ERR! code ENOTDIR

dbug Support npm ERR! syscall rename

dbug Support npm ERR! path /Users/-username-/node_modules/opencv4nodejs

dbug Support npm ERR! dest /Users/-username-/node_modules/.opencv4nodejs-YhDFjzvW

dbug Support npm ERR! errno -20

dbug Support npm ERR! ENOTDIR: not a directory, rename '/Users/-username-/node_modules/opencv4nodejs' -> '/Users/-username-/node_modules/.opencv4nodejs-YhDFjzvW'

dbug Support

dbug Support npm ERR! A complete log of this run can be found in:

dbug Support npm ERR! /Users/-username-/.npm/_logs/2021-11-02T08_10_14_713Z-debug.log dbug Support

ERR! Support Unable to load package 'opencv4nodejs': Unable to load package 'opencv4nodejs', linking failed: Command 'npm link opencv4nodejs' exited with code 236

WARN Support Unable to load 'opencv4nodejs': Unable to load package 'opencv4nodejs': Unable to load package 'opencv4nodejs', linking failed: Command 'npm link opencv4nodejs' exited with code 236

1 Answer 1

0

Iam Facing same issues couple week a go ,I assume opnecv4nodejs not works properly on appium 1.20.xx , Here my solution :

Step By Step :

  1. Un install opencv-build, opencv4nodejs and opencv:

brew uninstall opecv
npm uninstall -g opencv-build
npm uninstall -g opencv4nodejs

  1. Downgrade Appium to 1.20.xx

sudo npm uninstall -g appium
sudo npm install -g appium@1.20.2 --unsafe-perm=true --allow-root --force
sudo chown -R $(whoami) <path of Appium node modules> (e.g: /usr/local/lib/node_modules/appium)

  1. Downgrade node to v10.16.1 you can follow this step How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) and please don't use nvm or make sure your node modules at usr/loca/lib/node_modules

  2. set env variable to select opencv modules to install WITH autobuild

export OPENCV4NODEJS_AUTOBUILD_FLAGS=-DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui,video,calib3d,features2d,objdetect,dnn,ml,flann,photo,stitching,gapi

  1. Install opencv & opencv4nodejs

npm i -g opencv-build
npm i -g opencv4nodejs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.