Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: opencv4nodejs module is required to use OpenCV features. #11865

Closed
suswari opened this issue Dec 18, 2018 · 73 comments
Closed

error: opencv4nodejs module is required to use OpenCV features. #11865

suswari opened this issue Dec 18, 2018 · 73 comments
Labels
Needs Info typically non-actionable; needs author to respond

Comments

@suswari
Copy link

suswari commented Dec 18, 2018

The problem

I am trying to use appium image comparison and used the reference code
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
OccurrenceMatchingResult result = driver
.findImageOccurrence(screenshot, partialImage, new OccurrenceMatchingOptions()
.withEnabledVisualization());
assertThat(result.getVisualization().length, is(greaterThan(0)));
assertNotNull(result.getRect());

I see the following error:
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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.

My project is in java and I am really not sure about performing npm i -g opencv4nodejs. Should I do npm i -g opencv4nodejs under the project root, though the project doest not have package.json

Environment

  • Appium version (or git revision) that exhibits the issue: 1.10
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: iOS 10.13.6
  • Node.js version (unless using Appium.app|exe):
  • Mobile platform/version under test:iOs
  • Real device or emulator/simulator:simulator
  • Appium CLI or Appium.app|exe:

Details

If necessary, describe the problem you have been experiencing in more detail.

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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'ICF2008045', ip: 'fe80:0:0:0:46:b040:b1:8193%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_181'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: /Users/sadla/Library/Develo..., autoWebview: true, automationName: XCUITest, browserName: , bundleId: com.icfi.energystarhome, databaseEnabled: false, deviceName: iPad Air 2, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, platform: MAC, platformName: iOS, platformVersion: 11.1, takesScreenshot: true, udid: D4469918-75D5-4277-A205-808..., webStorageEnabled: false}
Session ID: 5ae7aa6a-3eb7-45a4-9458-c88296598bb7

@mykola-mokhnach
Copy link
Collaborator

Did you read the howto document from the error message above?

@mykola-mokhnach mykola-mokhnach added NotABug Needs Info typically non-actionable; needs author to respond labels Dec 18, 2018
@suswari
Copy link
Author

suswari commented Dec 18, 2018

Yes sir, I did. I use a mac and I am unable to realize how to install opencv4nodejs. Can you please refer on the how to doc, what's exactly need to be done to install it.

@KazuCocoa
Copy link
Member

How did you install appium?
npm i -g opencv4nodejs is one way to install it as described in the error message like Appium, npm i -g appium

@mykola-mokhnach
Copy link
Collaborator

Try to read https://docs.npmjs.com/ to know more about npm and NodeJS packaging system

@suswari
Copy link
Author

suswari commented Dec 19, 2018

@KazuCocoa, I used the command npm i -g opencv4nodejs quite many times and restarted the appium. I was getting the same error again and again. (error: opencv4nodejs module is required to use OpenCV features).
@mykola-mokhnach, Sure. Thanks

@KazuCocoa
Copy link
Member

If you handle appium with package.json, you need to add opencv4nodejs into package.json.
(It is npm stuff)
Could you share your log when you run npm i -g opencv4nodejs? I wondered if you faced installing issue for the lib.

@vkuhi
Copy link

vkuhi commented Dec 21, 2018

The same problem, does anyone fix it?

@KazuCocoa
Copy link
Member

In general, this is npm(and PATH issue) thing in your environment.

If you manage your project with package.json, you can make sure if your managed project has opencv4nodejs as below. Then, appium installed in the project can find them.

$ npm list opencv4nodejs # no opencv4nodejs
your/project
└── (empty)
$ npm list opencv4nodejs # has opencv4nodejs
your/project
└── opencv4nodejs@4.11.0

If you manage your Appium environment with -g command, below can call. Then, appium installed by -g option can find them.

$ npm list -g opencv4nodejs # no opencv4nodejs
/Users/kazuaki/.nodebrew/node/v11.4.0/lib
└── (empty)
$ npm list -g opencv4nodejs # has opencv4nodejs
/Users/kazuaki/.nodebrew/node/v10.11.0/lib
└── opencv4nodejs@4.11.0

