node-opencv icon indicating copy to clipboard operation
node-opencv copied to clipboard

TypeError: Error loading file at Matrix.detectObject when packaged into electron app.

Open fakob opened this issue 8 years ago • 3 comments

Hi I keep running into the TypeError pasted below when trying to run the faceDetection example in a packaged electron app on OSX.

When running the electron app in dev mode (not packaged) everything works fine and opencv.FACE_CASCADE gets loaded via im.detectObject(opencv.FACE_CASCADE, {}, function(err, faces){ just fine. When I package the app it throughs the mentioned error. I have been checking the paths to haarcascade_frontalface_alt.xml and there everything seems to look fine. The only difference is that in the packaged version all this lives in app.asar. Does anyone have experience with this particular error in a packaged electron app context?

Uncaught Exception: TypeError: Error loading file at Matrix.detectObject (/Users/fakob/electron-test-v003/release/mac/ElectronReact.app/Contents/Resources/app.asar/node_modules/opencv/lib/opencv.js:22:20) at /Users/fakob/electron-test-v003/release/mac/ElectronReact.app/Contents/Resources/app.asar/webpack:/app/main.dev.js:105:108 at EventEmitter.<anonymous> (/Users/fakob/electron-test-v003/release/mac/ElectronReact.app/Contents/Resources/app.asar/webpack:/app/main.dev.js:101:22) at emitTwo (events.js:106:13) at EventEmitter.emit (events.js:194:7) at WebContents.<anonymous> (/Users/fakob/electron-test-v003/release/mac/ElectronReact.app/Contents/Resources/electron.asar/browser/api/web-contents.js:247:13) at emitTwo (events.js:106:13) at WebContents.emit (events.js:194:7)

fakob avatar Jul 30 '17 21:07 fakob

I have the same issue. I resolved using electron-builder option "asar": false in my package.json.

It's not the best solution but works for now. This should still be considered as a bug since I was getting this error when passing Buffers to the readImage method.

nicholasc avatar Aug 04 '17 17:08 nicholasc

@nicholasc did you get this running with electron (including packaging for windows)? I am struggling since weeks to get this done!

stoefln avatar Jun 07 '19 20:06 stoefln

@stoefln no. Ended up using opencv4nodejs.

nicholasc avatar Jun 07 '19 21:06 nicholasc