├── .gitignore ├── .travis.yml ├── Dockerfile ├── README.md ├── ascripts ├── myhtml.html └── myphp.php ├── config ├── 000-default.conf ├── apache2.conf └── config.py ├── data └── labels.txt ├── scripts ├── example.sh ├── extract.sh ├── start_and_block.sh └── startup.sh ├── testing ├── pre-commit.sh └── test_build.sh ├── vatic_up.bat └── vatic_up.sh /.gitignore: -------------------------------------------------------------------------------- 1 | ### Project Specific ### 2 | /data/tmp 3 | /data/videos_out 4 | /data/frames_in 5 | 6 | 7 | 8 | 9 | # Created by https://www.gitignore.io/api/osx 10 | ### OSX ### 11 | .DS_Store 12 | .AppleDouble 13 | .LSOverride 14 | 15 | # Icon must end with two \r 16 | Icon 17 | 18 | 19 | # Thumbnails 20 | ._* 21 | 22 | # Files that might appear in the root of a volume 23 | .DocumentRevisions-V100 24 | .fseventsd 25 | .Spotlight-V100 26 | .TemporaryItems 27 | .Trashes 28 | .VolumeIcon.icns 29 | 30 | # Directories potentially created on remote AFP share 31 | .AppleDB 32 | .AppleDesktop 33 | Network Trash Folder 34 | Temporary Items 35 | .apdisk 36 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | 3 | services: 4 | - docker 5 | 6 | script: 7 | - ./testing/test_build.sh --native 8 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:trusty 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y wget git python-setuptools python-dev libavcodec-dev libavformat-dev libswscale-dev libjpeg62 libjpeg62-dev libfreetype6 libfreetype6-dev apache2 libapache2-mod-wsgi mysql-server-5.5 mysql-client-5.5 libmysqlclient-dev gfortran python-pip php5-cgi libapache2-mod-php5 && \ 5 | # the add-apt-repository command isn't included in ubuntu. we'll get it here. 6 | apt-get install -y software-properties-common python-software-properties && \ 7 | add-apt-repository ppa:mc3man/trusty-media -y && \ 8 | apt-get update && \ 9 | apt-get install -y ffmpeg gstreamer0.10-ffmpeg 10 | 11 | RUN sudo pip install SQLAlchemy==1.0.0 && \ 12 | sudo pip install wsgilog==0.3 && \ 13 | sudo pip install cython==0.20 && \ 14 | sudo pip install mysql-python==1.2.5 && \ 15 | sudo pip install munkres==1.0.7 && \ 16 | sudo pip install parsedatetime==1.4 && \ 17 | sudo pip install argparse && \ 18 | sudo pip install numpy==1.9.2 && \ 19 | sudo pip install Pillow 20 | 21 | 22 | RUN cd /root && \ 23 | git clone https://github.com/cvondrick/turkic.git && \ 24 | git clone https://github.com/cvondrick/pyvision.git && \ 25 | git clone https://github.com/cvondrick/vatic.git && \ 26 | cd /root/turkic && \ 27 | sudo python setup.py install && \ 28 | cd /root/pyvision && \ 29 | sudo python setup.py install 30 | 31 | 32 | COPY config/000-default.conf /etc/apache2/sites-enabled/000-default.conf 33 | COPY config/apache2.conf /etc/apache2/apache2.conf 34 | 35 | RUN sudo cp /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled && \ 36 | sudo apache2ctl graceful 37 | 38 | COPY config/config.py /root/vatic/config.py 39 | 40 | # We need to adjust some of these guys's import statements... 41 | RUN sed -i'' "s/import Image/from PIL import Image/" \ 42 | /usr/local/lib/python2.7/dist-packages/pyvision-0.3.1-py2.7-linux-x86_64.egg/vision/frameiterators.py \ 43 | /usr/local/lib/python2.7/dist-packages/pyvision-0.3.1-py2.7-linux-x86_64.egg/vision/ffmpeg.py \ 44 | /usr/local/lib/python2.7/dist-packages/pyvision-0.3.1-py2.7-linux-x86_64.egg/vision/visualize.py \ 45 | /root/vatic/models.py \ 46 | /root/vatic/cli.py \ 47 | /usr/local/lib/python2.7/dist-packages/pyvision-0.3.1-py2.7-linux-x86_64.egg/vision/pascal.py 48 | 49 | RUN sudo /etc/init.d/mysql start && \ 50 | cd /root/vatic && \ 51 | mysql -u root --execute="CREATE DATABASE vatic;" && \ 52 | turkic setup --database && \ 53 | turkic setup --public-symlink 54 | 55 | RUN sudo chown -R 755 /root/vatic/public && \ 56 | find /root -type d -exec chmod 775 {} \; && \ 57 | sudo chmod -R 775 /var/www && \ 58 | apt-get install -y links && \ 59 | apt-get install -y python-scipy && \ 60 | sudo apache2ctl restart 61 | 62 | # Debug tools 63 | RUN apt-get install -y nano w3m man 64 | 65 | COPY ascripts /root/vatic/ascripts 66 | COPY scripts /root/vatic 67 | # moved to the end to make troubleshooting quicker 68 | 69 | # Prepare workspace for use 70 | EXPOSE 80 443 71 | # VOLUME ["/var/www", "/var/log/apache2", "/etc/apache2"] 72 | # ENTRYPOINT ["/root/vatic/startup.sh"] 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vatic-docker [![Build Status](https://github.com/NPSVisionLab/vatic-docker.svg?branch=master)](https://github.com/NPSVisionLab/vatic-docker) 2 | 3 | # vatic-docker - Packaged up Vatic video annotation tool 4 | 5 | ## What is vatic-docker 6 | 7 | Dockerfile and configuration files for using VATIC in a Docker container. Uses the VATIC software located at https://github.com/cvondrick/vatic. This docker container will start an apache web server that will allow you to create annotation labels from within a browser and save those annotations to an xml file. See the VATIC github site for a description of VATIC. Currently "offline mode" is the only mode supported. 8 | 9 | 10 | ## SETUP 11 | 12 | In the directory where you want to run the docker command create a directory called 'data'. In that directory create a directory called 'videos_in'. In the 'videos_in' directory put the video that you want to annotate. 13 | 14 | In the 'data' directory create a text file called 'labels.txt'. Put all the object types that you want to label on the first line seperated by spaces. So for example, if you are going to annotate people and cars put one line in 'labels.txt' that has 'people cars'. 15 | 16 | The 'data' directory is shared by the host and the docker container and it will put the results back into that directory. 17 | 18 | If you are using a docker-machine, you will have to start it and run docker-machine env and configure your env to point to it. 19 | 20 | ## RUNNING 21 | 22 | To start the container run the following command: 23 | 24 | docker run -it -p 8111:80 -v $PWD/data:/root/vatic/data npsvisionlab/vatic-docker /bin/bash -C /root/vatic/example.sh 25 | 26 | Note that $PWD is the parent directory of the data directory and that on windows the format should be "//c/directory_path/data" where c is the drive letter. 27 | Note that 8111 is the port that you will want to direct your browser to. If that port is not available the choose another. 28 | 29 | This will start the apache web server and create image frames from the video located in "videos_in". The frames will be put in "frames_in" and the video will be moved to the folder called "videos_out" 30 | 31 | Find the ip address that the server is running on. If you are using docker-machine, 'docker-machine ip default' will show you ip-address the server is listening on. 32 | 33 | Open up a brower to point to http:/xxxx.xxxx.xxxx.xxxx:8111/directory where the xxxx.xxxx.xxxx.xxxx is the ip-address and 8111 is the port number (if not changed). 34 | 35 | ## ANNOTATING A VIDEO 36 | 37 | When you select one of the video links, it will open a page to allow labeling of the video. The label objects for the objects you can label appear on the right side of the video. These you defined by putting them in a file called labels.txt in the data directory. The labels are space delimited and all on one line. 38 | 39 | After you annotate your videos, you can just hit the button "Output Labels" to save your work. This will save your annotations in labelme format in the file "output.xml" in the data directory. It will also save a copy of the database in the data directory so when you start up another docker session you can continue where you left off. 40 | 41 | When you are done annotating the video just type in c or exit to close the docker container. 42 | 43 | ## Generating Matlab labels 44 | 45 | The software is setup to generate labelme annotation. To generate matlab annotation, copy the myphp.php.matlab to the public/directory/myphp.php file. Then exit the docker terminal and re-run the docker command. Now when you generate the output it will be in matlab format. 46 | -------------------------------------------------------------------------------- /ascripts/myhtml.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 18 | 19 | 20 |
21 |
22 | Click on above links to create/edit annotations of the video. 23 |
24 | Click on the below button once your annotations are done to output to a file called "output.xml". 25 |
26 |
27 | 28 |
30 | -------------------------------------------------------------------------------- /ascripts/myphp.php: -------------------------------------------------------------------------------- 1 | &1; mysqldump -u root --all-databases > data/db.mysql'); 9 | echo $result; 10 | exit(); 11 | 12 | } 13 | ?> 14 | -------------------------------------------------------------------------------- /config/000-default.conf: -------------------------------------------------------------------------------- 1 | WSGIDaemonProcess www-data 2 | WSGIProcessGroup www-data 3 | 4 | 5 | ServerAdmin webmaster@localhost 6 | DocumentRoot /root/vatic/public 7 | 8 | 9 | Options Indexes FollowSymLinks MultiViews Includes ExecCGI 10 | AllowOverride all 11 | Require all granted 12 | Satisfy Any 13 | 14 | 15 | 16 | Options Indexes FollowSymLinks Includes 17 | AllowOverride None 18 | 19 | 20 | 21 | Options Indexes FollowSymLinks MultiViews 22 | AllowOverride None 23 | Require all granted 24 | Require all granted 25 | 26 | 27 | ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 28 | 29 | 30 | Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 31 | Require all granted 32 | Require all granted 33 | 34 | 35 | ErrorLog /etc/apache2/error.log 36 | 37 | LogLevel warn 38 | 39 | CustomLog ${APACHE_LOG_DIR}/access.log combined 40 | WSGIScriptAlias /server /root/vatic/server.py 41 | 42 | Alias /doc/ "/usr/share/doc/" 43 | 44 | 45 | Options Indexes MultiViews FollowSymLinks 46 | AllowOverride None 47 | Allow from 127.0.0.0/255.0.0.0 ::1/128 48 | Require all granted 49 | 50 | 51 | 52 | 53 | 54 | AllowOverride All 55 | 56 | -------------------------------------------------------------------------------- /config/apache2.conf: -------------------------------------------------------------------------------- 1 | # This is the main Apache server configuration file. It contains the 2 | # configuration directives that give the server its instructions. 3 | # See http://httpd.apache.org/docs/2.4/ for detailed information about 4 | # the directives and /usr/share/doc/apache2/README.Debian about Debian specific 5 | # hints. 6 | # 7 | # 8 | # Summary of how the Apache 2 configuration works in Debian: 9 | # The Apache 2 web server configuration in Debian is quite different to 10 | # upstream's suggested way to configure the web server. This is because Debian's 11 | # default Apache2 installation attempts to make adding and removing modules, 12 | # virtual hosts, and extra configuration directives as flexible as possible, in 13 | # order to make automating the changes and administering the server as easy as 14 | # possible. 15 | 16 | # It is split into several files forming the configuration hierarchy outlined 17 | # below, all located in the /etc/apache2/ directory: 18 | # 19 | # /etc/apache2/ 20 | # |-- apache2.conf 21 | # | `-- ports.conf 22 | # |-- mods-enabled 23 | # | |-- *.load 24 | # | `-- *.conf 25 | # |-- conf-enabled 26 | # | `-- *.conf 27 | # `-- sites-enabled 28 | # `-- *.conf 29 | # 30 | # 31 | # * apache2.conf is the main configuration file (this file). It puts the pieces 32 | # together by including all remaining configuration files when starting up the 33 | # web server. 34 | # 35 | # * ports.conf is always included from the main configuration file. It is 36 | # supposed to determine listening ports for incoming connections which can be 37 | # customized anytime. 38 | # 39 | # * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ 40 | # directories contain particular configuration snippets which manage modules, 41 | # global configuration fragments, or virtual host configurations, 42 | # respectively. 43 | # 44 | # They are activated by symlinking available configuration files from their 45 | # respective *-available/ counterparts. These should be managed by using our 46 | # helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See 47 | # their respective man pages for detailed information. 48 | # 49 | # * The binary is called apache2. Due to the use of environment variables, in 50 | # the default configuration, apache2 needs to be started/stopped with 51 | # /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not 52 | # work with the default configuration. 53 | 54 | 55 | # Global configuration 56 | # 57 | 58 | # 59 | # ServerRoot: The top of the directory tree under which the server's 60 | # configuration, error, and log files are kept. 61 | # 62 | # NOTE! If you intend to place this on an NFS (or otherwise network) 63 | # mounted filesystem then please read the Mutex documentation (available 64 | # at ); 65 | # you will save yourself a lot of trouble. 66 | # 67 | # Do NOT add a slash at the end of the directory path. 68 | # 69 | #ServerRoot "/etc/apache2" 70 | 71 | # 72 | # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. 73 | # 74 | Mutex file:${APACHE_LOCK_DIR} default 75 | 76 | # 77 | # PidFile: The file in which the server should record its process 78 | # identification number when it starts. 79 | # This needs to be set in /etc/apache2/envvars 80 | # 81 | PidFile ${APACHE_PID_FILE} 82 | 83 | # 84 | # Timeout: The number of seconds before receives and sends time out. 85 | # 86 | Timeout 300 87 | 88 | # 89 | # KeepAlive: Whether or not to allow persistent connections (more than 90 | # one request per connection). Set to "Off" to deactivate. 91 | # 92 | KeepAlive On 93 | 94 | # 95 | # MaxKeepAliveRequests: The maximum number of requests to allow 96 | # during a persistent connection. Set to 0 to allow an unlimited amount. 97 | # We recommend you leave this number high, for maximum performance. 98 | # 99 | MaxKeepAliveRequests 100 100 | 101 | # 102 | # KeepAliveTimeout: Number of seconds to wait for the next request from the 103 | # same client on the same connection. 104 | # 105 | KeepAliveTimeout 5 106 | 107 | 108 | # These need to be set in /etc/apache2/envvars 109 | User ${APACHE_RUN_USER} 110 | Group ${APACHE_RUN_GROUP} 111 | 112 | # 113 | # HostnameLookups: Log the names of clients or just their IP addresses 114 | # e.g., www.apache.org (on) or 204.62.129.132 (off). 115 | # The default is off because it'd be overall better for the net if people 116 | # had to knowingly turn this feature on, since enabling it means that 117 | # each client request will result in AT LEAST one lookup request to the 118 | # nameserver. 119 | # 120 | HostnameLookups Off 121 | 122 | # ErrorLog: The location of the error log file. 123 | # If you do not specify an ErrorLog directive within a 124 | # container, error messages relating to that virtual host will be 125 | # logged here. If you *do* define an error logfile for a 126 | # container, that host's errors will be logged there and not here. 127 | # 128 | ErrorLog ${APACHE_LOG_DIR}/error.log 129 | 130 | # 131 | # LogLevel: Control the severity of messages logged to the error_log. 132 | # Available values: trace8, ..., trace1, debug, info, notice, warn, 133 | # error, crit, alert, emerg. 134 | # It is also possible to configure the log level for particular modules, e.g. 135 | # "LogLevel info ssl:warn" 136 | # 137 | LogLevel warn 138 | 139 | # Include module configuration: 140 | IncludeOptional mods-enabled/*.load 141 | IncludeOptional mods-enabled/*.conf 142 | 143 | # Include list of ports to listen on 144 | Include ports.conf 145 | 146 | 147 | # Sets the default security model of the Apache2 HTTPD server. It does 148 | # not allow access to the root filesystem outside of /usr/share and /var/www. 149 | # The former is used by web applications packaged in Debian, 150 | # the latter may be used for local directories served by the web server. If 151 | # your system is serving content from a sub-directory in /srv you must allow 152 | # access here, or in any related virtual host. 153 | 154 | Options FollowSymLinks 155 | AllowOverride None 156 | Require all denied 157 | 158 | 159 | 160 | AllowOverride None 161 | Require all granted 162 | 163 | 164 | 165 | Options Indexes FollowSymLinks 166 | AllowOverride None 167 | Require all granted 168 | 169 | 170 | # 171 | # Options Indexes FollowSymLinks 172 | # AllowOverride None 173 | # Require all granted 174 | # 175 | 176 | 177 | 178 | 179 | # AccessFileName: The name of the file to look for in each directory 180 | # for additional configuration directives. See also the AllowOverride 181 | # directive. 182 | # 183 | AccessFileName .htaccess 184 | 185 | # 186 | # The following lines prevent .htaccess and .htpasswd files from being 187 | # viewed by Web clients. 188 | # 189 | 190 | Require all denied 191 | 192 | 193 | 194 | # 195 | # The following directives define some format nicknames for use with 196 | # a CustomLog directive. 197 | # 198 | # These deviate from the Common Log Format definitions in that they use %O 199 | # (the actual bytes sent including headers) instead of %b (the size of the 200 | # requested file), because the latter makes it impossible to detect partial 201 | # requests. 202 | # 203 | # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. 204 | # Use mod_remoteip instead. 205 | # 206 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined 207 | LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined 208 | LogFormat "%h %l %u %t \"%r\" %>s %O" common 209 | LogFormat "%{Referer}i -> %U" referer 210 | LogFormat "%{User-agent}i" agent 211 | 212 | # Include of directories ignores editors' and dpkg's backup files, 213 | # see README.Debian for details. 214 | 215 | # Include generic snippets of statements 216 | IncludeOptional conf-enabled/*.conf 217 | 218 | # Include the virtual host configurations: 219 | IncludeOptional sites-enabled/*.conf 220 | 221 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 222 | 223 | # Adding from Tut 224 | 225 | ServerName localhost 226 | 227 | 228 | Options FollowSymLinks 229 | AllowOverride None 230 | Require all granted 231 | 232 | -------------------------------------------------------------------------------- /config/config.py: -------------------------------------------------------------------------------- 1 | signature = "" # AWS secret access key 2 | accesskey = "" #AWSaccesskeyID 3 | sandbox = True # if true, put on workersandbox.mturk.com 4 | localhost = "http://localhost/" # your local host 5 | database = "mysql://root@localhost/vatic" #server://user:pass@localhost/dbname 6 | geolocation = "" # api key for ipinfodb.com 7 | maxobjects = 25; 8 | 9 | # probably no need to mess below this line 10 | 11 | import multiprocessing processes = multiprocessing.cpu_count() import os.path import sys 12 | sys.path.append(os.path.dirname(os.path.abspath(__file__))) 13 | -------------------------------------------------------------------------------- /data/labels.txt: -------------------------------------------------------------------------------- 1 | ak47 2 | -------------------------------------------------------------------------------- /scripts/example.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Settings 4 | ID=currentvideo 5 | VIDEOPATH=/root/vatic/data/videos_in 6 | ANNOTATEDFRAMEPATH=/root/vatic/data/frames_in 7 | TURKOPS="--offline --title HelloTurk!" 8 | LABEL_FILE=/root/vatic/data/labels.txt 9 | if [ -f "$LABEL_FILE" ] 10 | then 11 | LABELS=`cat $LABEL_FILE` 12 | echo "Labels = $LABELS" 13 | else 14 | echo "!!! data/labels.txt is required !!!!" 15 | echo "This file is a single line space seperated list of label names" 16 | exit 1 17 | fi 18 | 19 | NEWVIDEO=0 20 | OLDVIDEO=0 21 | if [ -d "/root/vatic/data" ] 22 | then 23 | if [ -d ${VIDEOPATH} ] 24 | then 25 | if test "$(ls -A ${VIDEOPATH} 2>/dev/null)" 26 | then 27 | echo "New Videos to process." 28 | NEWVIDEO=1 29 | else 30 | echo "No new videos to process." 31 | fi 32 | fi 33 | fi 34 | if [ -d ${ANNOTATEDFRAMEPATH} ] 35 | then 36 | OLDVIDEO=1 37 | fi 38 | if [ ${NEWVIDEO} -eq 0 -a ${OLDVIDEO} -eq 0 ] 39 | then 40 | echo "!!!No new video or access to previous video's frames!!!" 41 | exit 1 42 | fi 43 | # Start database and server 44 | /root/vatic/startup.sh 45 | 46 | # Convert videos that need to be converted 47 | /root/vatic/extract.sh 48 | 49 | # Set up folders 50 | mkdir -p $ANNOTATEDFRAMEPATH 51 | cd /root/vatic 52 | 53 | # load frames and publish. This will print out access URLs. 54 | turkic load $ID $ANNOTATEDFRAMEPATH $LABELS $TURKOPS 55 | 56 | mkdir -p /root/vatic/public/directory 57 | 58 | if [ -f /root/vatic/data/db.mysql ]; 59 | then 60 | echo "Reading in previous database" 61 | mysql -u root < /root/vatic/data/db.mysql 62 | fi 63 | 64 | # replace the 'localhost' of the output to the host's address, and format it into 65 | # a series of html links. Save this at the /directory page in the website. 66 | { turkic publish --offline |\ 67 | tee /dev/fd/3 | sed "s|http://localhost| Video Segment <\/a>
|" > /root/vatic/public/directory/index.html; } 3>&1 69 | 70 | 71 | # add some user interface controls 72 | #cat $PWD/ascripts/vatic_index.html >> /root/vatic/public/index.html 73 | cat $PWD/ascripts/myhtml.html >> /root/vatic/public/directory/index.html 74 | cp $PWD/ascripts/myphp.php /root/vatic/public/directory 75 | chgrp -R www-data /root/vatic/data 76 | chmod 775 /root/vatic/data 77 | 78 | 79 | # open up a bash shell on the server 80 | 81 | /bin/bash 82 | -------------------------------------------------------------------------------- /scripts/extract.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TODOVIDEOPATH=/root/vatic/data/videos_in 4 | DONEVIDEOPATH=/root/vatic/data/videos_out 5 | FRAMEPATH=/root/vatic/data/frames_in 6 | 7 | mkdir -p $FRAMEPATH 8 | mkdir -p $DONEVIDEOPATH 9 | 10 | cd /root/vatic 11 | for i in $( ls $TODOVIDEOPATH); do 12 | turkic extract $TODOVIDEOPATH/$i $FRAMEPATH --width 720 --height 480 13 | mv $TODOVIDEOPATH/$i $DONEVIDEOPATH/ 14 | done 15 | -------------------------------------------------------------------------------- /scripts/start_and_block.sh: -------------------------------------------------------------------------------- 1 | # This script starts up the webserver and waits indefinately. It's used 2 | # for testing and must be manually terminated. 3 | 4 | ./root/vatic/startup.sh 5 | while true; do sleep 86400; done 6 | -------------------------------------------------------------------------------- /scripts/startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo /etc/init.d/mysql start 4 | apache2ctl start 5 | -------------------------------------------------------------------------------- /testing/pre-commit.sh: -------------------------------------------------------------------------------- 1 | # To ensure that you don't accidentally commit a bad build to the master branch, 2 | # add this to your hooks by running 3 | # 4 | # cp ./testing/pre-commit.sh ./.git/hooks/pre-commit 5 | # chmod +x ./.git/hooks/pre-commit 6 | # 7 | # Since building an image without caching takes between 8 and 9 minutes, this 8 | # script will only run when commiting on the master branch. For quick prototyping, 9 | # create a feature branch and only merge it with master after you're done. 10 | 11 | 12 | echo "Running pre-commit testing scripts" 13 | 14 | protected_branch='master' 15 | current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') 16 | 17 | if [ $current_branch != $protected_branch ]; then 18 | echo "Not on master branch, skipping tests." 19 | exit 0 20 | fi 21 | 22 | ./testing/test_build.sh 23 | -------------------------------------------------------------------------------- /testing/test_build.sh: -------------------------------------------------------------------------------- 1 | # Continuous Integration Script: 2 | # - builds Dockerfile 3 | # - boots server and makes sure it's reachable from the outside 4 | 5 | ################# 6 | ## Testing ## 7 | ################# 8 | 9 | ### Teardown 10 | function teardown { 11 | echo "Shutting down container." 12 | docker stop $JOB 13 | exit 0 14 | } 15 | 16 | ### There should be at least one video in the video_in directory, so that 17 | ### new users can quickly run the example scripts. 18 | if ls ./data/videos_in/*.mp4 1> /dev/null 2>&1; then 19 | echo "Example video found. Continuing." 20 | else 21 | echo 'There must be at least one video in the ./data/videos_in directory when commiting to the master branch.' 22 | exit 1 23 | fi 24 | 25 | ### Check that Dockerfile builds 26 | docker build --no-cache -t jldowns/vatic-docker:test-build . 27 | 28 | echo "Build passes." 29 | 30 | ### Ensure webserver starts up 31 | echo "Starting server.." 32 | JOB=$(\ 33 | docker run -ditP -v "$PWD/data":/root/vatic/data \ 34 | -v "$PWD/annotation_scripts":/root/vatic/ascripts \ 35 | jldowns/vatic-docker:test-build /bin/bash -C /root/vatic/start_and_block.sh \ 36 | ) 37 | PORT=$(docker port $JOB 80 | awk -F: '{ print $2 }') 38 | 39 | if [ $1 = "--native" ]; then 40 | DHOSTIP=localhost 41 | else 42 | DHOSTIP=$(docker-machine ip default) 43 | fi 44 | 45 | 46 | 47 | 48 | echo "Checking webserver at $DHOSTIP:$PORT" 49 | 50 | echo "Waiting for server to boot..." 51 | # check 10 times, give 10 seconds between tries, for a total of 100 seconds 52 | # for the server to boot. 53 | for i in `seq 1 10`; 54 | do 55 | if wget --spider -q "$DHOSTIP:$PORT" > /dev/null; then 56 | echo "Website Found" 57 | teardown 58 | else 59 | echo "Server not found. Retrying in 10 seconds..." 60 | fi 61 | sleep 10 62 | done 63 | 64 | echo "Server not found after 10 tries. Test fails. Shutting down image." 65 | docker stop $JOB 66 | exit 1 67 | -------------------------------------------------------------------------------- /vatic_up.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @setlocal 3 | REM MUST use //c notation for drive letter!! 4 | set MYHOME=//c/Users/tomb/Documents/nps/docker/vatic_docker 5 | set ANNOTATION_SCRIPT=example.sh 6 | if not exist "data\tmp" mkdir data\tmp 7 | 8 | REM docker-machine env 9 | for /f %%i in ('docker run -ditP -v %MYHOME%/data:/root/vatic/data npsvisionlab/vatic-docker /bin/bash -C /root/vatic/%ANNOTATION_SCRIPT%') do set JOB=%%i 10 | for /f %%i in ('docker port %JOB% 80') do set PORT=%%i 11 | set PORT=%PORT:~8% 12 | for /f %%i in ('docker-machine ip default') do set DHOSTIP=%%i 13 | echo "Point browser to : http://%DHOSTIP%:%PORT%/directory" 14 | docker attach %JOB% 15 | -------------------------------------------------------------------------------- /vatic_up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ANNOTATION_SCRIPT=example.sh 4 | 5 | JOB=$(\ 6 | docker run -ditP -v "$PWD/data":/root/vatic/data \ 7 | -v "$PWD/annotation_scripts":/root/vatic/ascripts \ 8 | npsvisionlab/vatic-docker /bin/bash -C /root/vatic/ascripts/$ANNOTATION_SCRIPT \ 9 | ) 10 | 11 | PORT=$(docker port $JOB 80 | awk -F: '{ print $2 }') 12 | DHOSTIP=$(docker-machine ip default) 13 | 14 | echo "Point brower to http://$DHOSTIP:$PORT/directory" 15 | docker attach $JOB 16 | --------------------------------------------------------------------------------