63 PS_ERROR_INVALID_TERMINATION
128 inline Scalar scale()
const;
135 inline Scalar convertCodeSpaceToObjectSpaceX(
const Scalar xCodeSpace)
const;
142 inline Scalar convertCodeSpaceToObjectSpaceY(
const Scalar yCodeSpace)
const;
303 static Frame draw(
const QRCodeBase& code,
const unsigned int border,
const uint8_t foregroundColor = 0u,
const uint8_t backgroundColor = 255u);
316 static Frame draw(
const QRCodeBase& code,
const unsigned int frameSize,
const bool allowTrueMultiple,
const unsigned int border,
Worker* worker =
nullptr,
const uint8_t foregroundColor = 0u,
const uint8_t backgroundColor = 255u);
380 template <
unsigned int tLineW
idth>
381 static void drawLine(
const AnyCamera& anyCamera,
Frame& frame,
const Vector2& pointA,
const Vector2& pointB,
const uint8_t* color =
nullptr,
const size_t steps = 10);
393 template <
unsigned int tLineW
idth>
394 static void drawLine(
const AnyCamera& anyCamera,
Frame& frame,
const Vector3& pointA,
const Vector3& pointB,
const uint8_t* color =
nullptr,
const size_t steps = 10);
409 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
410 static void drawLineIF(
Frame& frame,
const HomogenousMatrix4& flippedCamera_T_world,
const AnyCamera& anyCamera,
const Vector3& objectPoint0,
const Vector3& objectPoint1,
const unsigned int segments,
const uint8_t* foregroundColor,
const uint8_t* backgroundColor);
423 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
426 #if defined(OCEAN_QRCODES_QRCODEDEBUGELEMENTS_ENABLED)
592 static ParsingStatus parseWifiConfig(
const std::string& configString, std::string& ssid, std::string& password, std::string* encryption =
nullptr,
bool* isSsidHidden =
nullptr);
620 static bool unescapeSpecialCharacters(
const std::string& escapedString, std::string&
string,
const std::string& specialCharacters =
"\\;,\":");
643 const Scalar xObjectSpace = xScale_ * xCodeSpace -
Scalar(scale_);
651 const Scalar yObjectSpace = yScale_ * yCodeSpace +
Scalar(scale_);
659 ocean_assert(scale >
Scalar(0));
684 if (observations.size() != codes.size())
686 ocean_assert(
false &&
"This should never happen!");
690 for (
size_t i = 0; i < observations.size(); ++i)
692 drawObservation(frame, observations[i].frame_H_code(), observations[i].finderPatterns(), codes[i].version(), codes[i].modules());
696 template <
unsigned int tLineW
idth>
699 ocean_assert(anyCamera.
isValid());
701 ocean_assert(steps != 0);
703 return Utilities::drawLine<tLineWidth>(anyCamera, frame, anyCamera.
vector(pointA), anyCamera.
vector(pointB), color, steps);
706 template <
unsigned int tLineW
idth>
709 static_assert(tLineWidth != 0 && tLineWidth % 2u == 1u,
"Line width must be non-zero and odd");
711 ocean_assert(anyCamera.
isValid());
713 ocean_assert(steps != 0);
716 ocean_assert(!step.
isNull());
720 Vector3 previousPlanePoint = pointA;
723 for (
size_t s = 0; s < steps; ++s)
725 const Vector3 currentPlanePoint = previousPlanePoint + step;
728 CV::Canvas::line<tLineWidth>(frame, previousImagePoint, currentImagePoint, color);
730 previousPlanePoint = currentPlanePoint;
731 previousImagePoint = currentImagePoint;
735 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
738 static_assert(tForegroundLineWidth != 0u && tForegroundLineWidth % 2u == 1u,
"The line width must be non-zero and odd.");
739 static_assert(tBackgroundLineWidth == 0u || tBackgroundLineWidth % 2u == 1u,
"The line width must be either zero (in which case it will not be drawn) or non-zero and odd.");
741 ocean_assert(frame && flippedCamera_T_world.
isValid() && anyCamera.
isValid());
743 ocean_assert(segments >= 1u);
747 if (backgroundColor && tBackgroundLineWidth != 0u)
751 for (
unsigned int n = 0u; n < segments; ++n)
753 const Vector3 end = objectPoint0 + (objectPoint1 - objectPoint0) *
Scalar(n + 1) * segmentFactor;
756 CV::Canvas::line<tBackgroundLineWidth>(frame, projectedStart.
x(), projectedStart.
y(), projectedEnd.
x(), projectedEnd.
y(), backgroundColor);
758 projectedStart = projectedEnd;
766 for (
unsigned int n = 0u; n < segments; ++n)
768 const Vector3 end = objectPoint0 + (objectPoint1 - objectPoint0) *
Scalar(n + 1) * segmentFactor;
771 CV::Canvas::line<tForegroundLineWidth>(frame, projectedStart.
x(), projectedStart.
y(), projectedEnd.
x(), projectedEnd.
y(), foregroundColor);
773 projectedStart = projectedEnd;
778 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
781 static_assert(tForegroundLineWidth != 0u && tForegroundLineWidth % 2u == 1u,
"The line width must be non-zero and odd.");
782 static_assert(tBackgroundLineWidth == 0u || tBackgroundLineWidth % 2u == 1u,
"The line width must be either zero (in which case it will not be drawn) or non-zero and odd.");
784 ocean_assert(frame && flippedCamera_T_world.
isValid() && anyCamera.
isValid() && world_T_coordinateSystem.
isValid());
794 const Vector3 xAxis = world_T_coordinateSystem *
Vector3(length, 0, 0);
795 const Vector3 yAxis = world_T_coordinateSystem *
Vector3(0, length, 0);
796 const Vector3 zAxis = world_T_coordinateSystem *
Vector3(0, 0, length);
800 drawLineIF<tForegroundLineWidth, tBackgroundLineWidth>(frame, flippedCamera_T_world, anyCamera, world_T_coordinateSystem.
translation(), xAxis, 15u, red, black);
805 drawLineIF<tForegroundLineWidth, tBackgroundLineWidth>(frame, flippedCamera_T_world, anyCamera, world_T_coordinateSystem.
translation(), yAxis, 15u, green, black);
810 drawLineIF<tForegroundLineWidth, tBackgroundLineWidth>(frame, flippedCamera_T_world, anyCamera, world_T_coordinateSystem.
translation(), zAxis, 15u, blue, black);
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
virtual unsigned int width() const =0
Returns the width of the camera image.
virtual VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual unsigned int height() const =0
Returns the height of the camera image.
virtual bool isValid() const =0
Returns whether this camera is valid.
virtual VectorT3< T > vector(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const =0
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
static const uint8_t * green(const FrameType::PixelFormat pixelFormat=FrameType::FORMAT_RGB24)
Returns the color values for a green color.
static const uint8_t * red(const FrameType::PixelFormat pixelFormat=FrameType::FORMAT_RGB24)
Returns the color values for a red color.
static const uint8_t * black(const FrameType::PixelFormat pixelFormat=FrameType::FORMAT_RGB24)
Returns the color values for a black color.
static const uint8_t * blue(const FrameType::PixelFormat pixelFormat=FrameType::FORMAT_RGB24)
Returns the color values for a blue color.
Definition of a class for finder patterns of QR codes (squares in the top-left, top-right and bottom-...
Definition: FinderPatternDetector.h:58
Definition of an observation of QR code in 2D.
Definition: LegacyQRCodeDetector2D.h:73
const FinderPatternTriplet & finderPatterns() const
Returns a pointer to the finder patterns.
Definition: LegacyQRCodeDetector2D.h:275
const SquareMatrix3 & frame_H_code() const
Returns the homography that maps coordinates in the QR code grid to image coordinates.
Definition: LegacyQRCodeDetector2D.h:270
std::vector< Observation > Observations
Definition of a vector of observations.
Definition: LegacyQRCodeDetector2D.h:116
std::vector< Observation > Observations
Definition of a vector of observations.
Definition: MicroQRCodeDetector2D.h:88
Base class for QR code implementations.
Definition: QRCodeBase.h:32
const std::vector< uint8_t > & modules() const
Returns the modules of this QR code The modules are stored in a vector and will have modulesPerSide()...
Definition: QRCodeBase.h:290
unsigned int version() const
Returns the version of the QR code.
Definition: QRCodeBase.h:305
std::vector< Observation > Observations
Definition of a vector of observations.
Definition: QRCodeDetector2D.h:92
Definition of a QR code.
Definition: QRCode.h:35
bool isValid() const override
Returns whether this is a valid QR code instance.
Definition: QRCode.h:93
Definition of a helper class to convert between the coordinate systems that are used for QR codes.
Definition: cv/detector/qrcodes/Utilities.h:116
virtual ~CoordinateSystemBase()=default
The default constructor.
CoordinateSystemBase(const unsigned int modulesPerSide, const Scalar scale=Scalar(1))
Constructs an coordinate system object Coordinates are normalized to the range [-1,...
Scalar yScale_
The scale factor for y-coordinates.
Definition: cv/detector/qrcodes/Utilities.h:172
Scalar convertCodeSpaceToObjectSpaceX(const Scalar xCodeSpace) const
Converts an x-coordinate from code space to object space.
Definition: cv/detector/qrcodes/Utilities.h:641
Scalar convertCodeSpaceToObjectSpaceY(const Scalar yCodeSpace) const
Converts an y-coordinate from code space to object space.
Definition: cv/detector/qrcodes/Utilities.h:649
Scalar xScale_
The scale factor for x-coordinates.
Definition: cv/detector/qrcodes/Utilities.h:169
Scalar scale_
Global factor for coordinate scaling.
Definition: cv/detector/qrcodes/Utilities.h:166
unsigned int modulesPerSide_
The number of modules per side of the QR code, range: [11, 177].
Definition: cv/detector/qrcodes/Utilities.h:163
Scalar scale() const
Returns the scaling factor that is used for coordinate scaling.
Definition: cv/detector/qrcodes/Utilities.h:636
static Vectors3 computeCornersInObjectSpace(const Scalar scale=Scalar(1))
Compute the locations of the four corners of a code in object space Coordinates are normalized to the...
Definition: cv/detector/qrcodes/Utilities.h:657
Definition of a helper class to convert between the coordinate systems that are used for QR codes.
Definition: cv/detector/qrcodes/Utilities.h:179
static std::vector< Vectors3 > computeAlignmentPatternsInObjectSpace(const unsigned int version, const Scalar scale=Scalar(1))
Computes the locations of alignment patterns for a specific QR code version in object space Coordinat...
static Vectors3 computeVersionInformationModulesInObjectSpace(const unsigned int version, const bool versionInformation1)
Computes the locations of the version information fields for a specific QR code version in object spa...
CoordinateSystem(const unsigned int version, const Scalar scale=Scalar(1))
Constructs a coordinate system object Coordinates are normalized to the range [-1,...
static Vectors3 computeFinderPatternCentersInObjectSpace(const unsigned int version, const Scalar scale=Scalar(1))
Computes the locations of the centers of the 3 finder patterns for a specific QR code version in obje...
Definition of a helper class to convert between the coordinate systems that are used for Micro QR cod...
Definition: cv/detector/qrcodes/Utilities.h:251
Vector3 computeFinderPatternCenterInObjectSpace() const
Computes the location of the center of the finder pattern Coordinates are normalized to the range [-1...
Vectors3 computeHorizontalTimingPatternModulesInObjectSpace() const
Computes the locations of the modules in the horizontal (top edge) timing pattern Coordinates are nor...
Vectors3 computeFinderPatternCornersInObjectSpace() const
Computes the locations of the corners of the finder pattern for a specific Micro QR code version in o...
MicroQRCoordinateSystem(const unsigned int version, const Scalar scale=Scalar(1))
Constructs a Micro QR coordinate system object Coordinates are normalized to the range [-1,...
Vectors3 computeVerticalTimingPatternModulesInObjectSpace() const
Computes the locations of the modules in the vertical (left edge) timing pattern Coordinates are norm...
Definition of utility functions related to the detection of QR codes.
Definition: cv/detector/qrcodes/Utilities.h:42
static void drawObservation(Frame &frame, const SquareMatrix3 &frame_H_code, const FinderPatternTriplet &finderPatterns, const unsigned int version, const std::vector< uint8_t > &modules)
Draws an observation of a QR code into a given frame.
static bool computeCodeTiltAndViewAngles(const HomogenousMatrix4 &world_T_camera, const HomogenousMatrix4 &world_T_code, Scalar &tiltAngle, Scalar &viewAngle, Scalar *distance=nullptr)
Computes the tilt and view angles for an observation of a QR code The tilt angle is defined as the an...
static void drawLineIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &anyCamera, const Vector3 &objectPoint0, const Vector3 &objectPoint1, const unsigned int segments, const uint8_t *foregroundColor, const uint8_t *backgroundColor)
Draws a (projected) 3D line into a given frame.
Definition: cv/detector/qrcodes/Utilities.h:736
static std::string parsingStatusToString(const ParsingStatus status)
Returns a human-readable string for each possible parsing status.
static ParsingStatus parseWifiConfig(const std::string &configString, std::string &ssid, std::string &password, std::string *encryption=nullptr, bool *isSsidHidden=nullptr)
Parses a Wi-Fi configuration from a QR code The following format is expected:
static bool containsCode(const QRCodes &codes, const QRCode &newCode)
Checks if a given QR code exists in a list of QR codes This function will check if the payload of a n...
static Frame draw(const QRCodeBase &code, const unsigned int border, const uint8_t foregroundColor=0u, const uint8_t backgroundColor=255u)
Draws an unscaled image of a QR code (FORMAT_Y8), i.e.
static bool containsCodeStereo(const SharedAnyCameras &sharedAnyCameras, const HomogenousMatrix4 &world_T_device, const HomogenousMatrices4 &device_T_cameras, const QRCodes &codes, const HomogenousMatrices4 &world_T_codes, const Scalars &codeSizes, const QRCode &newCode, const HomogenousMatrix4 &world_T_newCode, const Scalar newCodeSize, unsigned int *index=nullptr)
Checks if a given QR code exists in a list of QR codes given their 6DOF poses and a stereo camera Thi...
static bool computeContrast(const AnyCamera &anyCamera, const Frame &yFrame, const HomogenousMatrix4 &world_T_camera, const QRCodeBase &code, const HomogenousMatrix4 &world_T_code, const Scalar codeSize, unsigned int *medianContrast, unsigned int *averageContrast)
Computes the contrast between fore- and background modules for a given observation of a QR code.
static bool containsCodeMono(const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, const QRCodes &codes, const HomogenousMatrices4 &world_T_codes, const Scalars &codeSizes, const QRCode &newCode, const HomogenousMatrix4 &world_T_newCode, const Scalar newCodeSize, unsigned int *index=nullptr)
Checks if a given QR code exists in a list of QR codes given their 6DOF poses and a mono camera This ...
static Frame draw(const QRCodeBase &code, const unsigned int frameSize, const bool allowTrueMultiple, const unsigned int border, Worker *worker=nullptr, const uint8_t foregroundColor=0u, const uint8_t backgroundColor=255u)
Draws a scaled image of a QR code (FORMAT_Y8)
static Scalar computeModuleDiagonalLength(const AnyCamera &anyCamera, const HomogenousMatrix4 &flippedCamera_T_code, const CoordinateSystemBase &coordinateSystem, const unsigned int xModule, const unsigned int yModule)
Computes the average diagonal length of a module in pixels for a given coordinate system of a QR code...
static bool unescapeSpecialCharacters(const std::string &escapedString, std::string &string, const std::string &specialCharacters="\\;,\":")
Unescapes selected character from a string.
static void drawObservations(Frame &frame, const LegacyQRCodeDetector2D::Observations &observations, const QRCodes &codes)
Draws observations of QR codes into a given frame.
Definition: cv/detector/qrcodes/Utilities.h:680
static void drawLine(const AnyCamera &anyCamera, Frame &frame, const Vector2 &pointA, const Vector2 &pointB, const uint8_t *color=nullptr, const size_t steps=10)
Draws a line between two 2D points into a frame with lens distortion.
Definition: cv/detector/qrcodes/Utilities.h:697
static void drawFinderPattern(Frame &frame, const FinderPattern &finderPattern, const uint8_t *color)
Draw the location of a finder pattern in a given frame.
static bool computeNumberPixelsPerModule(const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, const HomogenousMatrix4 &world_T_code, const Scalar codeSize, const unsigned int version, Scalar *minNumberPixelsPerModule, Scalar *maxNumberPixelsPerModule, Scalar *medianNumberPixelsPerModule, Scalar *avgNumberPixelsPerModule)
Computes the number of pixel per module for a given observation of a QR code.
static void drawObservation(Frame &frame, const LegacyQRCodeDetector2D::Observation &observation, const QRCode &code)
Draws an observation of a QR code into a given frame.
Definition: cv/detector/qrcodes/Utilities.h:672
static bool computeCodeCenterInImage(const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, const QRCode &code, const HomogenousMatrix4 &world_T_code, const Scalar codeSize, Vector2 &imageCodeCenter, Scalar *maxSquareRadius=nullptr)
Computes the image location of the center of a QR code given its world pose.
static void drawObservations(const AnyCamera &anyCamera, Frame &frame, const QRCodeDetector2D::Observations &observations, const QRCodes &codes)
Draws observations of QR codes into a given frame.
static std::string escapeSpecialCharacters(const std::string &string, const std::string &specialCharacters="\\;,\":")
Escapes selected characters in a string.
static void drawCoordinateSystemIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_coordinateSystem, const Scalar length)
Draws a 3D coordinate system (projected) into a frame.
Definition: cv/detector/qrcodes/Utilities.h:779
static void drawObservations(const AnyCamera &anyCamera, Frame &frame, const MicroQRCodeDetector2D::Observations &observations, const MicroQRCodes &codes)
Draws observations of Micro QR codes into a given frame.
static void drawQRCodeOutline(const AnyCamera &anyCamera, Frame &frame, const unsigned int version, const HomogenousMatrix4 &code_T_camera)
Draws the outline of a QR code given its pose and version.
ParsingStatus
Definition of return codes of the parsing function for the Wi-Fi configurations.
Definition: cv/detector/qrcodes/Utilities.h:49
@ PS_ERROR_INVALID_FIELD_DATA
Indicates that the content of a field is invalid, missing, or could not be processed correctly.
Definition: cv/detector/qrcodes/Utilities.h:57
@ PS_ERROR_DUPLICATE_FIELD_TYPE
Indicates that a field has been found multiple times when it should have been unique.
Definition: cv/detector/qrcodes/Utilities.h:61
@ PS_ERROR_INVALID_PREFIX
Indicates that the input has an invalid prefix.
Definition: cv/detector/qrcodes/Utilities.h:53
@ PS_ERROR_INVALID_FIELD_TYPE
Indicates that field type is unknown or invalid.
Definition: cv/detector/qrcodes/Utilities.h:59
@ PS_ERROR_INVALID_FIELD_FORMAT
Indicates that a field uses an invalid format, for example it isn't closed correctly.
Definition: cv/detector/qrcodes/Utilities.h:55
static std::string toString(const QRCodeBase &code, const unsigned int border)
Converts a QR code into string (aka ASCII art)
static bool isObjectPointInFrontIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint, const T epsilon=NumericT< T >::eps())
Determines whether a given 3D object point lies in front of a camera while the location of the camera...
Definition: Camera.h:811
This class implements Ocean's image class.
Definition: Frame.h:1792
bool isValid() const
Returns whether this frame is valid.
Definition: Frame.h:4448
@ FORMAT_RGB24
Pixel format with byte order RGB and 24 bits per pixel.
Definition: Frame.h:315
unsigned int width() const
Returns the width of the frame format in pixel.
Definition: Frame.h:3143
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition: Frame.h:3188
static bool arePixelFormatsCompatible(const PixelFormat pixelFormatA, const PixelFormat pixelFormatB)
Returns whether two given pixel formats are compatible.
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition: Frame.h:3153
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition: Frame.h:1050
unsigned int height() const
Returns the height of the frame in pixel.
Definition: Frame.h:3148
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition: HomogenousMatrix4.h:1381
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
static constexpr bool isInsideRange(const T lower, const T value, const T upper, const T epsilon=NumericT< T >::eps())
Returns whether a value lies between a given range up to a provided epsilon border.
Definition: Numeric.h:2872
const T & x() const noexcept
Returns the x value.
Definition: Vector2.h:698
const T & y() const noexcept
Returns the y value.
Definition: Vector2.h:710
bool isNull() const
Returns whether this vector is a null vector up to a small epsilon.
Definition: Vector3.h:854
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
std::array< FinderPattern, 3 > FinderPatternTriplet
Definition of a 3-tuple of finder patterns.
Definition: FinderPatternDetector.h:198
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition: HomogenousMatrix4.h:73
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition: Math.h:144
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition: Vector3.h:22
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition: AnyCamera.h:90
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
std::vector< MicroQRCode > MicroQRCodes
Definition of a vector of Micro QR codes.
Definition: MicroQRCode.h:25
std::vector< QRCode > QRCodes
Definition of a vector of QR codes.
Definition: QRCode.h:25
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15