From e28d44df60b742bb16f1b2a802b1195bb1a9a528 Mon Sep 17 00:00:00 2001 From: aeddi Date: Sun, 22 May 2016 19:03:54 +0200 Subject: [PATCH 01/12] Fix username in URLs --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 28e2dbf..fb00c38 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Python OpenCV module for AWS Lambda -This is a simple script that build a deployement package including OpenCV compatible with the AWS Lambda Python runtime. The dynamic library is compiled with all extended instruction sets supported by Lambda CPU and binaries are stripped to save space. You simply need to add your code inside *lambda_funcion.py* and possibly your haar cascades files or additional Python modules. You can download directly a [pre-built archive](https://github.com/Plastic-1/aws-lambda-python-opencv/archive/prebuilt.zip). +This is a simple script that build a deployment package including OpenCV compatible with the AWS Lambda Python runtime. The dynamic library is compiled with all extended instruction sets supported by Lambda CPU and binaries are stripped to save space. You simply need to add your code inside *lambda_funcion.py* and possibly your haar cascades files or additional Python modules. You can download directly a [pre-built archive](https://github.com/aeddi/aws-lambda-python-opencv/releases/download/Prebuilt/aws-lambda-python-opencv-prebuilt.zip). - Build duration: ~20 min on T2.micro / ~15 min on C4.2xlarge - Package size without haar cascades included: 26MB @@ -10,7 +10,7 @@ This is a simple script that build a deployement package including OpenCV compat ## Module building ### Option 1: with an existing instance -- Download the repo `wget https://github.com/Plastic-1/aws-lambda-python-opencv/archive/master.zip` +- Download the repo `wget https://github.com/aeddi/aws-lambda-python-opencv/archive/master.zip` - Unzip the archive `unzip master.zip` - Launch the script `cd aws-lambda-python-opencv-master && ./build.sh` @@ -26,7 +26,7 @@ yum update -y yum install -y git cmake gcc-c++ gcc python-devel chrpath cd /tmp -wget https://github.com/Plastic-1/aws-lambda-python-opencv/archive/master.zip +wget https://github.com/aeddi/aws-lambda-python-opencv/archive/master.zip unzip master.zip chmod 777 aws-lambda-python-opencv-master cd aws-lambda-python-opencv-master From 1187c39e49204449cd911ea0262be33bdcc5eb49 Mon Sep 17 00:00:00 2001 From: aeddi Date: Wed, 16 Nov 2016 17:21:55 +0100 Subject: [PATCH 02/12] Add .editorconfig file --- .editorconfig | 10 ++++++++++ build.sh | 24 ++++++++++++------------ template.py | 6 +++--- 3 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dde1fec --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +indent_style = tab +indent_size = tab +tab_width = 4 diff --git a/build.sh b/build.sh index e6f95dd..bc6b242 100755 --- a/build.sh +++ b/build.sh @@ -16,18 +16,18 @@ cp -rf build/numpy/lib64/python2.7/site-packages/numpy lambda-package git clone https://github.com/Itseez/opencv.git cd opencv git checkout 3.1.0 - cmake \ - -D CMAKE_BUILD_TYPE=RELEASE \ - -D WITH_TBB=ON \ - -D WITH_IPP=ON \ - -D WITH_V4L=ON \ - -D ENABLE_AVX=ON \ - -D ENABLE_SSSE3=ON \ - -D ENABLE_SSE41=ON \ - -D ENABLE_SSE42=ON \ - -D ENABLE_POPCNT=ON \ - -D ENABLE_FAST_MATH=ON \ - -D BUILD_EXAMPLES=OFF \ + cmake \ + -D CMAKE_BUILD_TYPE=RELEASE \ + -D WITH_TBB=ON \ + -D WITH_IPP=ON \ + -D WITH_V4L=ON \ + -D ENABLE_AVX=ON \ + -D ENABLE_SSSE3=ON \ + -D ENABLE_SSE41=ON \ + -D ENABLE_SSE42=ON \ + -D ENABLE_POPCNT=ON \ + -D ENABLE_FAST_MATH=ON \ + -D BUILD_EXAMPLES=OFF \ -D PYTHON2_NUMPY_INCLUDE_DIRS="$NUMPY" \ . make diff --git a/template.py b/template.py index c3d7d38..3244ffe 100644 --- a/template.py +++ b/template.py @@ -1,8 +1,8 @@ import cv2 def lambda_handler(event, context): - print "OpenCV installed version:", cv2.__version__ - return "It works!" + print "OpenCV installed version:", cv2.__version__ + return "It works!" if __name__ == "__main__": - lambda_handler(42, 42) + lambda_handler(42, 42) From f935e2fe03b86ba66abb68467ccd1db333d4633e Mon Sep 17 00:00:00 2001 From: aeddi Date: Mon, 21 Nov 2016 23:55:03 +0100 Subject: [PATCH 03/12] Abbreviate mkdir command --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index bc6b242..899e8f1 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ # Setting up build env sudo yum update -y sudo yum install -y git cmake gcc-c++ gcc python-devel chrpath -mkdir lambda-package lambda-package/cv2 build build/numpy +mkdir -p lambda-package/cv2 build/numpy # Build numpy pip install --install-option="--prefix=$PWD/build/numpy" numpy From ab3dd7adb07cf6defc636823f1e79905b2a56045 Mon Sep 17 00:00:00 2001 From: aeddi Date: Wed, 21 Dec 2016 15:17:54 +0100 Subject: [PATCH 04/12] Fix small typos --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fb00c38..ef1b4fa 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Python OpenCV module for AWS Lambda -This is a simple script that build a deployment package including OpenCV compatible with the AWS Lambda Python runtime. The dynamic library is compiled with all extended instruction sets supported by Lambda CPU and binaries are stripped to save space. You simply need to add your code inside *lambda_funcion.py* and possibly your haar cascades files or additional Python modules. You can download directly a [pre-built archive](https://github.com/aeddi/aws-lambda-python-opencv/releases/download/Prebuilt/aws-lambda-python-opencv-prebuilt.zip). +This is a simple script that builds a deployment package including OpenCV compatible with the AWS Lambda Python runtime. The dynamic library is compiled with all extended instruction sets supported by Lambda CPU and binaries are stripped to save space. You simply need to add your code inside *lambda_function.py* and possibly your haar cascades files or additional Python modules. You can directly download a [pre-built archive](https://github.com/aeddi/aws-lambda-python-opencv/releases/download/Prebuilt/aws-lambda-python-opencv-prebuilt.zip). - Build duration: ~20 min on T2.micro / ~15 min on C4.2xlarge - Package size without haar cascades included: 26MB -- OpenCV 3.1 by default but may works with newer +- OpenCV 3.1 by default but may work with newer -**Need to be built on an Amazon Linux instance.** +**Needs to be built on an Amazon Linux instance.** ## Module building ### Option 1: with an existing instance @@ -15,12 +15,12 @@ This is a simple script that build a deployment package including OpenCV compati - Launch the script `cd aws-lambda-python-opencv-master && ./build.sh` ### Option 2: without an existing instance -On the EC2 console, launch a new instance with: +In the EC2 console, launch a new instance with: - Amazon Linux AMI - Role with S3 write permission - Shutdown behavior: *Terminate* - Paste the script below in the user data text field -```sh +```bash #!/bin/bash yum update -y yum install -y git cmake gcc-c++ gcc python-devel chrpath From a875121b865deac57471da34118d4b2c83717973 Mon Sep 17 00:00:00 2001 From: aeddi Date: Wed, 21 Dec 2016 15:20:32 +0100 Subject: [PATCH 05/12] Add Simple Mustache Service demo gif --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ef1b4fa..751ed3c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # Python OpenCV module for AWS Lambda +

+ Simple Mustache Service demo
+ Simple Mustache Service is an AWS Lambda demo that use this module +

+ +## Description This is a simple script that builds a deployment package including OpenCV compatible with the AWS Lambda Python runtime. The dynamic library is compiled with all extended instruction sets supported by Lambda CPU and binaries are stripped to save space. You simply need to add your code inside *lambda_function.py* and possibly your haar cascades files or additional Python modules. You can directly download a [pre-built archive](https://github.com/aeddi/aws-lambda-python-opencv/releases/download/Prebuilt/aws-lambda-python-opencv-prebuilt.zip). - Build duration: ~20 min on T2.micro / ~15 min on C4.2xlarge From de13c045c82e72807c30e303792c0517e2f0d68b Mon Sep 17 00:00:00 2001 From: aeddi Date: Wed, 21 Dec 2016 15:21:41 +0100 Subject: [PATCH 06/12] Add LICENSE file --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..884c40b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 - Antoine Eddi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. From 08094121353dda31b9c59de1a68e7e50ad061422 Mon Sep 17 00:00:00 2001 From: aeddi Date: Wed, 21 Dec 2016 16:57:46 +0100 Subject: [PATCH 07/12] Fix small typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 751ed3c..11f44fa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

Simple Mustache Service demo
- Simple Mustache Service is an AWS Lambda demo that use this module + Simple Mustache Service is an AWS Lambda demo that uses this module

## Description From 4dbf628a94b2f8a6ff4a67ab397b8e4a4ae90f3b Mon Sep 17 00:00:00 2001 From: Geoff McIver Date: Fri, 28 Jul 2017 20:38:44 +1200 Subject: [PATCH 08/12] update to 3.2 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 899e8f1..988c131 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ cp -rf build/numpy/lib64/python2.7/site-packages/numpy lambda-package cd build git clone https://github.com/Itseez/opencv.git cd opencv - git checkout 3.1.0 + git checkout 3.2.0 cmake \ -D CMAKE_BUILD_TYPE=RELEASE \ -D WITH_TBB=ON \ From e4ad3c44820c1db1ab13f82458878f99564d3bdc Mon Sep 17 00:00:00 2001 From: Geoff McIver Date: Fri, 28 Jul 2017 21:49:30 +1200 Subject: [PATCH 09/12] updates for 3.2 and for more cpus --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 988c131..9c402d5 100755 --- a/build.sh +++ b/build.sh @@ -30,10 +30,10 @@ cp -rf build/numpy/lib64/python2.7/site-packages/numpy lambda-package -D BUILD_EXAMPLES=OFF \ -D PYTHON2_NUMPY_INCLUDE_DIRS="$NUMPY" \ . - make + make -j`cat /proc/cpuinfo | grep MHz | wc -l` ) cp build/opencv/lib/cv2.so lambda-package/cv2/__init__.so -cp -L build/opencv/lib/*.so.3.1 lambda-package/cv2 +cp -L build/opencv/lib/*.so.3.2 lambda-package/cv2 strip --strip-all lambda-package/cv2/* chrpath -r '$ORIGIN' lambda-package/cv2/__init__.so touch lambda-package/cv2/__init__.py From 6e05e24a0f9a31bfa2756df7c0d82b6e9db2e688 Mon Sep 17 00:00:00 2001 From: Geoff Date: Mon, 31 Jul 2017 10:05:39 +1200 Subject: [PATCH 10/12] Updates to cmake args to not build the tests Added cmake flags to not build the tests or the performance tests. These are not needed and add some time to the build. --- build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sh b/build.sh index 9c402d5..e537d14 100755 --- a/build.sh +++ b/build.sh @@ -28,6 +28,8 @@ cp -rf build/numpy/lib64/python2.7/site-packages/numpy lambda-package -D ENABLE_POPCNT=ON \ -D ENABLE_FAST_MATH=ON \ -D BUILD_EXAMPLES=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_PERF_TESTS=OFF \ -D PYTHON2_NUMPY_INCLUDE_DIRS="$NUMPY" \ . make -j`cat /proc/cpuinfo | grep MHz | wc -l` From b4f7fd09c5fa9508068efc86755b5f32d401ce31 Mon Sep 17 00:00:00 2001 From: Geoff Date: Mon, 31 Jul 2017 10:06:14 +1200 Subject: [PATCH 11/12] Fix comment --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index e537d14..33d15d4 100755 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ mkdir -p lambda-package/cv2 build/numpy pip install --install-option="--prefix=$PWD/build/numpy" numpy cp -rf build/numpy/lib64/python2.7/site-packages/numpy lambda-package -# Build OpenCV 3.1 +# Build OpenCV 3.2 ( NUMPY=$PWD/lambda-package/numpy/core/include cd build From bd80b1867f5a1ea7be24790d8e3f6fe52b94c04a Mon Sep 17 00:00:00 2001 From: aeddi Date: Fri, 8 Sep 2017 13:28:12 +0200 Subject: [PATCH 12/12] Update OpenCV version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11f44fa..1fcd9b2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This is a simple script that builds a deployment package including OpenCV compat - Build duration: ~20 min on T2.micro / ~15 min on C4.2xlarge - Package size without haar cascades included: 26MB -- OpenCV 3.1 by default but may work with newer +- OpenCV 3.2 by default but may work with newer **Needs to be built on an Amazon Linux instance.**