Cloud & OpenCV: using NodeJS on AWS lambda
*** first read here about NodeJS and AWS lambda *****
from http://stackoverflow.com/questions/38624370/opencv-and-aws-lambda/39649170#39649170
I recommend using Node.js instead of Java because Lambdas work better with Node.js.
Your code will look like this:
cv = require('opencv'); //do something with cv...
But before being able to run the code you should install OpenCV and its node package:
npm install opencv
This will create a node_modules
folder. Once ran your code locally, you need to do one extra step and then zip up everything (i.e. your-code.js
and node_modules
folder) into lambda-package.zip
and upload it to an AWS Lambda.
Extra step for Lambda:
IMPORTANT: Lambda code runs in Amazon Linux environment (not your local environment). That means you should build the node packages in that environment. You may launch an EC2 instance and do the npm install part in that machine or you may use a docker image.
Here's a nice article about this:
https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/
ASLO see https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/ for more