Open
Description
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
- Set up a Python script that uses OpenCV's ArUco detection
- Use the ArUco's:
cv2.aruco.getPredefinedDictionary()
andcv2.aruco.DetectorParameters()
- Call
cv2.aruco.detectMarkers()
with the created dictionary and parameters - 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 ofcv2.aruco.getPredefinedDictionary()
- Use
cv2.aruco.DetectorParameters_create()
instead ofcv2.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
Labels
No labels