Skip to content

Segmentation Fault in ArUco Detection on Raspberry Pi (ARM) with OpenCV 4.6.0 #3938

Open
@jbneto1

Description

@jbneto1

Environment

  • Hardware: Raspberry Pi 5
  • Operating System: Raspberry Pi OS (Bookworm)
  • OpenCV Version: 4.6.0
  • Python Version: 3.11
  • Camera: PiCamera2 with libcamera v0.5.0, libpisp version v1.2.1

Description

When running ArUco marker detection on Raspberry Pi using the OpenCV 4.6.0 API methods, the program crashes with a segmentation fault. The crash happens specifically during the cv2.aruco.detectMarkers() call.

Steps to Reproduce

  1. Set up a Python script that uses OpenCV's ArUco detection
  2. Use the ArUco's: cv2.aruco.getPredefinedDictionary() and cv2.aruco.DetectorParameters()
  3. Call cv2.aruco.detectMarkers() with the created dictionary and parameters
  4. The program crashes with SIGSEGV at a very low memory address (0x60)

Crash Information

When run with strace, the program shows the following crash pattern:


[DEBUG timestamp] Memory usage before detection: 174.37109375 MB
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x60} ---
+++ killed by SIGSEGV +++

Workaround

The issue can be resolved by using the older ArUco API functions:

  • Use cv2.aruco.Dictionary_get() instead of cv2.aruco.getPredefinedDictionary()
  • Use cv2.aruco.DetectorParameters_create() instead of cv2.aruco.DetectorParameters()

Code Sample to Reproduce

import cv2
import numpy as np

# Setup camera and capture frame
# ...

# This crashes on ARM/Raspberry Pi
aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_5X5_50)
parameters = cv2.aruco.DetectorParameters()
corners, ids, rejected = cv2.aruco.detectMarkers(gray_image, aruco_dict, parameters=parameters)

# This works (using older API)
dictionary = cv2.aruco.Dictionary_get(cv2.aruco.DICT_5X5_50)
parameters = cv2.aruco.DetectorParameters_create()
corners, ids, rejected = cv2.aruco.detectMarkers(gray_image, dictionary, parameters=parameters)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions