mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #29252 from JonasPerolini:pr-aruco-bit-threshold-in-refine
Use validBitIdThreshold for Aruco refineDetectedMarkers #29252 The goal of this PR is to solve the issue raised by @vrabaud in https://github.com/opencv/opencv/pull/28289 (comment: https://github.com/opencv/opencv/pull/28289#discussion_r3355812646). **Issue:** `refineDetectedMarkers()` converted the extracted cell ratios with `convertTo(CV_8UC1)` (an implicit 0.5 threshold) before computing the code distance, ignoring `detectorParams.validBitIdThreshold`. **Solution:** Make the refine path consistent with the main detection path `Dictionary::identify`. **Changes:** - Add a `Dictionary::getDistanceToId()` overload that takes the float cell pixel ratio matrix and `validBitIdThreshold` (similar to how it's done for the `identify()` overload. - Move the per cell distance computation into a private `getDistanceToIdImpl` helper used by both `identify()` and the new overload of `getDistanceToId()` to avoid repetitions. - `refineDetectedMarkers()` now calls the new overload. **Tests:** - `CV_ArucoRefine.validBitIdThreshold`: a marker with one degraded cell is recovered at threshold 0.7 but not at 0.49. - `CV_ArucoDictionary.getDistanceToIdCellPixelRatio`: unit-tests both `getDistanceToId` overloads. All passed
This commit is contained in:
@@ -65,7 +65,7 @@ class CV_EXPORTS_W_SIMPLE Dictionary {
|
||||
*/
|
||||
CV_WRAP bool identify(const Mat &onlyBits, CV_OUT int &idx, CV_OUT int &rotation, double maxCorrectionRate) const;
|
||||
|
||||
/** @brief Given a matrix of pixel ratio raging from 0 to 1. Returns whether if marker is identified or not.
|
||||
/** @brief Given a matrix of pixel ratio ranging from 0 to 1. Returns whether the marker is identified or not.
|
||||
*
|
||||
* Returns reference to the marker id in the dictionary (if any) and its rotation.
|
||||
*/
|
||||
@@ -77,6 +77,22 @@ class CV_EXPORTS_W_SIMPLE Dictionary {
|
||||
*/
|
||||
CV_WRAP int getDistanceToId(InputArray bits, int id, bool allRotations = true) const;
|
||||
|
||||
/** @brief Returns number of cells that differ from the specific id.
|
||||
*
|
||||
* For each cell, the distance is increased when the difference between the detected
|
||||
* cell pixel ratio and the dictionary bit value is greater than `validBitIdThreshold`.
|
||||
* If `allRotations` is set, the four possible marker rotations are considered.
|
||||
*
|
||||
* @param onlyCellPixelRatio markerSize x markerSize matrix (CV_32FC1) holding, for each cell,
|
||||
* the ratio of white pixels ranging from 0 to 1
|
||||
* @param id marker id in the dictionary to compute the distance to
|
||||
* @param allRotations if set, the four possible marker rotations are considered and the
|
||||
* smallest distance is returned
|
||||
* @param validBitIdThreshold maximum allowed difference between a cell pixel ratio and the
|
||||
* dictionary bit value; cells exceeding it are counted as differing
|
||||
*/
|
||||
CV_WRAP int getDistanceToId(InputArray onlyCellPixelRatio, int id, bool allRotations, float validBitIdThreshold) const;
|
||||
|
||||
/** @brief Generate a canonical marker image
|
||||
*/
|
||||
CV_WRAP void generateImageMarker(int id, int sidePixels, OutputArray _img, int borderBits = 1) const;
|
||||
|
||||
Reference in New Issue
Block a user