danschultzer / receipt-scanner

Receipt scanner extracts information from your PDF or image receipts - built in NodeJS
Other
294 stars 55 forks source link

ERROR: failed to run: pkg-config when running npm install git+https://git@github.com/danschultzer/receipt-scanner.git #62

Open Anima-t3d opened 5 years ago

Anima-t3d commented 5 years ago

When I run npm install git+https://git@github.com/danschultzer/receipt-scanner.git I get the following error:

> node-gyp rebuild

/Users/brechtmissotten/Projects/personal/receipt-parser/node_modules/opencv/utils/find-opencv.js:28
              throw new Error("ERROR: failed to run: pkg-config" + opencv + " " + flag + " - Is OpenCV installed?");
              ^

Error: ERROR: failed to run: pkg-config "opencv >= 2.3.1" --cflags - Is OpenCV installed?
    at /Users/brechtmissotten/Projects/personal/receipt-parser/node_modules/opencv/utils/find-opencv.js:28:21
    at ChildProcess.exithandler (child_process.js:304:5)
    at ChildProcess.emit (events.js:193:13)
    at maybeClose (internal/child_process.js:1001:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
gyp: Call to 'node utils/find-opencv.js --cflags' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

I tried re-installing and also https://stackoverflow.com/a/46743865/3163075 to no avail.

Might be related to https://github.com/peterbraden/node-opencv/issues/325

Schultzer commented 5 years ago

What version of OpenCV do you have installed?

Anima-t3d commented 5 years ago

How can I check? I think I saw something like 4.0.1 when I was running the install.

Schultzer commented 5 years ago

The issue is in node-opencv

https://github.com/peterbraden/node-opencv/blob/db093cb2ec422e507a61e79dd490126060a7e7d0/utils/find-opencv.js#L18

var opencv = process.env.PKG_CONFIG_OPENCV3 === "1" ? "opencv3" : ' "opencv >= 2.3.1"';

The reason it errors is that you are using opencv 4. node-opencv has not been updated to opencv 4. You could try uninstall opencv 4 and install opencv 3 instead.

Anima-t3d commented 5 years ago

I ran brew uninstall opencv and brew install opencv@3, got a lot of warnings but it went through.

When I try to run the receipt-scanner I get the following issue:

{ Error: Command failed: tesseract /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/tmp-1089275wv7gp4xOyq.png /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/node-tesseract-26fc5357-ccbb-4907-bf33-4784bdeb264d -l eng -psm 3
Error, unknown command line argument '-psm'

    at ChildProcess.exithandler (child_process.js:297:12)
    at ChildProcess.emit (events.js:193:13)
    at maybeClose (internal/child_process.js:1001:16)
    at Socket.stream.socket.on (internal/child_process.js:405:11)
    at Socket.emit (events.js:193:13)
    at Pipe._handle.close (net.js:614:12)
  killed: false,
  code: 1,
  signal: null,
  cmd:
   'tesseract /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/tmp-1089275wv7gp4xOyq.png /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/node-tesseract-26fc5357-ccbb-4907-bf33-4784bdeb264d -l eng -psm 3' }

Seems like it's no longer supported in tesseract 4 and now uses --psm

I tried brew uninstall tesseract and brew install tesseract@3 but couldn't find such version to install.

Schultzer commented 5 years ago

Yeah looking at https://github.com/desmondmorris/node-tesseract it doesn't support tesseract 4 yet.

Anima-t3d commented 5 years ago

@Schultzer Seems like node-tesseract is no longer maintained, there are a few pull requests addressing this issue already: https://github.com/desmondmorris/node-tesseract/pull/62

Anima-t3d commented 5 years ago

I applied the update as seen in desmondmorris/node-tesseract#62 in my local node_module, however I got the following error:

{ Error: Command failed: tesseract /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/tmp-13564744nKwcbZlrp.png /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/node-tesseract-9f229b6e-506e-4271-8414-c4062099c744 -l eng --psm 3 --oem undefined
Failed loading language 'eng'
Tesseract couldn't load any languages!
Could not initialize tesseract.

    at ChildProcess.exithandler (child_process.js:297:12)
    at ChildProcess.emit (events.js:193:13)
    at maybeClose (internal/child_process.js:1001:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
  killed: false,
  code: 1,
  signal: null,
  cmd:
   'tesseract /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/tmp-13564744nKwcbZlrp.png /var/folders/s1/2w_5_wds32xd4t4pf5kddtgm0000gn/T/node-tesseract-9f229b6e-506e-4271-8414-c4062099c744 -l eng --psm 3 --oem undefined' }

Seems related to #61