If you cannot find correct dependencies on your local, you probably make sure your node/npm environment in order node/npm can resolve their dependencies, first.

As mykola addressed in #11865 (comment) , I would recommend you to read npm documentation if you are using package.json stuff.

@vkuhi
Copy link

vkuhi commented Dec 21, 2018

macmini550:~ vkuhi$ npm list opencv4nodejs
/Users/vkuhi
└── opencv4nodejs@4.13.0

It is in the node_modules package, how can I get access to it from my java project?

@KazuCocoa
Copy link
Member

If the node_modules is a global environment for npm, your node/npm command can find it by modules installed by -g option. You have installed Appium via -g option, your appium env can find it launching appium in your home directory, for example.

If your Java project manages appium by package.json, I would recommend you to read https://docs.npmjs.com/ .

@vkuhi
Copy link

vkuhi commented Dec 21, 2018

I do not have any package.json in my Java project. How does the appium will know where this package located?

@KazuCocoa
Copy link
Member

How does the appium will know where this package located?

it depends on npm/node. Appium depends on them to resolve dependencies.

@suswari
Copy link
Author

suswari commented Dec 21, 2018

@vkuhi Initially I ran appium desktop app. I later (after reading the suggestions from in here) realized that the appium I am running and opencv4nodejs i installed are not from the same package/node_modules. So the shutdown the appium desktop app and verfiied the version of global appium, which was 1.7.2. I upgraded it to 1.9. Now that both appium and opencv4nodejs come from same package or node_modules, starting the appium from there solved my issue.

Thanks @KazuCocoa and @mykola-mokhnach for your prompt help :-)

@KazuCocoa
Copy link
Member

Ah... I see. Thanks.

I only explained about appium which is CLI tool. In desktop's case, that has its own package info. so, it can not find global opencv4nodejs.

I would link appium/appium-desktop#714

@eyalpartner
Copy link

eyalpartner commented Feb 28, 2019

I have same issue, node can't find opencv, working with win 10, any help will be appriciate.

Appium server:

I have already installed the opencv through npm,
When I run any driver.findByImage(“path.png”)
I get this error from appium server:

