File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Setting up build env
4+ yum update -y
5+ yum install -y git cmake gcc-c++ gcc python-devel chrpath
6+ mkdir lambda-package build
7+
8+ # Build numpy
9+ pip install --install-option=" --prefix=$PWD /build" numpy
10+ mv build/lib64/python2.7/site-packages/numpy lambda-package
11+
12+ # Build OpenCV 3.1
13+ (
14+ NUMPY=$PWD /lambda-package/numpy/core/include
15+ cd build
16+ git clone https://github.com/Itseez/opencv.git
17+ cd opencv
18+ git checkout 3.1.0
19+ cmake \
20+ -D CMAKE_BUILD_TYPE=RELEASE \
21+ -D WITH_TBB=ON \
22+ -D WITH_IPP=ON \
23+ -D WITH_V4L=ON \
24+ -D ENABLE_AVX=ON \
25+ -D ENABLE_SSE42=ON \
26+ -D ENABLE_POPCNT=ON \
27+ -D ENABLE_FAST_MATH=ON \
28+ -D BUILD_EXAMPLES=OFF \
29+ -D PYTHON2_NUMPY_INCLUDE_DIRS=" $NUMPY " \
30+ .
31+ make
32+ )
33+ mkdir lambda-package/cv2
34+ cp ` find opencv/lib " *.so*" -type f` lambda-package/cv2
35+ strip --strip-all lambda-package/cv2/*
36+ chrpath -r ' $ORIGIN' lambda-package/cv2/cv2.so
37+ cp ressources/__init.py__ lambda-package/cv2
38+
39+ # Copy template function and zip package
40+ cp ressources/template.py lambda-package/lambda_function.py
41+ zip -r lambda-package.zip lambda-package/*
Original file line number Diff line number Diff line change 1+ import pkg_resources
2+ import imp
3+
4+ __file__ = pkg_resources .resource_filename (__name__ , "cv2.so" )
5+ imp .load_dynamic (__name__ , __file__ )
Original file line number Diff line number Diff line change 1+ import cv2
2+
3+ def lambda_handler (event , context ):
4+ print "OpenCV installed version:" , cv2 .__version__
5+ return "It works!"
6+
7+ if __name__ == "__main__" :
8+ lambda_handler (42 , 42 )
You can’t perform that action at this time.
0 commit comments