Skip to content

Commit

Permalink
Merge pull request #26 from MrClock8163/master
Browse files Browse the repository at this point in the history
Add Meshroom output type
  • Loading branch information
zsiki authored Nov 12, 2023
2 parents 499fe89 + f0f030f commit 6b8c542
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ options:
-d DICT, --dict DICT marker dictionary id, default=1 (DICT_4X4_100)
-o OUTPUT, --output OUTPUT
name of output GCP list file, default stdout
-t {ODM,VisualSfM}, --type {ODM,VisualSfM}
-t {ODM,VisualSfM,Meshroom}, --type {ODM,VisualSfM,Meshroom}
target program ODM or VisualSfM, default
-i INPUT, --input INPUT
name of input GCP coordinate file, default None
Expand Down Expand Up @@ -235,7 +235,6 @@ This small program lists GPS position from exif information of images to the sta

```
Usage: ./exif_pos.py image_file(s)
```

Sample output of the program:
Expand Down Expand Up @@ -479,3 +478,30 @@ marker ids: [0, 1, 1, 2, 3, 4, 5, 6, 7, 28]
```

At 2584,64 on image DJI_0180.jpg is a false match.

### Sample 5

Using the same images as [Sample 2](#sample-2), the following command shows an example of the Meshroom output. This file can be used in Meshroom with the [GCP marker additions](https://github.com/MrClock8163/MeshroomGCPMarkerAdditions).

```
./gcp_find.py -t Meshroom -i samples/A3.txt -o samples/gcp_list.txt --minrate 0.01 --ignore 0.33 -d 99 samples/DJI_017[234].JPG
3206 2391 DJI_0172.JPG 9 17.0000
1952 2323 DJI_0172.JPG 8 16.7643
3124 1703 DJI_0172.JPG 3 16.5303
1908 1622 DJI_0172.JPG 4 16.5076
2419 368 DJI_0172.JPG 2 16.5680
188 2010 DJI_0172.JPG 9 56.6414
3172 2413 DJI_0173.JPG 9 16.5076
1921 2343 DJI_0173.JPG 8 16.5303
3091 1727 DJI_0173.JPG 3 16.5303
1880 1644 DJI_0173.JPG 4 16.5303
2393 396 DJI_0173.JPG 2 16.5303
3535 2892 DJI_0174.JPG 9 16.5000
2287 2838 DJI_0174.JPG 8 17.0294
3444 2206 DJI_0174.JPG 3 16.5303
2236 2136 DJI_0174.JPG 4 16.5076
2725 879 DJI_0174.JPG 2 16.5303
2239 403 DJI_0174.JPG 1 16.0078
3408 322 DJI_0174.JPG 0 16.0312
```
2 changes: 2 additions & 0 deletions gcp_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def LoadGcps(self):
return False
if len(self.gcps.columns) == 4:
self.gcps.columns = ["col", "row", "img", "id"]
if len(self.gcps.columns) == 5:
self.gcps.columns = ["col", "row", "img", "id", "size"]
elif len(self.gcps.columns) == 7:
self.gcps.columns = ["east", "north", "elev", "col", "row", "img", "id"]
else:
Expand Down
25 changes: 23 additions & 2 deletions gcp_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import json
import argparse
import numpy as np
from numpy.linalg import norm
import matplotlib.pyplot as plt
import cv2
from cv2 import aruco
Expand Down Expand Up @@ -212,7 +213,7 @@ def process_image(self, image_name):
# calculate center of aruco code
x = int(round(np.average(corners[i][0][:, 0])))
y = int(round(np.average(corners[i][0][:, 1])))
self.gcps.append((x, y, os.path.basename(image_name), j))
self.gcps.append((x, y, os.path.basename(image_name), j, corners[i][0]))
if self.args.debug:
if j in self.coords:
plt.plot(x, y, args.markerstyle, markersize=self.args.markersize,
Expand Down Expand Up @@ -264,6 +265,26 @@ def gcp_output(self):
print(f"GCP {j} over limit it is dropped on image {gcp[2]}", file=sys.stderr)
else:
print(f"No coordinates for {j}", file=sys.stderr)
if self.args.type == 'Meshroom':
if j in self.coords:
if len(self.gcp_found[j]) <= self.args.limit:
corners = gcp[4]
tl = corners[2]
bl = corners[1]
br = corners[0]
tr = corners[3]

max_sides = max(norm(tl-bl), norm(bl-br), norm(br-tr), norm(tr-tl))
max_diagonal = max(0.707*norm(tl-br), 0.707*norm(tr-bl))

size = 0.5 * max(max_sides, max_diagonal)

foutput.write('{} {} {} {} {:.4f}\n'.format(
gcp[0], gcp[1], gcp[2], j, size))
else:
print(f"GCP {j} over limit it is dropped on image {gcp[2]}", file=sys.stderr)
else:
print(f"No coordinates for {j}", file=sys.stderr)
else:
if j in self.coords:
if len(self.gcp_found[j]) <= self.args.limit:
Expand Down Expand Up @@ -311,7 +332,7 @@ def cmd_params(parser, params):
help=f'marker dictionary id, default={def_dict} (DICT_4X4_100)')
parser.add_argument('-o', '--output', type=str, default=def_output,
help='name of output GCP list file, default stdout')
parser.add_argument('-t', '--type', choices=['ODM', 'VisualSfM'],
parser.add_argument('-t', '--type', choices=['ODM', 'VisualSfM', 'Meshroom'],
default=def_type,
help=f'target program ODM or VisualSfM, default {def_type}')
parser.add_argument('-i', '--input', type=str, default=def_input,
Expand Down

0 comments on commit 6b8c542

Please sign in to comment.