Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jbneto1 opened this issue May 19, 2025 · 0 comments

Comments

@jbneto1
Copy link

jbneto1 commented May 19, 2025

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant