add an example of dockerfile for building opencv
This commit is contained in:
46
Readme.md
46
Readme.md
@@ -214,11 +214,44 @@ https://github.com/barais/ESIRTPDockerSampleApp (Une documentation pour compiler
|
|||||||
|
|
||||||
Construisez le fichier docker file permettant de créer l'image docker pour cette application.
|
Construisez le fichier docker file permettant de créer l'image docker pour cette application.
|
||||||
|
|
||||||
Vous aurez besoin de construire open cv depuis les src (principalement depuis la version 3.4)
|
|
||||||
|
Je vous fournis une version compilé de la librairie opencv (en 64 bit) et du jar d'opencv.
|
||||||
|
Pour faire tourner votre application. Installer le jar d'open CV.
|
||||||
|
|
||||||
|
Pour faire tourner dans kadacoda
|
||||||
|
```bash
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y openjdk-8-jdk
|
||||||
|
apt-get install -y maven
|
||||||
|
apt-get install -f libpng16-16
|
||||||
|
apt-get install -f libjasper1
|
||||||
|
apt-get install -f libdc1394-22
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn install:install-file -Dfile=./lib/opencv-3410.jar \
|
||||||
|
-DgroupId=org.opencv -DartifactId=opencv -Dversion=3.4.10 -Dpackaging=jar
|
||||||
|
```
|
||||||
|
|
||||||
|
Lancez cette application.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn package
|
||||||
|
java -Djava.library.path=lib/ -jar target/fatjar-0.0.1-SNAPSHOT.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
Construisez un fichier dockerfile permettant de créer une image docker permettant de lancer cette application.
|
||||||
|
Vous aurez besoin d'ajoutez le répertoire *lib* et le répertoire *haarcascades* à votre image.
|
||||||
|
|
||||||
|
Nous souhaitons faire en sorte de fournir une image docker finale la plus petite possible. (Un paquet de carambar à la plus petite image fonctionnelle)
|
||||||
|
|
||||||
|
|
||||||
|
**Version longue (non obligatoire)**
|
||||||
|
|
||||||
|
Si l'on voulait vraiment être reproductible, vous auriez besoin de construire open cv depuis les src (principalement depuis la version 3.4)
|
||||||
|
|
||||||
https://github.com/opencv/opencv
|
https://github.com/opencv/opencv
|
||||||
|
|
||||||
|
|
||||||
Tester le lancement de cette image.
|
Tester le lancement de cette image.
|
||||||
|
|
||||||
Vous pourrez utiliser cette documentation pour la compilation d'opencv sur ubuntu.
|
Vous pourrez utiliser cette documentation pour la compilation d'opencv sur ubuntu.
|
||||||
@@ -227,14 +260,13 @@ https://advancedweb.hu/2016/03/01/opencv_ubuntu/
|
|||||||
|
|
||||||
N'oubliez pas d'installer ant au sein de votre image docker ainsi que la jvm et maven.
|
N'oubliez pas d'installer ant au sein de votre image docker ainsi que la jvm et maven.
|
||||||
|
|
||||||
|
|
||||||
Nous souhaitons faire en sorte de fournir une image docker finale la plus petite possible. (Un paquet de carambar à la plus petite image fonctionnelle)
|
Nous souhaitons faire en sorte de fournir une image docker finale la plus petite possible. (Un paquet de carambar à la plus petite image fonctionnelle)
|
||||||
|
|
||||||
Fournissez donc deux fichiers docker file, un premier pour construire l'image qui permet de compiler opencv et compiler votre application. Un deuxième qui permet de construire l'image minimale pour votre application.
|
Fournissez donc deux fichiers docker file, un premier pour construire l'image qui permet de compiler opencv et compiler votre application. Un deuxième qui permet de construire l'image minimale pour votre application.
|
||||||
|
|
||||||
### Etape 4: Dockeriser une application existante
|
### Etape 4: Dockeriser une application existante
|
||||||
|
|
||||||
Fournir un docker file qui permet de mettre en place une application avec 4 instance de votre serveur Web.
|
Fournir un docker compose qui permet de mettre en place une application avec 4 instances de votre serveur Web.
|
||||||
|
|
||||||
|
|
||||||
### Etape 5: Dockeriser une application existante
|
### Etape 5: Dockeriser une application existante
|
||||||
@@ -263,7 +295,7 @@ OpenCV is a native library with Java bindings so you need to install this to you
|
|||||||
There are good instructions how to build OpenCV with Java bindings for your own platform here: http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html
|
There are good instructions how to build OpenCV with Java bindings for your own platform here: http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html
|
||||||
|
|
||||||
Once you have built the Java library you can install the resulting jar file to your local Maven repository using
|
Once you have built the Java library you can install the resulting jar file to your local Maven repository using
|
||||||
mvn install:install-file -Dfile=./bin/opencv-346.jar \
|
mvn install:install-file -Dfile=./lib/opencv-346.jar \
|
||||||
-DgroupId=org.opencv -DartifactId=opencv -Dversion=3.4.6 -Dpackaging=jar
|
-DgroupId=org.opencv -DartifactId=opencv -Dversion=3.4.6 -Dpackaging=jar
|
||||||
|
|
||||||
|
|
||||||
@@ -274,10 +306,10 @@ Once OpenCV jar library is available as a local Maven dependency, you can clone
|
|||||||
|
|
||||||
mvn install
|
mvn install
|
||||||
|
|
||||||
And run the application using the embedded Jetty plugin in http://localhost:8888
|
And run the application using the embedded Jetty plugin in http://localhost:8080
|
||||||
|
|
||||||
mvn package
|
mvn package
|
||||||
java -Djava.library.path=/home/barais/git/opencv/build/lib/ -jar target/fatjar-0.0.1-SNAPSHOT.jar
|
java -Djava.library.path=lib/ -jar target/fatjar-0.0.1-SNAPSHOT.jar
|
||||||
# Do not forget to update the path to your opencv install in Main.java
|
# Do not forget to update the path to your opencv install in Main.java
|
||||||
# You can change the image trollface ;)
|
# You can change the image trollface ;)
|
||||||
|
|
||||||
|
|||||||
45
dockeropencv/Dockerfile
Normal file
45
dockeropencv/Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
FROM ubuntu:16.04 AS ubuntu
|
||||||
|
|
||||||
|
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
|
||||||
|
|
||||||
|
RUN apt update && \
|
||||||
|
# install required tools
|
||||||
|
apt install -y git unzip ant build-essential \
|
||||||
|
cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev \
|
||||||
|
python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev \
|
||||||
|
python3 python3-dev python3-numpy \
|
||||||
|
software-properties-common debconf-utils && \
|
||||||
|
# install openjdk-8
|
||||||
|
apt install -y openjdk-8-jdk && \
|
||||||
|
# libjasper-dev
|
||||||
|
curl -fs http://security.ubuntu.com/ubuntu/pool/main/j/jasper/libjasper1_1.900.1-debian1-2.4ubuntu1.2_amd64.deb -o /tmp/libjasper1.deb && \
|
||||||
|
curl -fs http://security.ubuntu.com/ubuntu/pool/main/j/jasper/libjasper-dev_1.900.1-debian1-2.4ubuntu1.2_amd64.deb -o /tmp/libjasper-dev.deb && \
|
||||||
|
apt install /tmp/libjasper1.deb /tmp/libjasper-dev.deb && \
|
||||||
|
rm -rf /tmp/* && \
|
||||||
|
# download and prepare opencv
|
||||||
|
curl -fsL https://github.com/opencv/opencv/archive/3.4.10.zip -o /tmp/opencv.zip && \
|
||||||
|
cd /tmp && \
|
||||||
|
unzip opencv.zip && \
|
||||||
|
mv opencv-* opencv && \
|
||||||
|
cd opencv && \
|
||||||
|
mkdir build && \
|
||||||
|
# build opencv
|
||||||
|
cd /tmp/opencv/build && \
|
||||||
|
cmake \
|
||||||
|
-D CMAKE_BUILD_TYPE=Release \
|
||||||
|
-D CMAKE_INSTALL_PREFIX=/usr/local \
|
||||||
|
-D WITH_FFMPEG=OFF \
|
||||||
|
-D WITH_IPP=OFF \
|
||||||
|
-D WITH_OPENEXR=OFF \
|
||||||
|
-D BUILD_EXAMPLES=OFF \
|
||||||
|
-D BUILD_ANDROID_EXAMPLES=OFF \
|
||||||
|
-D INSTALL_PYTHON_EXAMPLES=OFF \
|
||||||
|
-D BUILD_DOCS=OFF \
|
||||||
|
-D BUILD_opencv_python2=OFF \
|
||||||
|
-D BUILD_opencv_python3=OFF \
|
||||||
|
-D BUILD_SHARED_LIBS=OFF \
|
||||||
|
-D BUILD_TESTS=OFF \
|
||||||
|
-D BUILD_PERF_TESTS=OFF \
|
||||||
|
.. && \
|
||||||
|
make -j8
|
||||||
|
#RUN cd /tmp/opencv/build && make install
|
||||||
Reference in New Issue
Block a user