From 61b3810b27ff3aa721b847067ee524cc97cd6eaa Mon Sep 17 00:00:00 2001 From: chiselko6 Date: Sat, 25 Jun 2022 15:47:54 +0200 Subject: [PATCH 1/2] Added autorunner script. Updated path to input/output files --- .gitignore | 3 +++ data/.gitkeep | 0 run.jl | 5 ++++- run.sh | 1 + src/create_mesh.jl | 3 ++- 5 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 data/.gitkeep create mode 100755 run.sh diff --git a/.gitignore b/.gitignore index a45d4bb..4a271cf 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ docs/site/ # committed for packages, but should be committed for applications that require a static # environment. Manifest.toml + +# Files for generation +data/ diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/run.jl b/run.jl index bf33ef8..8d9c563 100644 --- a/run.jl +++ b/run.jl @@ -1,7 +1,10 @@ using Pkg Pkg.activate(".") +Pkg.instantiate() using Images, CausticsEngineering -image = Images.load("./examples/cat_posing.jpg") # Check current working directory with pwd() +const input_file = "./data/input.jpg" + +image = Images.load(input_file) # Check current working directory with pwd() engineer_caustics(image); diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..a9f498f --- /dev/null +++ b/run.sh @@ -0,0 +1 @@ +docker run -it --rm -v $(pwd):/src -w /src julia julia ./run.jl diff --git a/src/create_mesh.jl b/src/create_mesh.jl index ad6c5b6..3de3fdd 100644 --- a/src/create_mesh.jl +++ b/src/create_mesh.jl @@ -1,5 +1,6 @@ # Currently unused. const grid_definition = 512 +const output_file = "./data/output.obj" """ @@ -931,7 +932,7 @@ function engineer_caustics(img) solidMesh = solidify(meshy) saveObj!( solidMesh, - "./examples/original_image.obj", + output_file, scale=1 / 512 * artifactSize, scalez=1 / 512.0 * artifactSize, ) From d13068f5bf0d36d15552d95badfee38d5db7f809 Mon Sep 17 00:00:00 2001 From: chiselko6 Date: Sat, 25 Jun 2022 17:28:59 +0200 Subject: [PATCH 2/2] Added Makefile with build, clean and run targets --- Makefile | 10 ++++++++++ README.md | 31 +++++++++++++++++++++++++++++-- build.jl | 4 ++++ run.jl | 1 - run.sh | 1 - 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 Makefile create mode 100644 build.jl delete mode 100755 run.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3d99b39 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +BUILD_DIR := $(PWD)/build + +build: + @docker run -it --rm -v $(PWD):/src -v $(BUILD_DIR):/root/.julia/ -w /src julia julia ./build.jl + +run: build + @docker run -it --rm -v $(PWD):/src -v $(BUILD_DIR):/root/.julia/ -w /src julia julia ./run.jl + +clean: + rm -r $(BUILD_DIR) diff --git a/README.md b/README.md index 0501627..14730bc 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,40 @@ This repo is for generating 3D surface meshes that project caustic images. It is See the write-up [here](https://mattferraro.dev/posts/caustics-engineering)! -# To Run +# To Run from source To run the cat example from the blogpost, run line by line from ` src/scratchpad.jl`. _OR_ from the command line. ``` -julia ./run.jl" +julia ./run.jl ``` The image file is currently hard-coded. + +# To Run in docker + +In this case you don't have install Julia locally - instead you will be able to build and run the project in a docker container. +To do that, follow the guide: + +1. Put your source image to `data/input.jpg`. This is the file the project will process. +1. Clean your build (you can omit this step if you are running the code for the first time). +It is required if you modify your source code only (changing input image doesn't require to execute this step): + + ```sh + make clean + ``` + +1. Build the project: + + ```sh + make build + ``` + +1. Run the project: + + ```sh + make run + ``` + +1. Find your output in `data/output.obj`. diff --git a/build.jl b/build.jl new file mode 100644 index 0000000..b62f261 --- /dev/null +++ b/build.jl @@ -0,0 +1,4 @@ +using Pkg +Pkg.activate(".") +Pkg.instantiate() + diff --git a/run.jl b/run.jl index 8d9c563..5a5c1da 100644 --- a/run.jl +++ b/run.jl @@ -1,6 +1,5 @@ using Pkg Pkg.activate(".") -Pkg.instantiate() using Images, CausticsEngineering diff --git a/run.sh b/run.sh deleted file mode 100755 index a9f498f..0000000 --- a/run.sh +++ /dev/null @@ -1 +0,0 @@ -docker run -it --rm -v $(pwd):/src -w /src julia julia ./run.jl