Skip to content

Commit

Permalink
demo prepared, missing results
Browse files Browse the repository at this point in the history
  • Loading branch information
freerafiki committed Jun 15, 2023
1 parent c77a322 commit c3dd68d
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# processing files
*.out
*.txt
libs.txt
*.obj

#3dFiles
Expand Down
4 changes: 0 additions & 4 deletions 3dvr_results/3dvr_30000/info.json

This file was deleted.

10 changes: 0 additions & 10 deletions 3dvr_results/3dvr_30000/registration/best_registration.csv

This file was deleted.

This file was deleted.

13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ The data collection process from the RePAIR project is yet to be finished and th
However, the code can be easily modified to work with different kind of data (it uses pointcloud, but resampling a mesh in a pointcloud is easy and you find an example in the `prepare_challenge.py` script if needed).
If there are issues or you need help, please do open an issue and ask.

## How do I use the code?

If you want to use it on your own data, check the [data preparation section](#data-preparation).

If you want to assemble fragments (you have prepared data), check the [assembling fragment section](#assembling-fragments).

If you have no idea, check the [demo file](demo.md) for a quick run (everything is prepared).

## Data preparation
If you already have the pointclouds of the broken objects in some random position, you can skip this part.

Expand Down Expand Up @@ -82,13 +90,18 @@ We created a script for the assembly, which can be run as:
```bash
python assemble_fragments.py --cfg assemble_cfg
```

This will assemble all the broken objects and create a lot (maybe too much? The call to the saving functions (detached from the computational one for ease of use) are easy to disable, check the code in `assemble_fragments.py` and look for `fr_ass.save_`)

The results will be in the output folder (check the name, line 19 of `configs/assembly_cfg.py` file) and will contain segmented data (colored) registered data and a copy of the pointcloud (and also colored borders) so you should be able to easily visualize all intermediate steps (if you have no idea, use Meshlab to visualize `.ply` files)

**Why before a `.yaml` file and now a `.py` file as config (with different syntax)?**
They were created at different times, and the `.py` file is very useful to create nested folders. They are relatively easy to use so it should be possible to understand both, sorry for the change`.

## Demo Run

There is a *demo* run prepared. Check the [demo file](demo.md) for more info.

# 4) Known Issues

The repo contains *a lot* of experiments, which will be organized with time. Use the scripts mentioned above for a guaranteed execution and use the rest of the code at your own risk.
Expand Down
5 changes: 4 additions & 1 deletion assemble_fragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import importlib
import pdb
from runner import fragment_reassembler
import os

def main(args):

Expand Down Expand Up @@ -30,7 +31,9 @@ def main(args):
fr_ass.load_objects()

# set output directory, save fragments and information there
fr_ass.set_output_dir(cfg.output_dir)
broken_objects_out_dir = os.path.join(cfg.output_dir, name)
os.makedirs(broken_objects_out_dir, exist_ok=True)
fr_ass.set_output_dir(broken_objects_out_dir)
fr_ass.save_fragments(cfg.name)
fr_ass.save_info()

Expand Down
67 changes: 67 additions & 0 deletions demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Demo run for 3DVR 2023

We prepared a couple of examples for reassembly.

The data is taken from the [breaking bad dataset](https://breaking-bad-dataset.github.io/) and is preprocessed in `data/DrinkBottle` and we have `fractured_62` and `fractured_70`.

If you run (after having installed everything) the `assemble_fragments` script:

```bash
python assemble_fragments.py --cfg assemble_cfg
```

You should get an output similar to:

```bash
> python assemble_fragments.py --cfg assemble_cfg

Will try to assemble:
0) DrinkBottle_fractured_70
1) DrinkBottle_fractured_62

#################################################################
Current broken object: fractured_70 (DrinkBottle)
-----------------------------------------------------------------
Loading object 1: data/DrinkBottle/fractured_70/objects/obj1_challenge.ply
100%|███████████████████████████████████████████████████████████████████████████| 29950/29950 [00:04<00:00, 6008.02it/s]
Loading object 2: data/DrinkBottle/fractured_70/objects/obj2_challenge.ply
100%|███████████████████████████████████████████████████████████████████████████| 29909/29909 [00:04<00:00, 6066.83it/s]
done
-----------------------------------------------------------------
Detecting breaking curves for object 1..
Creating point cloud graph..

```

And it will continue (after breaking curves there is segmentation and registration..).
It may take a while (depending on computer).
The segmentation step is the slowest at the moment, and it may take some minutes.
The runtime changed a lot on different computers, from some minutes to almost half an hour.

This will create an output folder, whose name is decided in `configs/assemble_cfg.py`, as:
```python
name = f'3dvr_{num_of_points}'
output_dir = os.path.join('3dvr_results', name)
os.makedirs(output_dir, exist_ok=True)
```

Feel free to change the name, of course.

In the output folder you will see:
- `pointclouds` folder (with pointcloud in initial position)
- `segmented_parts` folder (with segmented parts divided)
- `registration` folder (with pointcloud in final position plus the transformation in a `.csv` file)
- `borders_objN_challenge.ply`, the pointcloud containing only the breaking curves
- `col_borders_objN_challenge.ply`, a visualization with the full pointcloud and the breaking curves colored
- `col_regions_objN_challenge.ply`, a visualization with the full pointcloud and the segmented regions colored
- `info.json` a file with information (nothing interesting at the moment)

If you visualize (here screenshots from Meshlab) the results you should see something like this:

| Initial position (in `pointclouds`) | After assembly (in `registration`) |
|:---:|:----:|
| ![demo position](static/images/demo_position.png) | ![demo position](static/images/demo_solved.png) |

A demo result is saved in `3dvr_results/demo_results`, but you can do it on your pc to test it!


6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numpy
scipy
open3d
matplotlib
tqdm
scikit-learn

0 comments on commit c3dd68d

Please sign in to comment.