justadudewhohacks / face-recognition.js

Simple Node.js package for robust face detection and face recognition. JavaScript and TypeScript API.
MIT License
1.91k stars 278 forks source link

Error: load_image failed to open file: std::exception #16

Open djemrose opened 6 years ago

djemrose commented 6 years ago

No matter what image I try and load and even using the examples fr.loadImage always errors? Anybody else getting this?

justadudewhohacks commented 6 years ago

Probably occurs during a runtime exception calling libpng. Did you try upgrading libpng? What's your OS?

djemrose commented 6 years ago

OSX Sierra 10.12.6 libpng 1.6.34 node v8.6.0 npm 5.6.0

brew install libpng
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core, homebrew/php).
==> Updated Formulae
binaryen      chuck         git           idnits        libmonome     modules       serialosc     todoman
ccm           elixir        gjs           jenkins-lts   libre         paket         stress-ng     ttyd
certbot       elvish        hugo          libdvdread    libuv         postgis       svgcleaner
chakra        geoip         ibex          libmaxminddb  linkerd       rpm           tile38

Warning: libpng 1.6.34 is already installed

$ node index.js
/Volumes/Users/clpdxe/Sites/face-recognition/index.js:10
const lenna = fr.loadImage('./data/Lenna.png')
                ^
Error: load_image failed to open file: std::exception
    at Object.<anonymous> (/Volumes/Users/clpdxe/Sites/face-recognition/index.js:10:18)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:607:3
justadudewhohacks commented 6 years ago

Okay then are you sure the path to your file is correct? Try also to use an absolute path e.g. path.resolve('./data/Lenna.png').

stefgootzen commented 6 years ago

I've got the same problem: Ubuntu 16.04.4 LTS libpng12-dev 1.2.54-1ubuntu1 node v9.5.0 npm 5.6.0

/home/stef/Documents/orbitstudios/recognize-api/src/test2.js:6
const img1 = fr.loadImage('../data/faces/niels1.png');
                ^

Error: load_image failed to open file: std::exception
    at Object.<anonymous> (/home/stef/Documents/orbitstudios/recognize-api/src/test2.js:6:17)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:190:16)
    at bootstrap_node.js:662:3

convert -list format | grep PNG gave me

      JNG* PNG       rw-   JPEG Network Graphics
      MNG* PNG       rw+   Multiple-image Network Graphics (libpng 1.2.54)
      PNG* PNG       rw-   Portable Network Graphics (libpng 1.2.54)
           See http://www.libpng.org/ for details about the PNG format.
    PNG00* PNG       rw-   PNG inheriting bit-depth and color-type from original
    PNG24* PNG       rw-   opaque or binary transparent 24-bit RGB (zlib 1.2.8)
    PNG32* PNG       rw-   opaque or transparent 32-bit RGBA
    PNG48* PNG       rw-   opaque or binary transparent 48-bit RGB
    PNG64* PNG       rw-   opaque or transparent 64-bit RGBA
    PNG8* PNG       rw-   8-bit indexed with optional binary transparency

This might tell you more.

justadudewhohacks commented 6 years ago

Not really. Another reason I could think of is missing media codecs.

HarryF514 commented 6 years ago

I am having the same problem. Open jpg is fine. but open png gave me the error above.

sooxt98 commented 6 years ago

guest what?! i had found out a solution. There is some hidden files inside the image train folder!! After i deleted .DS_store, BOOM!

djemrose commented 6 years ago

Can confirm same as @harryyuanfeng JPG works fine but PNG does not.

botv commented 6 years ago

I was having the same issue and then simply ran console.log(path.resolve('image.jpg')) and found I was looking in the wrong directory. I recommend doing this if anyone is still having issues.

deathemperor commented 6 years ago

Also confirm JPG works but PNG does not