Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
c9d70d46
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
993
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c9d70d46
编写于
9月 05, 2023
作者:
A
Alexander Smorkalov
提交者:
GitHub
9月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #24139 from AleksandrPanov:fix_refineDetectedMarkers
fix refineDetectedMarkers
上级
c4c2e2e7
ca527040
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
1 deletion
+40
-1
modules/objdetect/misc/python/test/test_objdetect_aruco.py
modules/objdetect/misc/python/test/test_objdetect_aruco.py
+33
-0
modules/objdetect/src/aruco/aruco_detector.cpp
modules/objdetect/src/aruco/aruco_detector.cpp
+7
-1
未找到文件。
modules/objdetect/misc/python/test/test_objdetect_aruco.py
浏览文件 @
c9d70d46
...
...
@@ -186,6 +186,39 @@ class aruco_objdetect_test(NewOpenCVTests):
self
.
assertEqual
((
1
,
4
,
2
),
refine_corners
[
0
].
shape
)
np
.
testing
.
assert_array_equal
(
corners
,
refine_corners
)
def
test_charuco_refine
(
self
):
aruco_dict
=
cv
.
aruco
.
getPredefinedDictionary
(
cv
.
aruco
.
DICT_6X6_50
)
board_size
=
(
3
,
4
)
board
=
cv
.
aruco
.
CharucoBoard
(
board_size
,
1.
,
.
7
,
aruco_dict
)
aruco_detector
=
cv
.
aruco
.
ArucoDetector
(
aruco_dict
)
charuco_detector
=
cv
.
aruco
.
CharucoDetector
(
board
)
cell_size
=
100
image
=
board
.
generateImage
((
cell_size
*
board_size
[
0
],
cell_size
*
board_size
[
1
]))
camera
=
np
.
array
([[
1
,
0
,
0.5
],
[
0
,
1
,
0.5
],
[
0
,
0
,
1
]])
dist
=
np
.
array
([
0
,
0
,
0
,
0
,
0
],
dtype
=
np
.
float32
).
reshape
(
1
,
-
1
)
# generate gold corners of the ArUco markers for the test
gold_corners
=
np
.
array
(
board
.
getObjPoints
())[:,
:,
0
:
2
]
*
cell_size
# detect corners
markerCorners
,
markerIds
,
_
=
aruco_detector
.
detectMarkers
(
image
)
# test refine
rejected
=
[
markerCorners
[
-
1
]]
markerCorners
,
markerIds
=
markerCorners
[:
-
1
],
markerIds
[:
-
1
]
markerCorners
,
markerIds
,
_
,
_
=
aruco_detector
.
refineDetectedMarkers
(
image
,
board
,
markerCorners
,
markerIds
,
rejected
,
cameraMatrix
=
camera
,
distCoeffs
=
dist
)
charucoCorners
,
charucoIds
,
_
,
_
=
charuco_detector
.
detectBoard
(
image
,
markerCorners
=
markerCorners
,
markerIds
=
markerIds
)
self
.
assertEqual
(
len
(
charucoIds
),
6
)
self
.
assertEqual
(
len
(
markerIds
),
6
)
for
i
,
id
in
enumerate
(
markerIds
.
reshape
(
-
1
)):
np
.
testing
.
assert_allclose
(
gold_corners
[
id
],
markerCorners
[
i
].
reshape
(
4
,
2
),
0.01
,
1.
)
def
test_write_read_dictionary
(
self
):
try
:
aruco_dict
=
cv
.
aruco
.
getPredefinedDictionary
(
cv
.
aruco
.
DICT_5X5_50
)
...
...
modules/objdetect/src/aruco/aruco_detector.cpp
浏览文件 @
c9d70d46
...
...
@@ -1000,7 +1000,13 @@ static inline void _projectUndetectedMarkers(const Board &board, InputOutputArra
OutputArray
undetectedMarkersIds
)
{
Mat
rvec
,
tvec
;
// first estimate board pose with the current avaible markers
Mat
objPoints
,
imgPoints
;
// object and image points for the solvePnP function
board
.
matchImagePoints
(
detectedCorners
,
detectedIds
,
objPoints
,
imgPoints
);
// To refine corners of ArUco markers the function refineDetectedMarkers() find an aruco markers pose from 3D-2D point correspondences.
// To find 3D-2D point correspondences uses matchImagePoints().
// The method matchImagePoints() works with ArUco corners (in Board/GridBoard cases) or with ChArUco corners (in CharucoBoard case).
// To refine corners of ArUco markers we need work with ArUco corners only in all boards.
// To call matchImagePoints() with ArUco corners for all boards we need to call matchImagePoints() from base class Board.
// The method matchImagePoints() implemented in Pimpl and we need to create temp Board object to call the base method.
Board
(
board
.
getObjPoints
(),
board
.
getDictionary
(),
board
.
getIds
()).
matchImagePoints
(
detectedCorners
,
detectedIds
,
objPoints
,
imgPoints
);
if
(
objPoints
.
total
()
<
4ull
)
// at least one marker from board so rvec and tvec are valid
return
;
solvePnP
(
objPoints
,
imgPoints
,
cameraMatrix
,
distCoeffs
,
rvec
,
tvec
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录