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

Run the project in a docker container #17

Open
wants to merge 2 commits into
base: main
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
4 changes: 4 additions & 0 deletions build.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using Pkg
Pkg.activate(".")
Pkg.instantiate()

Empty file added data/.gitkeep
Empty file.
4 changes: 3 additions & 1 deletion run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ Pkg.activate(".")

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);
3 changes: 2 additions & 1 deletion src/create_mesh.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Currently unused.
const grid_definition = 512
const output_file = "./data/output.obj"


"""
Expand Down Expand Up @@ -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,
)
Expand Down