Skip to content

Segmentation Fault Using cv2.connectedComponentsWithStats #606

@chrisdonlan

Description

@chrisdonlan

Expected behaviour

Returns valid outputs corresponding to the following line of code given a numpy.ndarray binary image (black = 0, white = 255) of uint8 pixels:

self.count, self.mask, stats, centroids = cv2.connectedComponentsWithStats(
    cc_img.astype(np.uint8)), connectivity=connectivity
)

Actual behaviour

After raising my minimum allowed opencv-python version from 4.5.1 to 4.5.4, this error emerged.

Steps to reproduce

  • example code
import numpy as np

X = np.random.randint(0, 1, (100, 100))
X_img = (X * 255).astype(np.uint8)

import cv2
count, mask, stats, centroids = cv2.connectedComponentsWithStats(X_img, connectivity=4)

Result: Segmentation fault: 11

  • operating system

MacOSX "Darwin", Kernel Version 20.6.0

  • architecture (e.g. x86)

x86_64

  • opencv-python version

opencv-python 4.5.5.62

Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python

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