Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockeriseation #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
node_modules
npm-debug.log
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
.env
*/bin
*/obj
README.md
LICENSE
.vscode
*/aura-props
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*~
*.pyc
**.vscode
**/aura-props
**/tmp
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Builds an environment that runs the image analysis direct georeferecing tool set.

FROM continuumio/anaconda3:latest
LABEL Name=imageanalysis Version=0.1

ENV PATH /opt/conda/bin/
SHELL ["/bin/bash", "-c"]

# Define the working dir where to put all the source code
WORKDIR /app
# And the location of where to link the images when mounting the volume that holds the images, camera JSON and
VOLUME [ "/data" ]

# Update conda if required
RUN conda update conda

# Install all the required packages
RUN pip install opencv-python opencv-utils opencv-contrib-python==3.4.2.17 && \
pip install navpy piexif geojson panda3d pylint rope matplotlib

# Download the required props package
ADD https://github.com/AuraUAS/aura-props/archive/master.zip /app/

# extract the compressed files and install
RUN python -m zipfile -e /app/master.zip /app/ && \
cd aura-props-master/python && \
python setup.py install

# Add the source code last to ensure that the rebuild is as quick as possible
ADD . /app

ENTRYPOINT ["/bin/bash", "-c"]
CMD cd /app

# To run, use the following commands:
# docker run -d --name imageanalysis -v location/on/your/computer:/data imageanalysis
# docker exec -it imageanalysis /bin/bash

# When in the container, you can navigate to the project runner dir and run with the following:
# cd scripts
# python project_runner.py --project /data --camera /app/cameras/DJI_FC330.json --pix4d /data/pix4d.csv
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,22 @@ Wish list items:
## installation hints

- sudo pip3 install opencv-contrib-python
- sudo pip3 install --pre --extra-index-url https://archive.panda3d.org/ panda3d
- sudo pip3 install --pre --extra-index-url https://archive.panda3d.org/ panda3d

## Run with Docker

When you clone the repo, you can then build the docker image and run from inside of the docker image with the following commands:

````{.shell}
docker run -d --name imageanalysis -v location/on/your/computer:/data imageanalysis
docker exec -it imageanalysis /bin/bash
````

Ensure that you change ```location/on/your/computer``` to a location that holds all of your images, and the pix4d.csv file

When in the container, you can navigate to the project runner dir and run with the following:

````{.shell}
cd scripts
python project_runner.py --project /data --camera /app/cameras/DJI_FC330.json --pix4d /data/pix4d.csv
````
28 changes: 28 additions & 0 deletions cameras/DJI_FC330.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"K": [
3666.666504,
0.0,
2432.0,
0.0,
3666.666504,
1824.0,
0.0,
0.0,
1.0
],
"ccd_height_mm": 4.72,
"ccd_width_mm": 6.30,
"dist_coeffs": [
0.0,
0.0,
0.0,
0.0,
0.0
],
"focal_len_mm": 4,
"height_px": 3000,
"lens_model": "unknown",
"make": "DJI",
"model": "FC330",
"width_px": 4000
}
8 changes: 8 additions & 0 deletions docker-compose.debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '2.1'

services:
imageanalysis:
image: imageanalysis
build:
context: .
dockerfile: Dockerfile
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '2.1'

services:
imageanalysis:
image: imageanalysis
build: .
ports:
- 3000:3000
25 changes: 0 additions & 25 deletions scripts/1a-create-project.py

This file was deleted.

25 changes: 25 additions & 0 deletions scripts/1a_create_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/python3

import os, sys, argparse

from lib import ProjectMgr

# initialize a new project workspace
def new_project(project_dir):
# test if images directory exists
if not os.path.isdir(project_dir):
print("Images directory doesn't exist:", args.project)
quit()

# create an empty project
proj = ProjectMgr.ProjectMgr(project_dir, create=True)

# and save what we have so far ...
proj.save()

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Create an empty project.')
parser.add_argument('--project', required=True, help='Directory with a set of aerial images.')

args = parser.parse_args()
new_project(args.project)
72 changes: 0 additions & 72 deletions scripts/1b-set-camera-config.py

This file was deleted.

74 changes: 74 additions & 0 deletions scripts/1b_set_camera_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/python3

import argparse
import fnmatch
import os.path

# from the aura-props package
from props import getNode, PropertyNode
import props_json

from lib import ProjectMgr


def set_camera(project_dir, camera, yaw_deg = 0.0, pitch_deg = -90.0, roll_deg = 0.0):
proj = ProjectMgr.ProjectMgr(project_dir)

if camera:
# specified on command line
camera_file = camera
else:
# auto detect camera from image meta data
camera, make, model, lens_model = proj.detect_camera()
camera_file = os.path.join("..", "cameras", camera + ".json")
print("Camera:", camera_file)

# copy/overlay/update the specified camera config into the existing
# project configuration
cam_node = getNode('/config/camera', True)
tmp_node = PropertyNode()
if props_json.load(camera_file, tmp_node):
for child in tmp_node.getChildren(expand=False):
if tmp_node.isEnum(child):
# print(child, tmp_node.getLen(child))
for i in range(tmp_node.getLen(child)):
cam_node.setFloatEnum(child, i, tmp_node.getFloatEnum(child, i))
else:
# print(child, type(tmp_node.__dict__[child]))
child_type = type(tmp_node.__dict__[child])
if child_type is float:
cam_node.setFloat(child, tmp_node.getFloat(child))
elif child_type is int:
cam_node.setInt(child, tmp_node.getInt(child))
elif child_type is str:
cam_node.setString(child, tmp_node.getString(child))
else:
print('Unknown child type:', child, child_type)

proj.cam.set_mount_params(yaw_deg, pitch_deg, roll_deg)

# note: dist_coeffs = array[5] = k1, k2, p1, p2, k3

# ... and save
proj.save()
else:
# failed to load camera config file
if not camera:
print("Camera autodetection failed.")
print("Consider running the new camera script to create a camera config")
print("and then try running this script again.")
else:
print("Provided camera config not found:", camera)

if __name__ == "__main__":
# set all the various camera configuration parameters
parser = argparse.ArgumentParser(description='Set camera configuration.')
parser.add_argument('--project', required=True, help='project directory')
parser.add_argument('--camera', help='camera config file')
parser.add_argument('--yaw-deg', type=float, default=0.0,
help='camera yaw mounting offset from aircraft')
parser.add_argument('--pitch-deg', type=float, default=-90.0,
help='camera pitch mounting offset from aircraft')
parser.add_argument('--roll-deg', type=float, default=0.0,
help='camera roll mounting offset from aircraft')
args = parser.parse_args()
58 changes: 0 additions & 58 deletions scripts/2a-set-poses.py

This file was deleted.

Loading