Ask Your Question

Revision history [back]

Python Opencv Structured Forests Edge Detection TypeError

When I call the OpenCV Structured Forests Edge Detection in Python as shown below, I get an error:

import numpy as np
import cv2

img = cv2.imread('2009_005193.jpg')
gray_img = np.asarray(img.mean(axis=2) / 255, np.float32)
out = cv2.ximgproc_StructuredEdgeDetection.detectEdges(gray_img)

The error I get is:

Traceback (most recent call last):
  File "", line 19, in <module>
    out = cv2.ximgproc_StructuredEdgeDetection.detectEdges(gray_img)
TypeError: descriptor 'detectEdges' requires a 'cv2.ximgproc_StructuredEdgeDetection' object but received a 'numpy.ndarray'

In the documentation (link to documentation), detectEdges() is present under ximgproc_StructuredEdgeDetection.

I am not sure what I am doing wrong.