Skip to content

Segmentation fault for cv2.dnn.readNetFromDarknet.forward() on macOS with 4.7.0.68 #23072

@scito

Description

@scito

System Information

OpenCV python version: 4.7.0.68
Operating System / Platform: macos-latest and macos-11
Python version: 3.11.1

It passes with 4.6.0.66 on all plattforms including macos.
It passes with 4.7.0.68 on linux and windows

Detailed description

Fatal Python error: Segmentation fault occurs for cv2.dnn.readNetFromDarknet.forward()

Steps to reproduce

print('cv2.imread')
img = cv2.imread('tests/data/test_googleauth_export.png')

yolo_v3_QR_detector = cv2.dnn.readNetFromDarknet(cfgFile='tests/data/qrcode-yolov3-tiny.cfg', darknetModel='tests/data/qrcode-yolov3-tiny_last.weights')
yolo_v3_QR_detector.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)

output_layer_names = yolo_v3_QR_detector.getLayerNames()
output_layer_name = output_layer_names[yolo_v3_QR_detector.getUnconnectedOutLayers()[0] - 1]

print('cv2.dnn.blobFromImage')
_INPUT_SIZE = (416, 416)
_CONF_THRESHOLD = 0.5

blob = cv2.dnn.blobFromImage(img, 1 / 255, _INPUT_SIZE, swapRB=False, crop=False)

print('yolo.yolo_v3_QR_detector.setInput')
yolo_v3_QR_detector.setInput(blob=blob)

# Transform the image to blob and predict
print('yolo_v3_QR_detector.forward')
output = yolo_v3_QR_detector.forward(output_layer_name)  # <========= Segmentation fault

print('Done')

Full code to reproduce including data can be found in the following branch: https://github.com/scito/extract_otp_secret_keys/tree/cv2_segfault_repro_1
Note: GitHub actions CI is enabled on this branch.

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions