Open botchi09 opened 5 years ago
Same problem did you find a solution
Same problem did you find a solution
Nope. I'm having difficulties getting it to work even now.
I have a similar problem while trying to use the docker image from https://hub.docker.com/r/justadudewhohacks/opencv-nodejs. I found some hints in the net that invalid ELF headers might come from compiling to the wrong architecture...
# node index2.js
/app/opencv/node_modules/opencv4nodejs/lib/cv.js:47
throw err
^
Error: /app/opencv/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node: invalid ELF header
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/app/opencv/node_modules/opencv4nodejs/lib/cv.js:40:8)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
I found the problem in my case: I mistakenly referenced the macOS binaries of the opencv4nodejs module I added locally in the node project (and which were included in the folder I bound to the Docker container). After I referenced the globally installed module of the image, it runs.
I'm trying to use opencv4nodejs
in a docker container (FROM amazonlinux:2
).
I built opencv manually via a Dockerfile
# Build opencv
mkdir /tmp/opencv_build ; \
cd /tmp/opencv_build ; \
cmake3 -D CMAKE_BUILD_TYPE:STRING=Release -D BUILD_LIST=core,imgproc,imgcodecs /tmp/opencv ; \
cmake3 --build . ; \
I copied the /tmp/opencv_build/
in a repo /myNodeProject/
Here is the package.json
"opencv4nodejs": {
"disableAutoBuild": 1,
"opencvIncludeDir": "opencv_build/include",
"opencvLibDir": "opencv_build/lib",
"opencvBinDir": "opencv_build/bin"
}
I also tried to add a .env
OPENCV_INCLUDE_DIR=opencv_build/include
OPENCV_LIB_DIR=opencv_build/lib
OPENCV_BIN_DIR=opencv_build/bin
But when I run my node function I have this error
Error: /myNodeProject/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node: invalid ELF header
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/myNodeProject/node_modules/opencv4nodejs/lib/cv.js:40:8)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
code: 'ERR_DLOPEN_FAILED'
}
@justadudewhohacks @piercus Is it possible that the problem comes from the fact that I installed the node_modules and built my node project on a mac machine ?
@justadudewhohacks @piercus Is it possible that the problem comes from the fact that I installed the node_modules and built my node project on a mac machine ?
Maybe it is related Does autobuilding opencv4nodejs directly from the docker is working ?
Other approach: i suggest you try with version https://www.npmjs.com/package/@u4/opencv4nodejs
If it's not working with @UrielCh's fork, he has been very active on the build recently, and he is looking for feedbacks so he might be able to answer your questions
I'm trying to run a basic script with node darknet, which utilises this opencv module. However while it installs just fine even a basic script won't run. I get this issue:
internal/modules/cjs/loader.js:807 return process.dlopen(module, path.toNamespacedPath(filename)); ^
Error: /mnt/c/Users/Ryan/Documents/rsextract/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node: invalid ELF header
I don't think this is a darknet problem. Does anyone have an idea?
OpenCV version The one that came with npm install -s opencv4nodejs
With OpenCV-contrib? no?
OS: Windows 10 64 bit