Opencv和AWS Lambda [英] Opencv and AWS Lambda

查看:177
本文介绍了Opencv和AWS Lambda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java广告中编写了一个lambda函数,希望使用opencv库.我很难理解如何设置它.请帮忙.我可以在本地进行设置,但是我对lambda部分感到困惑.

I am writing a lambda function in Java ad want to use the opencv library. I am having a hard time understanding how to set it up. Please help. I can set it up just fine locally but I am really confused about the lambda part.

确切地说,我在使用System.LoadLibrary()函数时遇到麻烦.该dll位于项目文件中,但lambda找不到它.

To be precise I am having trouble with System.LoadLibrary() function. The dll is in the project files but lambda cannot find it.

推荐答案

我建议使用Node.js而不是Java,因为Lambdas与Node.js更好地兼容.

I recommend using Node.js instead of Java because Lambdas work better with Node.js.

您的代码将如下所示:

cv = require('opencv');
//do something with cv...

但是在运行代码之前,您应该先安装 OpenCV 及其

But before being able to run the code you should install OpenCV and its node package:

npm install opencv

这将创建一个node_modules文件夹.在本地运行代码后,您需要执行一个额外的步骤,然后将所有内容(即your-code.jsnode_modules文件夹)压缩到lambda-package.zip中,并将其上传到AWS Lambda.

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.

Lambda的额外步骤:

Lambda代码在Amazon Linux环境(而不是您的本地环境)中运行.这意味着您应该在该环境中构建节点程序包.您可以启动EC2实例并在该计算机上执行 npm install 部分,也可以使用docker映像.

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/

这篇关于Opencv和AWS Lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