Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv 4.1.2 - TypeError: Expected Ptr<cv::umat> for argument '%s'

I have opencv 4.1.2 installed on pi3B+ with a picamera connected and I am trying to use cv2 to find contours in delta image frame; here's the traceback that I get if cv2.contourArea(c) < conf["min_area"]: TypeError: Expected Ptr<cv::umat> for argument '%s'

Here's the code snippet that throws the above Traceback:

threshold delta image, dilate threshold image to fill in holes, then find contours on threshold image

thresh = cv2.threshold(frameDelta, conf["delta_thresh"], 255, cv2.THRESH_BINARY)[1]
thresh = cv2.dilate(thresh, None, iterations=2)
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

loop over contours

for c in cnts: #if contour is too small, ignore it if cv2.contourArea(c) < conf["min_area"]: continue

# compute bounding box for contour, draw it on the frame and update text
(x, y, w, h) = cv2.boundingRect(c)
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
text = "Occupied"

Is it a bug in cv 4.1.2? I noticed a similar bug was fixed in version 3.4 (#15834). If yes, will the fix be merged in opencv 4.1.2?

click to hide/show revision 2
None

updated 2019-12-26 02:08:29 -0600

berak gravatar image

opencv 4.1.2 - TypeError: Expected Ptr<cv::umat> for argument '%s'

I have opencv 4.1.2 installed on pi3B+ with a picamera connected and I am trying to use cv2 to find contours in delta image frame; here's the traceback that I get if cv2.contourArea(c) < conf["min_area"]: TypeError: Expected Ptr<cv::umat> for argument '%s'

Here's the code snippet that throws the above Traceback:

threshold
#threshold delta image, dilate threshold image to fill in holes, then find contours on threshold image

image
thresh = cv2.threshold(frameDelta, conf["delta_thresh"], 255, cv2.THRESH_BINARY)[1]
 thresh = cv2.dilate(thresh, None, iterations=2)
 cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

# loop over contours

contours for c in cnts: #if contour is too small, ignore it if **if cv2.contourArea(c) < conf["min_area"]: continue

conf["min_area"]:**
continue
# compute bounding box for contour, draw it on the frame and update text
 (x, y, w, h) = cv2.boundingRect(c)
 cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
 text = "Occupied"

Is it a bug in cv 4.1.2? I noticed a similar bug was fixed in version 3.4 (#15834). If yes, will the fix be merged in opencv 4.1.2?