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

Failed to build opencv4nodejs with precompiled 4.1.1 #77

Closed
RomanVeretenov opened this issue Feb 27, 2023 · 2 comments
Closed

Failed to build opencv4nodejs with precompiled 4.1.1 #77

RomanVeretenov opened this issue Feb 27, 2023 · 2 comments

Comments

@RomanVeretenov
Copy link

Error Message

Error: Cannot find module '.../node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs'

Steps to reproduce:

  • I have installed the prebuilt opencv for jetson 4.1.1 (available through specific NVIDIA debian repositories, but it seems that the problem isn't connected espetially with NVIDIA prebuilt binaries).
  • I have set the following variables
export OPENCV4NODEJS_DISABLE_AUTOBUILD=1
export OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION=4.1.1
  • I run npm i @u4/opencv4nodejs
  • I get no error messages, everything seems to be working ok
  • I run the following command to test a binding
    node -e "const cv = require('@u4/opencv4nodejs'); const cap = new cv.VideoCapture('./video.mp4'); const im = cap.read(); console.log(im)"
  • I get the following error stack
<...>/node_modules/@u4/opencv4nodejs/lib/cvloader.js:62
            throw err;
            ^

Error: Cannot find module '<...>/node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs'
Require stack:
- <...>/node_modules/@u4/opencv4nodejs/lib/cvloader.js
- <...>/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js
- <...>/[eval]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at getOpenCV (<...>/node_modules/@u4/opencv4nodejs/lib/cvloader.js:54:23)
    at loadOpenCV (<...>/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js:6:48)
    at Object.<anonymous> (<...>/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js:21:12)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '<...>/node_modules/@u4/opencv4nodejs/lib/cvloader.js',
    '<...>/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js',
    '<...>/[eval]'
  ]
}

How to fix

The module is not built. Using @u4/opencv-build and node-gyp I have found out, that the compilation failes here opencv4nodejs/cc/highgui/highguiConstants.cc:30
the constant WND_PROP_TOPMOST was intoduced only in OpenCV 4.1.2 while in opencv4nodejs code it stands for 3.4.8

Please replace this

#if CV_VERSION_GREATER_EQUAL(3, 4, 8)
	FF_SET_CV_CONSTANT(target, WND_PROP_TOPMOST);
#endif

with

#if CV_VERSION_GREATER_EQUAL(4, 1, 2)
	FF_SET_CV_CONSTANT(target, WND_PROP_TOPMOST);
#endif

Manual Build - Environment Information

OpenCV version 4.1.1
With OpenCV-contrib? (extra modules): no

OS: Ubuntu

@RomanVeretenov
Copy link
Author

Created a PR
#78

@UrielCh
Copy link
Owner

UrielCh commented Feb 28, 2023

Merged, thx for the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants