1
votes

I'm working on the project that requires me to run my code on the AWS cloud, I've tried some tutorial and I successfully used the python numpy module on AWS lambda, even I'm using window OS, following https://serverless.com/blog/serverless-python-packaging/

However, I would like to import the opencv, I installed opencv-python-headless bypip install opencv-python-headless. After all, I counldn't complete my development, it was told that the "unzipped size must be smaller than 262144000 bytes", it's true, since I had my .zip file with size more than 300000000 bytes.

My question is can I have the more simple opencv for installing, so I can have the package with smaller than the certain amount, I just want few codes about cv2:

faceCascade = cv2.CascadeClassifier(cascPath)
image = cv2.imread(imagePath, cv2.IMREAD_GRAYSCALE )

faces = faceCascade.detectMultiScale(
image,
scaleFactor=1.2,
minNeighbors=5,
minSize=(30, 50),
flags = cv2.CASCADE_SCALE_IMAGE
)

for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
......
lastimg = cv2.resize(crop_img, (182, 182))
cv2.imwrite("crop_{}".format(imagePath), lastimg)

OR is there any method to run these code on AWS cloud, (for example, can I upload my opencv module on AWS S3, and download it when running the above python code.

1
Please format the python codes with indentation - BMW

1 Answers

2
votes

My question is can I have the more simple opencv for installing, so I can have the package with smaller than the certain amount (...).

In order to acomplish this, you should build opencv yourself.

This way you could set the build options and create a version best suited to your needs.

Here are the docs with instructions and build options: https://docs.opencv.org/3.4/d7/d9f/tutorial_linux_install.html

Take a look at this build example with the same objective as yours: https://github.com/aeddi/aws-lambda-python-opencv/blob/master/build.sh


OR is there any method to run these code on AWS cloud, (for example, can I upload my opencv module on AWS S3, and download it when running the above python code.

Sadly, not that I know of.