Skip to content

Commit

Permalink
--aruco_params switch added
Browse files Browse the repository at this point in the history
  • Loading branch information
zsiki committed Oct 31, 2023
1 parent da7d355 commit 499fe89
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 26 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ usage: gcp_find.py [-h] [-d DICT] [-o OUTPUT] [-t {ODM,VisualSfM}] [-i INPUT]
[--edgewidth EDGEWIDTH] [--fontsize FONTSIZE]
[--fontcolor FONTCOLOR] [--fontcolor1 FONTCOLOR1]
[--fontweight FONTWEIGHT] [--fontweight1 FONTWEIGHT1]
[--limit LIMIT] [--thres THRES] [--winmax WINMAX]
[--winmin WINMIN] [--winstep WINSTEP] [--maxiter MAXITER]
[--limit LIMIT] [--aruco_params ARUCO_PARAMS]
[--thres THRES] [--winmax WINMAX] [--winmin WINMIN]
[--winstep WINSTEP] [--maxiter MAXITER]
[--refinement REFINEMENT] [--minacc MINACC]
[--refwin REFWIN] [-r] [--correctionrate CORRECTIONRATE]
[--borderbits BORDERBITS] [--error ERROR]
Expand Down Expand Up @@ -120,6 +121,10 @@ options:
debug
--limit LIMIT limit the number of records in the output for a unique
id
--aruco_params ARUCO_PARAMS
all ArUco detection parameters are read from a JSON
file, other ArUco detection parameters are ignored
from the command line
--thres THRES adaptive threshold constant, default 7.0
--winmax WINMAX adaptive thresholding window max size, default 23
--winmin WINMIN adaptive tresholding window min size, default 3
Expand Down Expand Up @@ -380,7 +385,7 @@ The gcp_list.txt output file which is ready for use with ODM or WebODM. Copy the
--gcp ./images/gcp_list.txt
```

switch to your ODM command.
switch to your ODM command. In case of WebODM upload gcp_list.txt file with your images.

The gcp_list.txt file should look like:

Expand All @@ -406,6 +411,23 @@ EPSG:23700
650544.828 237514.298 104.215 3408 322 DJI_0174.JPG 0
```

Alternatively you can set all ArUco marker recognition parameters from a
JSON file using --aruco_params switch. It is enough to set parameters where default is not
suiteable. If you create the following JSON file (aruco_params.json)

```
{
"minMarkerPerimeterRate" : 0.01,
"perspectiveRemoveIgnoredMarginPerCell" : 0.33
}
```

then you can change the command line:

```
./gcp_find.py -v -t ODM -i samples/A3.txt --epsg 23700 -o samples/gcp_list.txt --aruco_params aruco_params.json -d 99 samples/DJI_017[234].JPG
```

### Sample 3

Photos (DJI0087.jpg and DJI0088.jpg) made by a DJI Phantom 4 Pro. There are three 4x4 GCPs (id=3, id=4, id=5) on image DJI\_0087.jpg and five (id=0, id=3, id=4, id=5, id=6) on image DJI\_0088.jpg.
Expand Down
57 changes: 34 additions & 23 deletions gcp_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import time
import glob
import json
import argparse
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -47,29 +48,37 @@ def __init__(self, args, params):

# set aruco parameters from command line arguments
self.params = params
self.params.adaptiveThreshConstant = args.thres
self.params.adaptiveThreshWinSizeMax = args.winmax
self.params.adaptiveThreshWinSizeMin = args.winmin
self.params.adaptiveThreshWinSizeStep = args.winstep
self.params.cornerRefinementMaxIterations = args.maxiter
self.params.cornerRefinementMethod = args.refinement
self.params.cornerRefinementMinAccuracy = args.minacc
self.params.cornerRefinementWinSize = args.refwin
self.params.detectInvertedMarker = args.inverted
self.params.errorCorrectionRate = args.correctionrate
self.params.markerBorderBits = args.borderbits
self.params.maxErroneousBitsInBorderRate = args.error
self.params.maxMarkerPerimeterRate = args.maxrate
self.params.minCornerDistanceRate = args.corner
self.params.minDistanceToBorder = args.borderdist
self.params.minMarkerDistanceRate = args.markerdist
self.minMarkerLengthRatioOriginalImg = args.lengthratio
self.params.minMarkerPerimeterRate = args.minrate
self.params.minOtsuStdDev = args.otsu
self.params.perspectiveRemoveIgnoredMarginPerCell = args.ignore
self.params.perspectiveRemovePixelPerCell = args.persp
self.params.polygonalApproxAccuracyRate = args.poly
self.params.useAruco3Detection = args.aruco3
if args.aruco_params is None:
self.params.adaptiveThreshConstant = args.thres
self.params.adaptiveThreshWinSizeMax = args.winmax
self.params.adaptiveThreshWinSizeMin = args.winmin
self.params.adaptiveThreshWinSizeStep = args.winstep
self.params.cornerRefinementMaxIterations = args.maxiter
self.params.cornerRefinementMethod = args.refinement
self.params.cornerRefinementMinAccuracy = args.minacc
self.params.cornerRefinementWinSize = args.refwin
self.params.detectInvertedMarker = args.inverted
self.params.errorCorrectionRate = args.correctionrate
self.params.markerBorderBits = args.borderbits
self.params.maxErroneousBitsInBorderRate = args.error
self.params.maxMarkerPerimeterRate = args.maxrate
self.params.minCornerDistanceRate = args.corner
self.params.minDistanceToBorder = args.borderdist
self.params.minMarkerDistanceRate = args.markerdist
self.minMarkerLengthRatioOriginalImg = args.lengthratio
self.params.minMarkerPerimeterRate = args.minrate
self.params.minOtsuStdDev = args.otsu
self.params.perspectiveRemoveIgnoredMarginPerCell = args.ignore
self.params.perspectiveRemovePixelPerCell = args.persp
self.params.polygonalApproxAccuracyRate = args.poly
self.params.useAruco3Detection = args.aruco3
else :
# read params from json
with open(args.aruco_params) as f:
data = f.read()
js = json.loads(data)
for par in js:
setattr(self.params, par, js[par])
if args.list:
# list available aruco dictionary names & exit
for act_dict in self.list_dicts():
Expand Down Expand Up @@ -344,6 +353,8 @@ def cmd_params(parser, params):
parser.add_argument('--limit', type=int, default=def_limit,
help='limit the number of records in the output for a unique id')
# parameters for ArUco detection
parser.add_argument('--aruco_params', type=str, default=None,
help='all ArUco detection parameters are read from a JSON file, other ArUco detection parameters are ignored from the command line')
parser.add_argument('--thres', type=float,
default=params.adaptiveThreshConstant,
help=f'adaptive threshold constant, default {params.adaptiveThreshConstant}')
Expand Down

0 comments on commit 499fe89

Please sign in to comment.