Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb7d38b

Browse files
committed
Merge branch 4.x
2 parents 4c549b8 + 4a9b0f2 commit cb7d38b

File tree

73 files changed

+1706
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1706
-95
lines changed

3rdparty/libjasper/jas_stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ int jas_stream_copy(jas_stream_t *out, jas_stream_t *in, int n)
889889
while (all || m > 0) {
890890
if ((c = jas_stream_getc_macro(in)) == EOF) {
891891
/* The next character of input could not be read. */
892-
/* Return with an error if an I/O error occured
892+
/* Return with an error if an I/O error occurred
893893
(not including EOF) or if an explicit copy count
894894
was specified. */
895895
return (!all || jas_stream_error(in)) ? (-1) : 0;

3rdparty/libjasper/jpc_bs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
#define JPC_BITSTREAM_NOCLOSE 0x01
101101
/* End of file has been reached while reading. */
102102
#define JPC_BITSTREAM_EOF 0x02
103-
/* An I/O error has occured. */
103+
/* An I/O error has occurerd. */
104104
#define JPC_BITSTREAM_ERR 0x04
105105

106106
/******************************************************************************\

3rdparty/tbb/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ if (WIN32 AND NOT ARM)
55
message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!")
66
endif()
77

8-
ocv_update(OPENCV_TBB_RELEASE "v2020.2")
9-
ocv_update(OPENCV_TBB_RELEASE_MD5 "5af6f6c2a24c2043e62e47205e273b1f")
8+
ocv_update(OPENCV_TBB_RELEASE "v2021.11.0")
9+
ocv_update(OPENCV_TBB_RELEASE_MD5 "b301151120b08a17e98dcdda6e4f6011")
1010
ocv_update(OPENCV_TBB_FILENAME "${OPENCV_TBB_RELEASE}.tar.gz")
1111
string(REGEX REPLACE "^v" "" OPENCV_TBB_RELEASE_ "${OPENCV_TBB_RELEASE}")
1212
#ocv_update(OPENCV_TBB_SUBDIR ...)
@@ -17,7 +17,7 @@ ocv_download(FILENAME ${OPENCV_TBB_FILENAME}
1717
URL
1818
"${OPENCV_TBB_URL}"
1919
"$ENV{OPENCV_TBB_URL}"
20-
"https://github.com/01org/tbb/archive/"
20+
"https://github.com/oneapi-src/oneTBB/archive/refs/tags/"
2121
DESTINATION_DIR ${tbb_src_dir}
2222
ID TBB
2323
STATUS res
@@ -44,7 +44,6 @@ ocv_include_directories("${tbb_src_dir}/include"
4444

4545
file(GLOB lib_srcs "${tbb_src_dir}/src/tbb/*.cpp")
4646
file(GLOB lib_hdrs "${tbb_src_dir}/src/tbb/*.h")
47-
list(APPEND lib_srcs "${tbb_src_dir}/src/rml/client/rml_tbb.cpp")
4847
ocv_list_filterout(lib_srcs "${tbb_src_dir}/src/tbb/tbbbind.cpp") # hwloc.h requirement
4948
ocv_list_filterout(lib_srcs "${tbb_src_dir}/src/tbb/tbb_bind.cpp") # hwloc.h requirement 2020.1+
5049

cmake/android/android_gradle_projects.cmake

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(ANDROID_GRADLE_PLUGIN_VERSION "7.3.1" CACHE STRING "Android Gradle Plugin version")
33
message(STATUS "Android Gradle Plugin version: ${ANDROID_GRADLE_PLUGIN_VERSION}")
44

5-
set(KOTLIN_PLUGIN_VERSION "1.5.20" CACHE STRING "Kotlin Plugin version")
5+
set(KOTLIN_PLUGIN_VERSION "1.8.20" CACHE STRING "Kotlin Plugin version")
66
message(STATUS "Kotlin Plugin version: ${KOTLIN_PLUGIN_VERSION}")
77

88
if(BUILD_KOTLIN_EXTENSIONS)
@@ -222,20 +222,9 @@ include ':${__dir}'
222222
configure_file("${path}/build.gradle.in" "${ANDROID_TMP_INSTALL_BASE_DIR}/${__dir}/build.gradle" @ONLY)
223223
install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/${__dir}/build.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples)
224224

225-
# HACK: AAR packages generated from current OpenCV project has incomple prefab part
226-
# and cannot be used for native linkage against OpenCV.
227-
# Alternative way to build AAR: https://github.com/opencv/opencv/blob/5.x/platforms/android/build_java_shared_aar.py
228-
if("${__dir}" STREQUAL "tutorial-2-mixedprocessing" OR "${__dir}" STREQUAL "tutorial-4-opencl")
229-
file(APPEND "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" "
230-
if (gradle.opencv_source == 'sdk_path') {
231-
include ':${__dir}'
232-
}
233-
")
234-
else()
235-
file(APPEND "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" "
225+
file(APPEND "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" "
236226
include ':${__dir}'
237227
")
238-
endif()
239228

240229
endmacro()
241230

cmake/checks/cpu_neon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# include <Intrin.h>
66
# include <arm_neon.h>
77
# define CV_NEON 1
8-
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
8+
#elif defined(__ARM_NEON)
99
# include <arm_neon.h>
1010
# define CV_NEON 1
1111
#endif

doc/DoxygenLayout.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
<groupgraph visible="$GROUP_GRAPHS"/>
140140
<memberdecl>
141141
<nestedgroups visible="yes" title=""/>
142+
</memberdecl>
143+
<detaileddescription title=""/>
144+
<memberdecl>
142145
<dirs visible="yes" title=""/>
143146
<files visible="yes" title=""/>
144147
<namespaces visible="yes" title=""/>
@@ -158,7 +161,6 @@
158161
<friends title=""/>
159162
<membergroups visible="yes"/>
160163
</memberdecl>
161-
<detaileddescription title=""/>
162164
<memberdef>
163165
<pagedocs/>
164166
<inlineclasses title=""/>
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
Detection of ArUco boards {#tutorial_aruco_board_detection}
2+
=========================
3+
4+
@prev_tutorial{tutorial_aruco_detection}
5+
6+
| | |
7+
| -: | :- |
8+
| Original authors | Sergio Garrido, Alexander Panov |
9+
| Compatibility | OpenCV >= 4.7.0 |
10+
11+
An ArUco board is a set of markers that acts like a single marker in the sense that it provides a
12+
single pose for the camera.
13+
14+
The most popular board is the one with all the markers in the same plane, since it can be easily printed:
15+
16+
![](images/gboriginal.jpg)
17+
18+
However, boards are not limited to this arrangement and can represent any 2d or 3d layout.
19+
20+
The difference between a board and a set of independent markers is that the relative position between
21+
the markers in the board is known a priori. This allows that the corners of all the markers can be used for
22+
estimating the pose of the camera respect to the whole board.
23+
24+
When you use a set of independent markers, you can estimate the pose for each marker individually,
25+
since you dont know the relative position of the markers in the environment.
26+
27+
The main benefits of using boards are:
28+
29+
- The pose estimation is much more versatile. Only some markers are necessary to perform pose estimation.
30+
Thus, the pose can be calculated even in the presence of occlusions or partial views.
31+
- The obtained pose is usually more accurate since a higher amount of point correspondences (marker
32+
corners) are employed.
33+
34+
Board Detection
35+
---------------
36+
37+
A board detection is similar to the standard marker detection. The only difference is in the pose estimation step.
38+
In fact, to use marker boards, a standard marker detection should be done before estimating the board pose.
39+
40+
To perform pose estimation for boards, you should use `solvePnP()` function, as shown below
41+
in the `samples/cpp/tutorial_code/objectDetection/detect_board.cpp`.
42+
43+
@snippet samples/cpp/tutorial_code/objectDetection/detect_board.cpp aruco_detect_board_full_sample
44+
45+
46+
The parameters are:
47+
48+
- `objPoints`, `imgPoints` object and image points, matched with `cv::aruco::GridBoard::matchImagePoints()`
49+
which, in turn, takes as input `markerCorners` and `markerIds` structures of detected markers from
50+
`cv::aruco::ArucoDetector::detectMarkers()` function.
51+
- `board` the `cv::aruco::Board` object that defines the board layout and its ids
52+
- `cameraMatrix` and `distCoeffs`: camera calibration parameters necessary for pose estimation.
53+
- `rvec` and `tvec`: estimated pose of the board. If not empty then treated as initial guess.
54+
- The function returns the total number of markers employed for estimating the board pose.
55+
56+
The drawFrameAxes() function can be used to check the obtained pose. For instance:
57+
58+
![Board with axis](images/gbmarkersaxis.jpg)
59+
60+
And this is another example with the board partially occluded:
61+
62+
![Board with occlusions](images/gbocclusion.jpg)
63+
64+
As it can be observed, although some markers have not been detected, the board pose can still be
65+
estimated from the rest of markers.
66+
67+
Sample video:
68+
69+
@youtube{Q1HlJEjW_j0}
70+
71+
A full working example is included in the `detect_board.cpp` inside the `samples/cpp/tutorial_code/objectDetection/`.
72+
73+
The samples now take input via command line via the `cv::CommandLineParser`. For this file the example
74+
parameters will look like:
75+
@code{.cpp}
76+
-w=5 -h=7 -l=100 -s=10
77+
-v=/path_to_opencv/opencv/doc/tutorials/objdetect/aruco_board_detection/gboriginal.jpg
78+
-c=/path_to_opencv/opencv/samples/cpp/tutorial_code/objectDetection/tutorial_camera_params.yml
79+
-cd=/path_to_opencv/opencv/samples/cpp/tutorial_code/objectDetection/tutorial_dict.yml
80+
@endcode
81+
Parameters for `detect_board.cpp`:
82+
@snippet samples/cpp/tutorial_code/objectDetection/detect_board.cpp aruco_detect_board_keys
83+
84+
Grid Board
85+
----------
86+
87+
Creating the `cv::aruco::Board` object requires specifying the corner positions for each marker in the environment.
88+
However, in many cases, the board will be just a set of markers in the same plane and in a grid layout,
89+
so it can be easily printed and used.
90+
91+
Fortunately, the aruco module provides the basic functionality to create and print these types of markers
92+
easily.
93+
94+
The `cv::aruco::GridBoard` class is a specialized class that inherits from the `cv::aruco::Board`
95+
class and which represents a Board with all the markers in the same plane and in a grid layout,
96+
as in the following image:
97+
98+
![Image with aruco board](images/gboriginal.jpg)
99+
100+
Concretely, the coordinate system in a grid board is positioned in the board plane, centered in the bottom left
101+
corner of the board and with the Z pointing out, like in the following image (X:red, Y:green, Z:blue):
102+
103+
![Board with axis](images/gbaxis.jpg)
104+
105+
A `cv::aruco::GridBoard` object can be defined using the following parameters:
106+
107+
- Number of markers in the X direction.
108+
- Number of markers in the Y direction.
109+
- Length of the marker side.
110+
- Length of the marker separation.
111+
- The dictionary of the markers.
112+
- Ids of all the markers (X*Y markers).
113+
114+
This object can be easily created from these parameters using the `cv::aruco::GridBoard` constructor:
115+
116+
@snippet samples/cpp/tutorial_code/objectDetection/detect_board.cpp aruco_create_board
117+
118+
- The first and second parameters are the number of markers in the X and Y direction respectively.
119+
- The third and fourth parameters are the marker length and the marker separation respectively.
120+
They can be provided in any unit, having in mind that the estimated pose for this board will be
121+
measured in the same units (in general, meters are used).
122+
- Finally, the dictionary of the markers is provided.
123+
124+
So, this board will be composed by 5x7=35 markers. The ids of each of the markers are assigned, by default,
125+
in ascending order starting on 0, so they will be 0, 1, 2, ..., 34.
126+
127+
After creating a grid board, we probably want to print it and use it.
128+
There are two ways to do this:
129+
1. By using the script `doc/patter_tools/gen_pattern.py `, see @subpage tutorial_camera_calibration_pattern.
130+
2. By using the function `cv::aruco::GridBoard::generateImage()`.
131+
132+
The function `cv::aruco::GridBoard::generateImage()` is provided in cv::aruco::GridBoard class and
133+
can be called by using the following code:
134+
135+
@snippet samples/cpp/tutorial_code/objectDetection/create_board.cpp aruco_generate_board_image
136+
137+
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
138+
to the board dimensions, it will be centered on the image.
139+
- `boardImage`: the output image with the board.
140+
- The third parameter is the (optional) margin in pixels, so none of the markers are touching the image border.
141+
In this case the margin is 10.
142+
- Finally, the size of the marker border, similarly to `generateImageMarker()` function. The default value is 1.
143+
144+
A full working example of board creation is included in the `samples/cpp/tutorial_code/objectDetection/create_board.cpp`
145+
146+
The output image will be something like this:
147+
148+
![](images/board.png)
149+
150+
The samples now take input via commandline via the `cv::CommandLineParser`. For this file the example
151+
parameters will look like:
152+
@code{.cpp}
153+
"_output_path_/aboard.png" -w=5 -h=7 -l=100 -s=10 -d=10
154+
@endcode
155+
156+
Refine marker detection
157+
-----------------------
158+
159+
ArUco boards can also be used to improve the detection of markers. If we have detected a subset of the markers
160+
that belongs to the board, we can use these markers and the board layout information to try to find the
161+
markers that have not been previously detected.
162+
163+
This can be done using the `cv::aruco::refineDetectedMarkers()` function, which should be called
164+
after calling `cv::aruco::ArucoDetector::detectMarkers()`.
165+
166+
The main parameters of this function are the original image where markers were detected, the board object,
167+
the detected marker corners, the detected marker ids and the rejected marker corners.
168+
169+
The rejected corners can be obtained from the `cv::aruco::ArucoDetector::detectMarkers()` function and
170+
are also known as marker candidates. This candidates are square shapes that have been found in the
171+
original image but have failed to pass the identification step (i.e. their inner codification presents
172+
too many errors) and thus they have not been recognized as markers.
173+
174+
However, these candidates are sometimes actual markers that have not been correctly identified due to high
175+
noise in the image, very low resolution or other related problems that affect to the binary code extraction.
176+
The `cv::aruco::ArucoDetector::refineDetectedMarkers()` function finds correspondences between these
177+
candidates and the missing markers of the board. This search is based on two parameters:
178+
179+
- Distance between the candidate and the projection of the missing marker. To obtain these projections,
180+
it is necessary to have detected at least one marker of the board. The projections are obtained using the
181+
camera parameters (camera matrix and distortion coefficients) if they are provided. If not, the projections
182+
are obtained from local homography and only planar board are allowed (i.e. the Z coordinate of all the
183+
marker corners should be the same). The `minRepDistance` parameter in `refineDetectedMarkers()`
184+
determines the minimum euclidean distance between the candidate corners and the projected marker corners
185+
(default value 10).
186+
187+
- Binary codification. If a candidate surpasses the minimum distance condition, its internal bits
188+
are analyzed again to determine if it is actually the projected marker or not. However, in this case,
189+
the condition is not so strong and the number of allowed erroneous bits can be higher. This is indicated
190+
in the `errorCorrectionRate` parameter (default value 3.0). If a negative value is provided, the
191+
internal bits are not analyzed at all and only the corner distances are evaluated.
192+
193+
This is an example of using the `cv::aruco::ArucoDetector::refineDetectedMarkers()` function:
194+
195+
@snippet samples/cpp/tutorial_code/objectDetection/detect_board.cpp aruco_detect_and_refine
196+
197+
It must also be noted that, in some cases, if the number of detected markers in the first place is
198+
too low (for instance only 1 or 2 markers), the projections of the missing markers can be of bad
199+
quality, producing erroneous correspondences.
200+
201+
See module samples for a more detailed implementation.
10.7 KB
Loading
60.9 KB
Loading
69.9 KB
Loading

0 commit comments

Comments
 (0)