211142 (3) [Avatar] Offline
I downloaded the faceDetection-js.zip file from the book. Then I modified dstBucket and outputDomain appropriately and uploaded the new zip to AWS Lambda. Finally I added a policy to allow PUTting S3 objects in my bucket and connected the policy to a Lambda rule for my faceDetection function.

I ran:
aws lambda invoke --function-name faceDetection --payload '{"imageUrl":"http://weknowyourdreams.com/images/people/people-06.jpg"}' output.txt

I got this result:
    "FunctionError": "Unhandled", 
    "StatusCode": 200

This was in the output.txt file:
  "errorMessage": "Cannot find module '/var/task/node_modules/opencv/build/opencv/v5.0.0/Release/node-v46-linux-x64/opencv.node'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:276:25)",
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)",
    "Object.<anonymous> (/var/task/node_modules/opencv/lib/bindings.js:4:15)",
    "Module._compile (module.js:409:26)",
    "Object.Module._extensions..js (module.js:416:10)",
    "Module.load (module.js:343:32)",
    "Function.Module._load (module.js:300:12)",
    "Module.require (module.js:353:17)"

There isn't a node-v46-linux-x64/opencv.node file in node_modules. Instead there's a node-v11-linux-x64/opencv.node file. How I can get this to work?
211142 (3) [Avatar] Offline
Changing {node_abi} to node-v11 in package.json's binary:module_path value led to this error:
  "errorMessage": "Module did not self-register.",
  "errorType": "Error",
  "stackTrace": [
    "Object.Module._extensions..node (module.js:434:18)",
    "Module.load (module.js:343:32)",
    "Function.Module._load (module.js:300:12)",
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)",
    "Object.<anonymous> (/var/task/node_modules/opencv/lib/bindings.js:4:15)",
    "Module._compile (module.js:409:26)",
    "Object.Module._extensions..js (module.js:416:10)",
    "Module.load (module.js:343:32)"
211142 (3) [Avatar] Offline
Anybody else able to get opencv to work?
475381 (1) [Avatar] Offline
Hi, I have same problem.Beside that the book in this exercise is not well described, but i get:

"errorMessage": "Cannot find module '/var/task/node_modules/opencv/build/opencv/v5.0.0/Release/node-v48-linux-x64/opencv.node'"

any hints?
481543 (1) [Avatar] Offline
I had the same problem. It looks like the opencv that was delivered with the node.js is not right (not sure why) because the directly that the log is complaining about doesn't exist. I uploaded the python version. I had to change the invoke method for python and I was able to get this to work.
512702 (1) [Avatar] Offline
I had the same problems with opencv face-detection example for nodejs.

I tried the faceDetection several hours before I understood, that I have to compile the opencv for the node-version I selected in lambda (6.10).
And than use that binaries for the lambda package to get the face detection running in lambda.

I googled around and sampled steps mainly from two pages and the book itself to get it running.
Hope posting my steps help you.

If you are not experienced in setting up and using a AWS EC2 Linux instance and Linux (via ssh/commandline/scp/zip ...), the description of my steps will not help you.

What I did:
1. Start a new AWS EC2 instance from the Amazon Linux-Image.
2. Connect to this instance via ssh.
3. Install the nvm ( node version manager)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
. ~/.nvm/nvm.sh

4. Install the node Version I selected in the lambda-Function (6.10)
nvm install 6.10
5. Install the compiler and tools
sudo yum update -y
sudo yum install –y gcc44 gcc-c++ libgcc44 cmake

6. make a Directory for compiling opencv and changed to it
mkdir compile_opencv && cd compile_opencv
7. Download opencv version 2.4. linux unix-source-code
wget https://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.11/opencv-2.4.11.zip/download -O opencv-2.4.11.zip

8. make folder for the source files
mkdir opencv-source
9. change to soure folder
cd opencv-source
10. unzip opencv-zip to souce-folder
unzip ../opencv-2.4.11.zip
11. prepare compiling
12. compile and install opencv locally (takes a while or long depending on your ec2 instance)
make && make install
13. correct the library parameters for the image-formats (as explained in the book) in the file:
-ljasper -ltiff -lpng -ljpeg
-llibjasper -llibtiff -llibpng -llibjpeg
14. make a node project folder
cd ~
mkdir opencv_lambda_template

15. install opencv in the project folder
PKG_CONFIG_PATH=~/opencv/lib/pkgconfig/ npm install --prefix=~/opencv_lambda_template opencv

16. (optional) test opencv in project folder (copied from step 6: https://aws.amazon.com/de/blogs/compute/nodejs-packages-in-lambda/)

cd ~/opencv_lambda_template
cd node_modules/opencv/examples/
mkdir tmp
node face-detection.js # Image saved to ./tmp/face-detection.png
ls tmp # face-detection.png
rm -r tmp

You may then zip the project folder and copy (scp ...) the zip to your local machine.
There you can extract and use it as template for the project. You fill with your code file and install the appropriate packages.

Or you may edit the project on the ec2 instance.
Finally you zip it and push it to S3 (you have to install the needed credentials on the ec2 instance if you do it from there).

From S3 you can load the zip to lambda.

Pages that helped me beside the book itself:

Hope that helps