Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
e6f32c6a
Commit
e6f32c6a
authored
Apr 02, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2487 from paroj:rapidup
parents
4b632022
367d7beb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
track_marker.py
modules/rapid/samples/track_marker.py
+48
-0
rapid.cpp
modules/rapid/src/rapid.cpp
+1
-1
No files found.
modules/rapid/samples/track_marker.py
0 → 100644
View file @
e6f32c6a
import
numpy
as
np
import
cv2
as
cv
# aruco config
adict
=
cv
.
aruco
.
Dictionary_get
(
cv
.
aruco
.
DICT_4X4_50
)
cv
.
imshow
(
"marker"
,
cv
.
aruco
.
drawMarker
(
adict
,
0
,
400
))
marker_len
=
5
# rapid config
obj_points
=
np
.
float32
([[
-
0.5
,
0.5
,
0
],
[
0.5
,
0.5
,
0
],
[
0.5
,
-
0.5
,
0
],
[
-
0.5
,
-
0.5
,
0
]])
*
marker_len
tris
=
np
.
int32
([[
0
,
2
,
1
],
[
0
,
3
,
2
]])
# note CCW order for culling
line_len
=
10
# random calibration data. your mileage may vary.
imsize
=
(
800
,
600
)
K
=
cv
.
getDefaultNewCameraMatrix
(
np
.
diag
([
800
,
800
,
1
]),
imsize
,
True
)
# video capture
cap
=
cv
.
VideoCapture
(
0
)
cap
.
set
(
cv
.
CAP_PROP_FRAME_WIDTH
,
imsize
[
0
])
cap
.
set
(
cv
.
CAP_PROP_FRAME_HEIGHT
,
imsize
[
1
])
rot
,
trans
=
None
,
None
while
cv
.
waitKey
(
1
)
!=
27
:
img
=
cap
.
read
()[
1
]
# detection with aruco
if
rot
is
None
:
corners
,
ids
=
cv
.
aruco
.
detectMarkers
(
img
,
adict
)[:
2
]
if
ids
is
not
None
:
rvecs
,
tvecs
=
cv
.
aruco
.
estimatePoseSingleMarkers
(
corners
,
marker_len
,
K
,
None
)[:
2
]
rot
,
trans
=
rvecs
[
0
]
.
ravel
(),
tvecs
[
0
]
.
ravel
()
# tracking and refinement with rapid
if
rot
is
not
None
:
for
i
in
range
(
5
):
# multiple iterations
ratio
,
rot
,
trans
=
cv
.
rapid
.
rapid
(
img
,
40
,
line_len
,
obj_points
,
tris
,
K
,
rot
,
trans
)
if
ratio
<
0.8
:
# bad quality, force re-detect
rot
,
trans
=
None
,
None
break
# drawing
cv
.
putText
(
img
,
"detecting"
if
rot
is
None
else
"tracking"
,
(
0
,
20
),
cv
.
FONT_HERSHEY_SIMPLEX
,
1.0
,
(
0
,
255
,
255
))
if
rot
is
not
None
:
cv
.
drawFrameAxes
(
img
,
K
,
None
,
rot
,
trans
,
marker_len
)
cv
.
imshow
(
"tracking"
,
img
)
modules/rapid/src/rapid.cpp
View file @
e6f32c6a
...
...
@@ -55,7 +55,7 @@ public:
// close the loop
idx
.
push_back
(
idx
[
0
]);
cum_dist
.
resize
(
i
pts2d
.
rows
);
cum_dist
.
resize
(
i
dx
.
size
()
);
perimeter
=
0.0
f
;
for
(
size_t
i
=
1
;
i
<
idx
.
size
();
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment