Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Commit 74ad405

Browse files
committed
add Install-OpenCV
1 parent 480c536 commit 74ad405

File tree

6 files changed

+124
-12
lines changed

6 files changed

+124
-12
lines changed

Dockerfile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
# Inherit from Heroku's python stack
22
FROM heroku/python
33

4-
# Install OpenCV by https://github.com/jayrambhia/Install-OpenCV
4+
# Install OpenCV
55
RUN mkdir -p /app/.heroku/opencv /tmp/opencv
6-
WORKDIR /tmp/opencv
7-
RUN git clone https://github.com/jayrambhia/Install-OpenCV
8-
WORKDIR Install-OpenCV/Ubuntu
9-
# Modify install scripts...
10-
RUN sed -i 's/sudo //g' *.sh
11-
RUN sed -i 's/BUILD_NEW_PYTHON_SUPPORT=ON/BUILD_opencv_python2=ON -D PYTHON_INCLUDE_DIR=\/app\/.heroku\/python\/include\/python2.7/' opencv_install.sh
12-
RUN sed -i 's/make install/make DESTDIR=\/app\/.heroku\/opencv install/' opencv_install.sh
13-
# Install
6+
ADD Install-OpenCV /tmp/opencv
7+
WORKDIR /tmp/opencv/Ubuntu
148
RUN echo 'deb http://archive.ubuntu.com/ubuntu trusty multiverse' >> /etc/apt/sources.list
159
RUN apt-get update
1610
RUN ./opencv_latest.sh
17-
RUN echo "/app/.heroku/opencv/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf
18-
RUN ldconfig
19-
RUN ln /dev/null /dev/raw1394
11+
12+
# Python environment
13+
RUN echo 'export PYTHONPATH=${PYTHONPATH:-/app/.heroku/opencv/lib/python2.7/site-packages}' > /app/.profile.d/opencv.sh

Install-OpenCV/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Install-OpenCV
2+
==============
3+
4+
Copied from [https://github.com/jayrambhia/Install-OpenCV](https://github.com/jayrambhia/Install-OpenCV)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
echo "--- Removing any pre-installed ffmpeg and x264"
4+
apt-get -qq remove ffmpeg x264 libx264-dev
5+
6+
function install_dependency {
7+
echo "--- Installing dependency: $1"
8+
apt-get -y install $1
9+
}
10+
11+
install_dependency libopencv-dev
12+
install_dependency build-essential
13+
install_dependency checkinstall
14+
install_dependency cmake
15+
install_dependency pkg-config
16+
install_dependency yasm
17+
install_dependency libtiff5-dev
18+
install_dependency libjpeg-dev
19+
install_dependency libjasper-dev
20+
install_dependency libavcodec-dev
21+
install_dependency libavformat-dev
22+
install_dependency libswscale-dev
23+
install_dependency libdc1394-22-dev
24+
install_dependency libxine2-dev
25+
install_dependency libgstreamer0.10-dev
26+
install_dependency libgstreamer-plugins-base0.10-dev
27+
install_dependency libv4l-dev
28+
install_dependency python-dev
29+
install_dependency python-numpy
30+
install_dependency libtbb-dev
31+
install_dependency libqt4-dev
32+
install_dependency libgtk2.0-dev
33+
install_dependency libfaac-dev
34+
install_dependency libmp3lame-dev
35+
install_dependency libopencore-amrnb-dev
36+
install_dependency libopencore-amrwb-dev
37+
install_dependency libtheora-dev
38+
install_dependency libvorbis-dev
39+
install_dependency libxvidcore-dev
40+
install_dependency x264
41+
install_dependency v4l-utils
42+
#install_dependency ffmpeg
43+
install_dependency unzip
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# Dan Walkes
3+
# 2014-01-29
4+
# Call this script after configuring variables:
5+
# version - the version of OpenCV to be installed
6+
# downloadfile - the name of the OpenCV download file
7+
# dldir - the download directory (optional, if not specified creates an OpenCV directory in the working dir)
8+
if [[ -z "$version" ]]; then
9+
echo "Please define version before calling `basename $0` or use a wrapper like opencv_latest.sh"
10+
exit 1
11+
fi
12+
if [[ -z "$downloadfile" ]]; then
13+
echo "Please define downloadfile before calling `basename $0` or use a wrapper like opencv_latest.sh"
14+
exit 1
15+
fi
16+
if [[ -z "$dldir" ]]; then
17+
dldir=OpenCV
18+
fi
19+
set -e
20+
21+
echo "--- Installing OpenCV" $version
22+
23+
echo "--- Installing Dependencies"
24+
source dependencies.sh
25+
26+
echo "--- Downloading OpenCV" $version
27+
mkdir -p $dldir
28+
cd $dldir
29+
wget -O $downloadfile http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$downloadfile/download
30+
31+
echo "--- Installing OpenCV" $version
32+
echo $downloadfile | grep ".zip"
33+
if [ $? -eq 0 ]; then
34+
unzip $downloadfile
35+
else
36+
tar -xvf $downloadfile
37+
fi
38+
cd opencv-$version
39+
mkdir build
40+
cd build
41+
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/app/.heroku/opencv -D WITH_TBB=ON -D BUILD_opencv_python2=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_OPENGL=ON -D PYTHON_INCLUDE_DIR=/app/.heroku/python/include/python2.7 -D WITH_1394=OFF ..
42+
make -j 4
43+
make install
44+
sh -c 'echo "/app/.heroku/opencv/lib" > /etc/ld.so.conf.d/opencv.conf'
45+
ldconfig
46+
echo "OpenCV" $version "ready to be used"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
. `dirname $0`/../get_latest_version_download_file.sh
3+
if [ $? -ne 0 ]; then
4+
exit $?;
5+
fi
6+
. `dirname $0`/opencv_install.sh
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Dan Walkes
2+
# 2014-01-29
3+
# Find the latest version and download file link from the OpenCV sourceforge page
4+
5+
version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9]+)+(-[-a-zA-Z0-9]+)?' | cut -c2-)"
6+
downloadfilelist="opencv-$version.tar.gz opencv-$version.zip"
7+
downloadfile=
8+
for file in $downloadfilelist;
9+
do
10+
wget --spider http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$file/download
11+
if [ $? -eq 0 ]; then
12+
downloadfile=$file
13+
fi
14+
done
15+
if [ -z "$downloadfile" ]; then
16+
echo "Could not find download file on sourceforge page. Please find the download file for version $version at"
17+
echo "http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/ and update this script"
18+
exit 1
19+
fi

0 commit comments

Comments
 (0)