Skip to main content

Python based detector detecting position and orientation of circular pads. This detection is based on the positions of the partial shapes (inner halls) and ArUco marker(s).

Project description

Circle & ArUco Marker Detector

01.02.2026: Julia Škovierová, Pavel Krsek, David Svitak

The detector was developed within the framework of the DeKrys project to estimate the position of the destination plate. The plate is a circle made of metal (copper or aluminium). There are three small holes in the plate. The small holes are evenly spaced on a circle. The plate is usually provided by an ArUco marker. The ArUco marker is placed outside the main circle of the plate on the attached small square plate. The ArUco marker identifies the plate and defines a unique coordinate system.

This Python module provides a simple class-based interface to detect circles and ArUco markers in an image using OpenCV. It returns information such as the center, perimeter, and marker ID (if available).


Requirements

  • Python 3.10+
  • NumPy standard library
  • OpenCV with ArUco support
  • Instalation:
pip install -r requirements.txt

or better using the uv python packaging manager

uv venv
uv lock --upgrade
uv sync --dev

Instalation

Project can be installed directly trough pip

pip install CircleDetector

Usage

The CircleDetector require specification of shape it is looking for in the image.

Shape specification file

Here is json file containing the shape of an specific pad. Note that the plate abd aruco_code keys are required.

{
  "plate": {
    "type": "circle",
    "diameter": 30.0
  },
  "aruco_code": {
    "id": 5,
    "size": 5.0,
    "type": "DICT_4X4_50"
  },
  "holes": [
    {
      "type": "circle",
      "diameter": 3.0,
      "dist_from_center": 11.5,
      "angle_deg": 0.0
    },
    {
      "type": "circle",
      "diameter": 3.0,
      "dist_from_center": 11.5,
      "angle_deg": 120.0
    },
    {
      "type": "circle",
      "diameter": 3.0,
      "dist_from_center": 11.5,
      "angle_deg": 240.0
    }
  ]
}

Example

import CircleDetector

# 1. Prepare the image as np.ndarraz

image = cv2.imread("path/to/image.png")

# 2. Create Detector Instance with the shape configuration file. 
# It also help if you know the ppm of the camera that took the picture

with open("path/to/file/shape_config.json", "r") as config:
  shape_config = json.load(config)
circle_detector = CircleDetector(config=shape_config, ppm = 27.001)

# 3. Run Detection

large_circle_data = circle_detector.detect(original_image=image, refine_circles = True)

Output Format - example

List of "large circles" is output of the detector. It is list of CircleDetection dataclasses described in the typeClass.

Parameters of CircleDetection dataclass:

  • center - vector defines the position of the large circle center in the image coordinate system [columns, rows].
  • radius - radius of the large circle in pixels.
  • small_circles - matrix of the small circle parameters. 3 small circles should be inside the large circle. Each row of the matrix corresponds to one small circle and contains the position of the center and radius in pixels in order: [columns, rows, radius].
  • marker_center - vector defines position of the ArUco marker center in the image coordinate system [columns, rows].
  • marker_id - the numeric ID of the ArUco marker.
  • marker_corners - positions of the ArUco marker corners written in the matrix, where each row corresponds to one corner.
  • marker_angle - angle in radians between row and vector defined by points: circle_center, marker_center. The coordinates are in the image coordinate system in order (in each line): [columns, rows].

Note: All the positon parameters are in pixels.

Example of the output

[
    {
        "center": [2043.7399455436005, 1168.2050984495788], 
        "radius": 394.06181273076515, 
        "small_circles": [
            [1755.4770265994944, 1076.191785488278, 39.22459052417032], 
            [2262.807828140135, 962.7916276277658, 39.09135996015619], 
            [2107.1382180760556, 1456.9808042095924, 37.638359777725334]
        ], 
        "marker_center": [2388.75, 849.0], 
        "marker_id": 7, 
        "marker_corners": [
            [2298.0, 843.0], 
            [2396.0, 759.0], 
            [2479.0, 856.0], 
            [2382.0, 938.0]
        ], 
        "marker_angle": 0.7465673948230674
    }
]

Notes

In case that the refinement option is selected, but not enough points are found to recalculate the circle, the value for the center and radius remains unchanged

Authors & contributions

  • Julia ŠkovierováAlghoritm development:
  • Pavel KrsekAlghoritm development:
  • David Sviták (@DavidSvitak) — Integration and testing:
  • Štěpán Venclík (@StepanVenclik) — Automatization and Integration:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circledetector-1.1.2.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

circledetector-1.1.2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file circledetector-1.1.2.tar.gz.

File metadata

  • Download URL: circledetector-1.1.2.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for circledetector-1.1.2.tar.gz
Algorithm Hash digest
SHA256 aaee3be7828bb970ff9ab5a7d91ef37765d33d9c67d20d241f42495907cbfa0b
MD5 b5bffc38b5cb4081ec39c7af7f832624
BLAKE2b-256 b637c2e96da4238875f2a85020fa5db3c2e641407a8ff1477a91d40421cd1caf

See more details on using hashes here.

File details

Details for the file circledetector-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: circledetector-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for circledetector-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 965afdc01e8df3023a94a4aeb0241ffb834bc0c3ad7f62b01933956cbae6c047
MD5 9d36bb7f2c746c559ec562a8ea7fdbc6
BLAKE2b-256 39ead3d2e74126e567af954f8ec8d1fcbd57f7ca19ca98b6fd90a95fc23a48c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page