Skip to content

refineDetectedMarkers return different arrays depending on if new markers were found #2720

@Ofenhed

Description

@Ofenhed
System information (version)
  • OpenCV => 4.5.0-1 (via Python 3)
  • Operating System / Platform => Arch Linux x64
  • Compiler => Installed via Arch pacman
Detailed description

The function refineDetectedMarkers returns different lists depending on whether it finds new markers or not. The following list are the detectedIds as they are before calling refineDetectedMarkers:

[array([[[2189.961 , 4129.8223],
        [2423.625 , 4104.6997],
        [2496.3433, 4220.5117],
        [2247.3022, 4247.493 ]]], dtype=float32), array([[[1983.1108, 4056.9077],
        [2162.0933, 4126.974 ],
        [2000.5653, 4216.961 ],
        [1821.8195, 4140.437 ]]], dtype=float32), array([[[1980.4174, 3944.8262],
        [1972.7639, 4044.8574],
        [1745.5054, 4043.5725],
        [1766.1394, 3943.3354]]], dtype=float32), array([[[2447.0383, 4095.2173],
        [2535.8245, 3999.946 ],
        [2756.3477, 4044.2703],
        [2676.597 , 4145.6904]]], dtype=float32)]

And the following is the list returned:

[array([[[2189.961 , 4129.8223]],
       [[2423.625 , 4104.6997]],
       [[2496.3433, 4220.5117]],
       [[2247.3022, 4247.493 ]]], dtype=float32), array([[[1983.1108, 4056.9077]],
       [[2162.0933, 4126.974 ]],
       [[2000.5653, 4216.961 ]],
       [[1821.8195, 4140.437 ]]], dtype=float32), array([[[1980.4174, 3944.8262]],
       [[1972.7639, 4044.8574]],
       [[1745.5054, 4043.5725]],
       [[1766.1394, 3943.3354]]], dtype=float32), array([[[2447.0383, 4095.2173]],
       [[2535.8245, 3999.946 ]],
       [[2756.3477, 4044.2703]],
       [[2676.597 , 4145.6904]]], dtype=float32), array([[[2173.7258, 3877.364 ]],
       [[1994.933 , 3934.5142]],
       [[1874.378 , 3861.4165]],
       [[2037.4222, 3808.2634]]], dtype=float32)]

As refineDetectedMarkers does not modify the list if no new markers are found, this means that the return value of refineDetectedMakers can be either [array([[4*[x, y]]])] or [array([4*[[x, y]]])].

Steps to reproduce
    para = aruco.DetectorParameters_create()
    para.cornerRefinementMethod = aruco.CORNER_REFINE_SUBPIX
    det_corners, det_ids, rejected = aruco.detectMarkers(image, someMarkers, parameters=para)
    coords = np.array([[np.append(y, [1]) for y in x] for x in markers.values()], 'float32')
    ids = np.array([[x] for x in markers.keys()])
    board = aruco.Board_create(coords, lightTriggerMarkers, ids)
    new_det_corners, new_det_ids, new_rejected, recovered = aruco.refineDetectedMarkers(gray, board, det_corners[:-1], det_ids[:-1], rejected + det_corners[-1:], parameters=para, errorCorrectionRate=3., checkAllOrders=False)
    print(f"Corners changed from {det_corners} to {new_det_corners}")

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution only since a problem with inconsistent return types is obviously a bug
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc Look, I'm sorry. I've worked around the issue in my code, I'm just here to help you and just finding how python libraries are generated, to find the correct repository to report to, and write this report, has taken way too long already. The code above is usable if you provide an image with aruco markers and load it into the code.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions