62 PS_ERROR_INVALID_TERMINATION
130 inline Scalar scale()
const;
137 inline Scalar convertCodeSpaceToObjectSpaceX(
const Scalar xCodeSpace)
const;
144 inline Scalar convertCodeSpaceToObjectSpaceY(
const Scalar yCodeSpace)
const;
232 static Frame draw(
const QRCodeBase& code,
const unsigned int border,
const uint8_t foregroundColor = 0u,
const uint8_t backgroundColor = 255u);
245 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);
300 template <
unsigned int tLineW
idth>
301 static void drawLine(
const AnyCamera& anyCamera,
Frame& frame,
const Vector2& pointA,
const Vector2& pointB,
const uint8_t* color =
nullptr,
const size_t steps = 10);
313 template <
unsigned int tLineW
idth>
314 static void drawLine(
const AnyCamera& anyCamera,
Frame& frame,
const Vector3& pointA,
const Vector3& pointB,
const uint8_t* color =
nullptr,
const size_t steps = 10);
329 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
330 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);
343 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
346 #if defined(OCEAN_QRCODES_QRCODEDEBUGELEMENTS_ENABLED)
512 static ParsingStatus parseWifiConfig(
const std::string& configString, std::string& ssid, std::string& password, std::string* encryption =
nullptr,
bool* isSsidHidden =
nullptr);
540 static bool unescapeSpecialCharacters(
const std::string& escapedString, std::string&
string,
const std::string& specialCharacters =
"\\;,\":");
563 const Scalar xObjectSpace = xScale_ * xCodeSpace -
Scalar(scale_);
571 const Scalar yObjectSpace = yScale_ * yCodeSpace +
Scalar(scale_);
579 ocean_assert(scale >
Scalar(0));
604 if (observations.size() != codes.size())
606 ocean_assert(
false &&
"This should never happen!");
610 for (
size_t i = 0; i < observations.size(); ++i)
612 drawObservation(frame, observations[i].frame_H_code(), observations[i].finderPatterns(), codes[i].version(), codes[i].modules());
616 template <
unsigned int tLineW
idth>
619 ocean_assert(anyCamera.
isValid());
621 ocean_assert(steps != 0);
623 return Utilities::drawLine<tLineWidth>(anyCamera, frame, anyCamera.
vector(pointA), anyCamera.
vector(pointB), color, steps);
626 template <
unsigned int tLineW
idth>
629 static_assert(tLineWidth != 0 && tLineWidth % 2u == 1u,
"Line width must be non-zero and odd");
631 ocean_assert(anyCamera.
isValid());
633 ocean_assert(steps != 0);
636 ocean_assert(!step.
isNull());
640 Vector3 previousPlanePoint = pointA;
643 for (
size_t s = 0; s < steps; ++s)
645 const Vector3 currentPlanePoint = previousPlanePoint + step;
648 CV::Canvas::line<tLineWidth>(frame, previousImagePoint, currentImagePoint, color);
650 previousPlanePoint = currentPlanePoint;
651 previousImagePoint = currentImagePoint;
655 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
658 static_assert(tForegroundLineWidth != 0u && tForegroundLineWidth % 2u == 1u,
"The line width must be non-zero and odd.");
659 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.");
661 ocean_assert(frame && flippedCamera_T_world.
isValid() && anyCamera.
isValid());
663 ocean_assert(segments >= 1u);
667 if (backgroundColor && tBackgroundLineWidth != 0u)
671 for (
unsigned int n = 0u; n < segments; ++n)
673 const Vector3 end = objectPoint0 + (objectPoint1 - objectPoint0) *
Scalar(n + 1) * segmentFactor;
676 CV::Canvas::line<tBackgroundLineWidth>(frame, projectedStart.
x(), projectedStart.
y(), projectedEnd.
x(), projectedEnd.
y(), backgroundColor);
678 projectedStart = projectedEnd;
686 for (
unsigned int n = 0u; n < segments; ++n)
688 const Vector3 end = objectPoint0 + (objectPoint1 - objectPoint0) *
Scalar(n + 1) * segmentFactor;
691 CV::Canvas::line<tForegroundLineWidth>(frame, projectedStart.
x(), projectedStart.
y(), projectedEnd.
x(), projectedEnd.
y(), foregroundColor);
693 projectedStart = projectedEnd;
698 template <
unsigned int tForegroundLineW
idth,
unsigned int tBackgroundLineW
idth>
701 static_assert(tForegroundLineWidth != 0u && tForegroundLineWidth % 2u == 1u,
"The line width must be non-zero and odd.");
702 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.");
704 ocean_assert(frame && flippedCamera_T_world.
isValid() && anyCamera.
isValid() && world_T_coordinateSystem.
isValid());
714 const Vector3 xAxis = world_T_coordinateSystem *
Vector3(length, 0, 0);
715 const Vector3 yAxis = world_T_coordinateSystem *
Vector3(0, length, 0);
716 const Vector3 zAxis = world_T_coordinateSystem *
Vector3(0, 0, length);
720 drawLineIF<tForegroundLineWidth, tBackgroundLineWidth>(frame, flippedCamera_T_world, anyCamera, world_T_coordinateSystem.
translation(), xAxis, 15u, red, black);
725 drawLineIF<tForegroundLineWidth, tBackgroundLineWidth>(frame, flippedCamera_T_world, anyCamera, world_T_coordinateSystem.
translation(), yAxis, 15u, green, black);
730 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
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:115
Scalar convertCodeSpaceToObjectSpaceX(const Scalar xCodeSpace) const
Converts an x-coordinate from code space to object space.
Definition: cv/detector/qrcodes/Utilities.h:561
Scalar convertCodeSpaceToObjectSpaceY(const Scalar yCodeSpace) const
Converts an y-coordinate from code space to object space.
Definition: cv/detector/qrcodes/Utilities.h:569
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...
Scalar scale_
Global factor for coordinate scaling.
Definition: cv/detector/qrcodes/Utilities.h:213
Scalar scale() const
Returns the scaling factor that is used for coordinate scaling.
Definition: cv/detector/qrcodes/Utilities.h:556
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 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:219
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...
Scalar xScale_
The scale factor for x-coordinates.
Definition: cv/detector/qrcodes/Utilities.h:216
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:577
Definition of utility functions related to the detection of QR codes.
Definition: cv/detector/qrcodes/Utilities.h:41
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:656
static Scalar computeModuleDiagonalLength(const AnyCamera &anyCamera, const HomogenousMatrix4 &flippedCamera_T_code, const CoordinateSystem &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 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 computeContrast(const AnyCamera &anyCamera, const Frame &yFrame, const HomogenousMatrix4 &world_T_camera, const QRCode &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 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 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 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:600
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:617
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:592
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:699
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:48
@ 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:56
@ 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:60
@ PS_ERROR_INVALID_PREFIX
Indicates that the input has an invalid prefix.
Definition: cv/detector/qrcodes/Utilities.h:52
@ PS_ERROR_INVALID_FIELD_TYPE
Indicates that field type is unknown or invalid.
Definition: cv/detector/qrcodes/Utilities.h:58
@ 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:54
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:1760
bool isValid() const
Returns whether this frame is valid.
Definition: Frame.h:4416
@ 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:3111
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition: Frame.h:3156
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:3121
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition: Frame.h:1018
unsigned int height() const
Returns the height of the frame in pixel.
Definition: Frame.h:3116
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< QRCode > QRCodes
Definition of a vector of QR codes.
Definition: QRCode.h:25
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15