mime must be a string
[W3C] 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-install1 for more details on this topic.
[W3C] at initOpenCV (C:\node_modules\appium\node_modules\appium-support\lib\image-util.js💯11)
[W3C] at Object.getImageOccurrence$ (C:\node_modules\appium\node_modules\appium-support\lib\image-util.js:420:3)
[W3C] at tryCatch (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js💯21)
[W3C] at invoke (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[W3C] at enqueueResult (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
[W3C] at new Promise ()
[W3C] at new F (C:\node_modules\appium\node_modules\core-js\library\modules$.export.js:30:36)
[W3C] at AsyncIterator.enqueue (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
[W3C] at AsyncIterator.prototype.(anonymous function) [as next] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js💯21)
[W3C] at Object.runtime.async (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
[W3C] at Object.getImageOccurrence (C:\node_modules\appium\node_modules\appium-support\build\lib\image-util.js:632:30)
[W3C] at AndroidDriver.callee$0$0$ (C:\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\images.js:47:32)
[W3C] at tryCatch (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js💯21)
[W3C] at invoke (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[W3C] at enqueueResult (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
[W3C] at new Promise ()
[W3C] at new F (C:\node_modules\appium\node_modules\core-js\library\modules$.export.js:30:36)
[W3C] at AsyncIterator.enqueue (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
[W3C] at AsyncIterator.prototype.(anonymous function) [as next] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js💯21)
[W3C] at Object.runtime.async (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
[W3C] at AndroidDriver.callee$0$0 [as compareImages] (C:\node_modules\appium\node_modules\appium-base-driver\build\lib\basedriver\commands\images.js:55:30)
[W3C] at AndroidDriver.condition$ (C:\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\find.js:111:26)
[W3C] at tryCatch (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js💯21)
[W3C] at GeneratorFunctionPrototype.invoke (C:\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)

I am mantion that I already use install opencv in various ways:
npm install --save opencv4nodejs
npm i -g opencv4nodejs

And also tried mannually, the appium doctor keep saying:
WARN AppiumDoctor ✖️ opencv4nodejs cannot be found

But I got indication that the opencv is installed success when install from npm,
maybe Windows 10 path is wrong ? I add mannually all the pathes that I could,
I don’t know what else to do in order that the npm/Windows recognize the opencv and activate him.

@KazuCocoa
Copy link
Member

What result can you get with npm list -g opencv4nodejs?
Did you use appium CLI (not from appium-desktop), right? (because of appium/appium-desktop#714 )

@eyalpartner
Copy link

eyalpartner commented Mar 3, 2019

What result can you get with npm list -g opencv4nodejs?
Did you use appium CLI (not from appium-desktop), right? (because of appium/appium-desktop#714 )


That's the output:
C:\Users\OSN20933\AppData\Roaming\npm
`-- opencv4nodejs@4.14.1

I am using appium server from java code, I am not using appium gui client desktop.

@KazuCocoa
Copy link
Member

thanks.
It appreciates if you could try appium/appium-support#105

@eyalpartner
Copy link

thanks.
It appreciates if you could try appium/appium-support#105

I enter there, But honestly I have no idea what to do according that post,
Can you direct me please ?
Thanks

@KazuCocoa
Copy link
Member

One is building Appium code. Another is waiting for the PR's release in beta


building Appium from code

  1. Build Appium from code => https://appiumpro.com/editions/47
  2. below commands:
    $ git clone git@github.com:appium/appium-support.git
    $ cd appium-support
    $ git checkout isaac-opencv
    $ npm install
    # copy `appium-support/build/` into `appium/node_modules/appium-support/build`
    # move to `appium`
    # node . # then appium launches
    

Or just wait for the PR will release.
Then, you can install it as a beta like:

$ npm uninstall -g appium
$ npm install -g appium@beta

@eyalpartner
Copy link

One is building Appium code. Another is waiting for the PR's release in beta

building Appium from code

  1. Build Appium from code => https://appiumpro.com/editions/47
  2. below commands:
    $ git clone git@github.com:appium/appium-support.git
    $ cd appium-support
    $ git checkout isaac-opencv
    $ npm install
    # copy `appium-support/build/` into `appium/node_modules/appium-support/build`
    # move to `appium`
    # node . # then appium launches
    

Or just wait for the PR will release.
Then, you can install it as a beta like:

$ npm uninstall -g appium
$ npm install -g appium@beta

didn't help,
I have removed npm and node.js and appium from my pc,
Trying to install all from the begining, hope it may help....

@eyalpartner
Copy link

Nothing help so far....
I tried averything

@eyalpartner
Copy link

Update:
After remove node.js and npm and appium from pc, install all from the begining, it solve the error

@KazuCocoa
Copy link
Member

thanks. I guess node dependencies affected that...

@13817458995
Copy link

I have install opencv4nodejs by npm install -g opencv4nodejs.
Run appium-doctor --ios, return opencv4nodejs is installed at: /usr/local/lib. Installed version is: 5.1.0
Start appium desktop and run the test, still return below error message:
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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.

How should I install the opencv4nodejs and anything need to be configured?

@KazuCocoa
Copy link
Member

I could not find the solution for desktop appium/appium-desktop#714

You can run appium CLI separately and connect to it from the desktop app via the custom server tab in the inspector.

@adityabhargav
Copy link

adityabhargav commented May 11, 2020

@KazuCocoa ,
By appium-doctor,
found out that issue regarding the FFMPEG as given below,

{ Error: Command 'ffmpeg -version' exited with code null
at ChildProcess.proc.on.code (/usr/local/lib/node_modules/appium-doctor/node_modules/teen_process/lib/exec.js:113:19)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
stdout: '',
stderr:
'dyld: Library not loaded: /usr/local/opt/tesseract/lib/libtesseract.4.dylib\n Referenced from: /usr/local/bin/ffmpeg\n Reason: image not found\n',
code: null }

is FFMPEG is required by OpenCV4nodejs?

or

do we need tessract lib. ? (Becoz i've removed it for issue in opencv4nodejs installation)

@KazuCocoa
Copy link
Member

Simply they required libtesseract.4.dylib

@adityabhargav
Copy link

Hi @KazuCocoa

The issue got resolved and working fine, able to click on element by the image...

The issue seems to be with
1.FFMPEG
2.TESSERACT
3.OpenSSL
not installed before or not updated properly

after reinstalling got solved the issue

Thanx a lot for helping me... and sparing ur valuable time...

@sumanthvakacharla
Copy link

sumanthvakacharla commented Jun 24, 2020

@adityabhargav Can you please share your steps/commands in re-installing those 3 mentioned issues ?

By the way, my appium-doctor logs are below:
appium-doctor
Error: Package exports for '/Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/appium-doctor/node_modules/uuid' do not define a valid '.' target
at resolveExportsTarget (internal/modules/cjs/loader.js:545:13)
at applyExports (internal/modules/cjs/loader.js:459:14)
at resolveExports (internal/modules/cjs/loader.js:508:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:577:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:879:27)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/appium-doctor/node_modules/appium-support/lib/util.js:15:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
at Module.load (internal/modules/cjs/loader.js:914:32)
at Function.Module._load (internal/modules/cjs/loader.js:822:14)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/Users/sumanthvakacharla/.virtualenvs/VirtualEnv/lib/node_modules/appium-doctor/node_modules/appium-support/lib/fs.js:12:1)
(virtualEnv) svakacharla-mac:automation sumanthvakacharla$

Other info:
(virtualEnv) svakacharla-mac:automation sumanthvakacharla$ npm list -g opencv4nodejs
/Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib
└── opencv4nodejs@5.6.0

@KazuCocoa
APPIUM LOGS:
BaseDriver] Verifying screenshot size and aspect ratio
[BaseDriver] Screenshot aspect ratio '0.5625' (1242x2208) matched screen aspect ratio '0.5625' (414x736)
[BaseDriver] Scaling screenshot from 1242x2208 to match screen at 414x736
[debug] [Support] Initializing opencv
[debug] [Support] Loading local package 'opencv4nodejs'
[debug] [Support] Failed to load local package 'opencv4nodejs': Cannot find module '/Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs'
[debug] [Support] Require stack:
[debug] [Support] - /Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/opencv4nodejs/lib/cv.js
[debug] [Support] - /Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/opencv4nodejs/lib/opencv4nodejs.js
[debug] [Support] - /Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/appium/node_modules/appium-support/build/lib/node.js
[debug] [Support] - /Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/appium/node_modules/appium-support/build/lib/image-util.js
[debug] [Support] - /Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/appium/node_modules/appium-support/build/index.js
[debug] [Support] - /Users/sumanthvakacharla/.virtualenvs/TvirtualEnv/lib/node_modules/appium/build/lib/logsink.js
[debug] [Support] - /Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/appium/build/lib/main.js
[debug] [Support] Loading global package '/Users/sumanthvakacharla/.virtualenvs/virtualEnv/lib/node_modules/opencv4nodejs'
[debug] [Support] Failed to load global package 'opencv4nodejs': Cannot find module '/Users/sumanthvakacharla/.virtualenvs/TvirtualEnv/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs'

@adityabhargav
Copy link

Hi @sumanthvakacharla ,

above mentioned are node libs., and need to install w.r.t to the node_modules folder where opencv4nodejs is placed...

1.FFMPEG -- npm i ffmpeg
2.TESSERACT -- npm i tesseract
3.OpenSSL -- npm i openssl

@sajithgr
Copy link

sajithgr commented Aug 4, 2020

[debug] �[35m[Support]�[39m Failed to load global package 'opencv4nodejs': The "path" argument must be of type string. Received undefined
[debug] �[35m[Support]�[39m Linking package 'opencv4nodejs'
[debug] �[35m[Support]�[39m Retrying load of linked package 'opencv4nodejs'
�[35m[Support]�[39m Unable to load package 'opencv4nodejs': The specified module could not be found.

Still facing the issue on windows 10.
npm list -g --depth=0
+-- appium@1.18.0
+-- node-gyp@7.0.0
+-- opencv4nodejs@5.6.0

Any solution for this??

@sajithgr
Copy link

sajithgr commented Aug 5, 2020

Update:
After remove node.js and npm and appium from pc, install all from the begining, it solve the error

Please explai in details how you solved this. Please?

@sajithgr
Copy link

The problem

I am trying to use appium image comparison and used the reference code
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
OccurrenceMatchingResult result = driver
.findImageOccurrence(screenshot, partialImage, new OccurrenceMatchingOptions()
.withEnabledVisualization());
assertThat(result.getVisualization().length, is(greaterThan(0)));
assertNotNull(result.getRect());

I see the following error:
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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.

My project is in java and I am really not sure about performing npm i -g opencv4nodejs. Should I do npm i -g opencv4nodejs under the project root, though the project doest not have package.json

Environment

  • Appium version (or git revision) that exhibits the issue: 1.10
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: iOS 10.13.6
  • Node.js version (unless using Appium.app|exe):
  • Mobile platform/version under test:iOs
  • Real device or emulator/simulator:simulator
  • Appium CLI or Appium.app|exe:

Details

If necessary, describe the problem you have been experiencing in more detail.

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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'ICF2008045', ip: 'fe80:0:0:0:46:b040:b1:8193%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_181'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: /Users/sadla/Library/Develo..., autoWebview: true, automationName: XCUITest, browserName: , bundleId: com.icfi.energystarhome, databaseEnabled: false, deviceName: iPad Air 2, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, platform: MAC, platformName: iOS, platformVersion: 11.1, takesScreenshot: true, udid: D4469918-75D5-4277-A205-808..., webStorageEnabled: false}
Session ID: 5ae7aa6a-3eb7-45a4-9458-c88296598bb7

@suswari how you solved your issue reported here

@qwerty32123
Copy link

I have this same problem and i solver by installing cmake before trying to install opencv4nodejs with npm

@mohamed8681
Copy link

mohamed8681 commented Aug 19, 2021

What result can you get with npm list -g opencv4nodejs?
Did you use appium CLI (not from appium-desktop), right? (because of appium/appium-desktop#714 )

/Users/mohamedgamal/.npm-global/lib
└── opencv4nodejs@5.6.0

but i have the issue when run test script

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! opencv-build@0.1.9 install: node ./install.js
[debug] [Support] npm ERR! Exit status 1
[debug] [Support] npm ERR!
[debug] [Support] npm ERR! Failed at the opencv-build@0.1.9 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)
[HTTP] <-- POST /wd/hub/session/4e730ba6-9b43-4eea-be6d-800298d4ff5d/appium/compare_images 500 7593 ms - 967
[HTTP]
method checkAvailabilitySection failed
[ERROR] 2021-08-19 17:02:16.785 [main] Log - method checkAvailabilitySection failed
[ERROR] 2021-08-19 17:02:16.787 [main] Log - The console issue of failed method checkAvailabilitySection is 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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'mohameds-MacBook-Pro.local', ip: 'fe80:0:0:0:4e0:6823:18c5:a806%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_291'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: /Users/mohamedgamal/Documen..., applicationCacheEnabled: false, autoAcceptAlerts: true, automationName: XCUITest, browserName: , databaseEnabled: false, deviceName: Iphone_Mohamed_Gamal, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: true, locationServicesAuthorized: true, locationServicesEnabled: true, networkConnectionEnabled: true, newCommandTimeout: 600000, platform: MAC, platformName: IOS, platformVersion: 14.6, startIWDP: true, takesScreenshot: true, udid: 00008101-00015D200E91001E, useNewWDA: false, usePrebuiltWDA: true, waitForQuiescence: false, wdaEventloopIdleDelay: 3, webStorageEnabled: false, xcodeOrgId: M82244S89Y, xcodeSigningId: iPhone Developer}
Session ID: 4e730ba6-9b43-4eea-be6d-800298d4ff5d
Screenshot captured for test case:checkAvailabilitySection
[HTTP] --> GET /wd/hub/session/4e730ba6-9b43-4eea-be6d-800298d4ff5d/screenshot

@mohamed8681
Copy link

Hi @KazuCocoa ,

I have removed OpenCV,appium node modules and started with re-downloading the opencv4nodejs(from npm install -g opencv4node) and appium(v1.17.1) CLI globally.,

but again getting the issue as given below

Appium Logs:-

[debug] [Support] Initializing opencv
[debug] [Support] Loading local package 'opencv4nodejs'
[debug] [Support] Failed to load local package 'opencv4nodejs': dlopen(/usr/local/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node, 1): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
[debug] [Support] Referenced from: /usr/local/opt/ffmpeg/lib/libavformat.58.dylib
[debug] [Support] Reason: image not found
[debug] [Support] Failed to load global package 'opencv4nodejs': The "path" argument must be of type string. Received type undefined
[debug] [Support] Linking package 'opencv4nodejs'
[debug] [Support] Retrying load of linked package 'opencv4nodejs'
[Support] Unable to load package 'opencv4nodejs': dlopen(/usr/local/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node, 1): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
[Support] Referenced from: /usr/local/opt/ffmpeg/lib/libavformat.58.dylib
[Support] Reason: image not found
[Support] Unable to load 'opencv4nodejs': Unable to load package 'opencv4nodejs': dlopen(/usr/local/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node, 1): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
[Support] Referenced from: /usr/local/opt/ffmpeg/lib/libavformat.58.dylib
[Support] Reason: image not found
[debug] [W3C (02d838a1)] 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 (02d838a1)] at initOpenCV (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/image-util.js:109:11)
[HTTP] <-- POST /wd/hub/session/02d838a1-d44b-4af2-8714-c1b46c1f4635/element 500 1663 ms - 961

issue in Java-Client:-

Exception in thread "main" 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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.

the same issue when run test script

xecuting 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! opencv-build@0.1.9 install: node ./install.js
[debug] [Support] npm ERR! Exit status 1
[debug] [Support] npm ERR!
[debug] [Support] npm ERR! Failed at the opencv-build@0.1.9 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)
[HTTP] <-- POST /wd/hub/session/4e730ba6-9b43-4eea-be6d-800298d4ff5d/appium/compare_images 500 7593 ms - 967
[HTTP]
method checkAvailabilitySection failed
[ERROR] 2021-08-19 17:02:16.785 [main] Log - method checkAvailabilitySection failed
[ERROR] 2021-08-19 17:02:16.787 [main] Log - The console issue of failed method checkAvailabilitySection is 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. Read https://github.com/justadudewhohacks/opencv4nodejs#how-to-install for more details on this topic.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'mohameds-MacBook-Pro.local', ip: 'fe80:0:0:0:4e0:6823:18c5:a806%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_291'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: /Users/mohamedgamal/Documen..., applicationCacheEnabled: false, autoAcceptAlerts: true, automationName: XCUITest, browserName: , databaseEnabled: false, deviceName: Iphone_Mohamed_Gamal, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: true, locationServicesAuthorized: true, locationServicesEnabled: true, networkConnectionEnabled: true, newCommandTimeout: 600000, platform: MAC, platformName: IOS, platformVersion: 14.6, startIWDP: true, takesScreenshot: true, udid: 00008101-00015D200E91001E, useNewWDA: false, usePrebuiltWDA: true, waitForQuiescence: false, wdaEventloopIdleDelay: 3, webStorageEnabled: false, xcodeOrgId: M82244S89Y, xcodeSigningId: iPhone Developer}
Session ID: 4e730ba6-9b43-4eea-be6d-800298d4ff5d
Screenshot captured for test case:checkAvailabilitySection
[HTTP] --> GET /wd/hub/session/4e730ba6-9b43-4eea-be6d-800298d4ff5d/screenshot

@KazuCocoa
Copy link
Member

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

Have you installed opencv4nodejs?
If yes, where did you install on your local?

@mohamed8681
Copy link

mohamed8681 commented Aug 22, 2021

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

Have you installed opencv4nodejs? Yes
If yes, where did you install on your local? >>. info AppiumDoctor opencv4nodejs is installed at: /Users/mohamedgamal/.npm-global/lib. Installed version is: 5.6.0

npm list -g opencv4nodejs
/Users/mohamedgamal/.npm-global/lib
└── opencv4nodejs@5.6.0

@KazuCocoa
Copy link
Member

KazuCocoa commented Aug 22, 2021

I guess your local environment refers to /opt/homebrew/lib instead of /Users/mohamedgamal/.npm-global/lib.

Latest Appium loads a npm package as https://github.com/appium/appium-support/blob/15afcad2329e872f76195120ff238450fafc3bbb/lib/node.js#L38-L64, so it calls requires in some possible ways.

e.g.

> node
# on node repl
$ require('opencv4nodejs')

process.env.npm_config_prefix

@mohamed8681
Copy link

mohamed8681 commented Aug 22, 2021

I guess your local environment refers to /opt/homebrew/lib instead of /Users/mohamedgamal/.npm-global/lib.

Latest Appium loads a npm package as https://github.com/appium/appium-support/blob/15afcad2329e872f76195120ff238450fafc3bbb/lib/node.js#L38-L64, so it calls requires in some possible ways.

e.g.

> node
# on node repl
$ require('opencv4nodejs')

process.env.npm_config_prefix

issue :- 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'

thanks for your reply but i did not understand how to resolve it now

@KazuCocoa
Copy link
Member

I guess you can try to set npm_config_prefix environment variables like:

NPM_CONFIG_PREFIX=/Users/mohamedgamal/.npm-global appium

I haven't met the error and tried the environment, but i guess your environment has two paths for lib for node/npm

@mohamed8681
Copy link

mohamed8681 commented Aug 23, 2021

/Users/mohamedgamal/.npm-global appium

@KazuCocoa
i added the variable to env
env.put("NPM_CONFIG_PREFIX", "/Users/mohamedgamal/.npm-global appium");
also i tried to add the absolute path without appium
env.put("NPM_CONFIG_PREFIX", "/Users/mohamedgamal/.npm-global");
image

also i have the same issue
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: spawn npm ENOENT
[Support] Unable to load 'opencv4nodejs': Unable to load package 'opencv4nodejs': Unable to load package 'opencv4nodejs', linking failed: spawn npm ENOENT
[Support] Unable to load package 'opencv4nodejs': Unable to load package 'opencv4nodejs', linking failed: spawn npm ENOENT

when follow path which appeared in log /opt/homebrew/lib/node_modules/opencv4nodejs/build/Release/
image

@KazuCocoa
Copy link
Member

What is the result of npm config get prefix?

As i guess your environment has two paths for lib for node/npm, the root cause is probably your local configuration had two cases. One was to /opt/homebrew/lib/ and the other was /Users/mohamedgamal/.npm-global.
I guess appium command was in /opt/homebrew/lib/. opencv4nodejs was in /Users/mohamedgamal/.npm-global. I don't know how you installed opencv4nodejs but I guess the installation path was different from the /opt/homebrew/lib/.
(I haven't used homebrew to manage node/npm, so I have no good idea for now)

@mohamed8681
Copy link

mohamed8681 commented Aug 23, 2021

npm config get prefix

@KazuCocoa >> the result of npm config get prefix is>>>> /Users/mohamedgamal/.npm-global

So i tried to link the opencv4nodejs module to appium by going to Users/mohamedgamal/.npm-globaland and running below mentioned command:

npm ls -g opencv4nodejs --depth=0 && npm link opencv4nodejs

/Users/mohamedgamal/.npm-global/lib
└── opencv4nodejs@5.6.0

/Users/mohamedgamal/node_modules/opencv4nodejs -> /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs

but the issue is still

[debug] [XCUITest] Executing command 'compareImages'
[debug] [Support] Initializing opencv
[debug] [Support] Loading local package 'opencv4nodejs'
[debug] [Support] Failed to load local package 'opencv4nodejs': Cannot find module '/Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs'
[debug] [Support] Require stack:
[debug] [Support] - /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/lib/cv.js
[debug] [Support] - /Users/mohamedgamal/.npm-global/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: spawn npm ENOENT

@KazuCocoa
Copy link
Member

Btw, did the opencv4nodejs installed correctly? I saw a case opencv4nodejs package was installed, but the installation was broken. So the module did not have some modules. Then, like the below require fails because of missing some modules. Then, you should ensure if opencv4nodejs is exactly installed.

> node
# on node repl
$ require('opencv4nodejs')

@mohamed8681
Copy link

mohamed8681 commented Aug 24, 2021

@KazuCocoa
mohameds-MacBook-Pro:~ mohamedgamal$ node
Welcome to Node.js v14.17.0.
Type ".help" for more information.

require('opencv4nodejs')
Uncaught:
Error: Cannot find module '/Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/build/Release/opencv4nodejs'
Require stack:

  • /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/lib/cv.js
  • /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/lib/opencv4nodejs.js
  • at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15) at Function.Module._load (internal/modules/cjs/loader.js:730:27) at Module.require (internal/modules/cjs/loader.js:957:19) at require (internal/modules/cjs/helpers.js:88:18) { code: 'MODULE_NOT_FOUND', requireStack: [ '/Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/lib/cv.js', '/Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/lib/opencv4nodejs.js', '' ]

}

@mohamed8681
Copy link

@KazuCocoa but after use brew install brew install opencv@4 then npm i -g opencv4nodejs

i got different issue

1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/HistAxes.o] Error 1
1 error generated.
In file included from ../cc/CustomMatAllocator.cc:1:
In file included from ../cc/CustomMatAllocator.h:8:
../cc/core/Size.h:1: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/ExternalMemTracking.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/CustomMatAllocator.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 ../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>
^~~~~~~~~~~~~~~~~~
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.
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>
^~~~~~~~~~~~~~~~~~
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/coreConstants.o] Error 1
make: *** Waiting for unfinished jobs....
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>
^~~~~~~~~~~~~~~~~~
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>
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/core/HistAxes.o] Error 1
1 error generated.
In file included from ../cc/CustomMatAllocator.cc:1:
In file included from ../cc/CustomMatAllocator.h:8:
../cc/core/Size.h:1: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/ExternalMemTracking.o] Error 1
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/CustomMatAllocator.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

  • opencv4nodejs@5.6.0

@mohamed8681
Copy link

mohamed8681 commented Aug 24, 2021

@KazuCocoa. i found the same issue but i can not understand
the solve

justadudewhohacks/opencv4nodejs#661 (comment)

and also the same issue but i did not understand the solve
justadudewhohacks/opencv4nodejs#538 (comment)

@KazuCocoa
Copy link
Member

I found my old comment about the version #15210 (comment) (OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION=3.4.6 npm install -g opencv4nodejs@4.17.0)
Probably you want to try the version...

@mohamed8681
Copy link

OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION=3.4.6 npm install -g opencv4nodejs@4.17.0

@KazuCocoa
i ruined it and i have the issue

opencv-build@0.1.9 install /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs/node_modules/opencv-build
node ./install.js

info install OPENCV4NODEJS_DISABLE_AUTOBUILD is set
info install skipping auto build...

opencv4nodejs@4.17.0 install /Users/mohamedgamal/.npm-global/lib/node_modules/opencv4nodejs
node-gyp rebuild

CXX(target) Release/obj.target/opencv4nodejs/cc/opencv4nodejs.o
In file included from ../cc/opencv4nodejs.cc:2:
In file included from ../cc/ExternalMemTracking.h:2:
In file included from ../cc/CustomMatAllocator.h:8:
../cc/core/Size.h:1:10: fatal error: 'opencv2/core.hpp' file not found
#include <opencv2/core.hpp>
^~~~~~~~~~~~~~~~~~
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"
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
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv4nodejs@4.17.0 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv4nodejs@4.17.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mohamedgamal/.npm/_logs/2021-08-24T22_10_03_785Z-debug.log
image

@jlipps
Copy link
Member

jlipps commented Aug 25, 2021

OpenCV is very difficult to install. I wish we didn't depend on it for these features. But we cannot support OpenCV & OpenCV4NodeJS installations. Once you have it set where opencv4nodejs can be required, then Appium will work with it.

@mohamed8681
Copy link

mohamed8681 commented Aug 25, 2021

OpenCV is very difficult to install. I wish we didn't depend on it for these features. But we cannot support OpenCV & OpenCV4NodeJS installations. Once you have it set where opencv4nodejs can be required, then Appium will work with it.

@jlipps

can. you advise me about other libraries to compare two images for same element ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Info typically non-actionable; needs author to respond
Projects
None yet
Development

No branches or pull requests