Ocean
Loading...
Searching...
No Matches
MicroQRCodeDetector.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
11
13
15
16namespace Ocean
17{
18
19namespace CV
20{
21
22namespace Detector
23{
24
25namespace QRCodes
26{
27
28/**
29 * This class implements common functionality of Micro QR code detectors but is not a stand-alone detector
30 * @ingroup cvdetectorqrcodes
31 */
32class OCEAN_CV_DETECTOR_QRCODES_EXPORT MicroQRCodeDetector
33{
34 protected:
35
36 /**
37 * Locates the modules of one timing pattern in a Micro QR code
38 * @param yFrame The frame in which Micro QR code will be detected, must be valid, match the camera size, have its origin in the upper left corner, and have a pixel format that is compatible with Y8
39 * @param width The width of the input frame, range: [15, infinity)
40 * @param height The height of the input frame, range: [15, infinity)
41 * @param paddingElements The number of padding elements of the input frame, range: [0, infinity)
42 * @param finderPattern The finder pattern; must be valid and have known corners
43 * @param topLeftCorner The index of the finder pattern corner considered to be the top-left one, range: [0, 3]
44 * @param timingAdjacentFinderCorner The index of the finder pattern corner adjacent to the timing pattern, must be top-right or bottom-left, range: [0, 3]
45 * @param moduleCenters The centers of the modules that were found in the timing pattern, will be empty if the timing pattern was not found
46 * @return True if the timing pattern was found, otherwise false
47 */
48 static bool getTimingPatternModules(const uint8_t* const yFrame, const unsigned int width, const unsigned int height, const unsigned int paddingElements, const FinderPattern& finderPattern, const unsigned int topLeftCorner, const unsigned int timingAdjacentFinderCorner, Vectors2& moduleCenters);
49
50 /**
51 * Computes potential versions and poses of a Micro QR code given its finder pattern
52 * @param anyCamera The camera profile that produced the input image, must be valid
53 * @param yFrame The frame in which Micro QR code will be detected, must be valid, match the camera size, have its origin in the upper left corner, and have a pixel format that is compatible with Y8
54 * @param width The width of the input frame, range: [15, infinity)
55 * @param height The height of the input frame, range: [15, infinity)
56 * @param paddingElements The number of padding elements of the input frame, range: [0, infinity)
57 * @param finderPattern The finder pattern; must be valid and have known corners
58 * @param code_T_cameras The returning possible poses that have been identified, possible size: [0, 4] (optimally it is only 1)
59 * @param provisionalVersions The version numbers that the Micro QR code is estimated to have at each potential pose, range: [1, 4]
60 * @param scale Optional scaling factor for the coordinates in the object space, range: (0, infinity)
61 * @return True if one or more poses have been found, otherwise false
62 */
63 static bool computePosesAndProvisionalVersions(const AnyCamera& anyCamera, const uint8_t* const yFrame, const unsigned int width, const unsigned int height, const unsigned int paddingElements, const FinderPattern& finderPattern, HomogenousMatrices4& code_T_cameras, std::vector<unsigned int>& provisionalVersions, const Scalar scale = Scalar(1));
64
65 /**
66 * Extracts all modules of a Micro QR code from an image
67 * @param anyCamera The camera profile that produced the input image, must be valid
68 * @param yFrame The frame in which Micro QR code will be detected, must be valid, match the camera size, have its origin in the upper left corner, and have a pixel format that is compatible with Y8
69 * @param width The width of the input frame, range: [15, infinity)
70 * @param height The height of the input frame, range: [15, infinity)
71 * @param paddingElements The number of padding elements of the input frame, range: [0, infinity)
72 * @param version The version number that the Micro QR code candidate, range: [1, 4]
73 * @param code_T_camera The pose of the Micro QR code candidate
74 * @param isNormalReflectance Indicates whether alignment patterns with normal or inverted reflectance are searched
75 * @param grayThreshold The gray value that has been determined as the separation between foreground and background modules (cf. `FinderPattern::grayThreshold()`), range: [0, 255]
76 * @param modules The resulting list of all extracted modules, will have `MicroQRCode::modulesPerSide(version) * MicroQRCode::modulesPerSide(version)` elements
77 * @param scale Optional scaling factor for the coordinates in the object space, range: (0, infinity)
78 * @return True if the extraction of all modules was successful, otherwise false
79 */
80 static bool extractModulesFromImage(const AnyCamera& anyCamera, const uint8_t* const yFrame, const unsigned int width, const unsigned int height, const unsigned int paddingElements, const unsigned int version, const HomogenousMatrix4& code_T_camera, const bool isNormalReflectance, const unsigned int grayThreshold, std::vector<uint8_t>& modules, const Scalar scale = Scalar(1));
81
82 /**
83 * Extracts the version information from the modules of a Micro QR code
84 * @param provisionalVersion The version number that was used to extract the modules, range: [1, 4]
85 * @param modules The modules of the Micro QR code, should have `MicroQRCode::modulesPerSide(provisionalVersion) * MicroQRCode::modulesPerSide(provisionalVersion)` elements
86 * @return The version number as it was encoded in the Micro QR code, range: [1, 4], or 0 if the version information could not be extracted
87 */
88 static unsigned int extractVersionFromModules(const unsigned int provisionalVersion, const std::vector<uint8_t>& modules);
89
90};
91
92} // namespace QRCodes
93
94} // namespace Detector
95
96} // namespace CV
97
98} // namespace Ocean
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
Definition of a class for finder patterns of QR codes (squares in the top-left, top-right and bottom-...
Definition FinderPatternDetector.h:58
This class implements common functionality of Micro QR code detectors but is not a stand-alone detect...
Definition MicroQRCodeDetector.h:33
static unsigned int extractVersionFromModules(const unsigned int provisionalVersion, const std::vector< uint8_t > &modules)
Extracts the version information from the modules of a Micro QR code.
static bool extractModulesFromImage(const AnyCamera &anyCamera, const uint8_t *const yFrame, const unsigned int width, const unsigned int height, const unsigned int paddingElements, const unsigned int version, const HomogenousMatrix4 &code_T_camera, const bool isNormalReflectance, const unsigned int grayThreshold, std::vector< uint8_t > &modules, const Scalar scale=Scalar(1))
Extracts all modules of a Micro QR code from an image.
static bool computePosesAndProvisionalVersions(const AnyCamera &anyCamera, const uint8_t *const yFrame, const unsigned int width, const unsigned int height, const unsigned int paddingElements, const FinderPattern &finderPattern, HomogenousMatrices4 &code_T_cameras, std::vector< unsigned int > &provisionalVersions, const Scalar scale=Scalar(1))
Computes potential versions and poses of a Micro QR code given its finder pattern.
static bool getTimingPatternModules(const uint8_t *const yFrame, const unsigned int width, const unsigned int height, const unsigned int paddingElements, const FinderPattern &finderPattern, const unsigned int topLeftCorner, const unsigned int timingAdjacentFinderCorner, Vectors2 &moduleCenters)
Locates the modules of one timing pattern in a Micro QR code.
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition HomogenousMatrix4.h:73
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
std::vector< QRCode > QRCodes
Definition of a vector of QR codes.
Definition QRCode.h:28
The namespace covering the entire Ocean framework.
Definition Accessor.h:15