Skip to content

cv2.contourArea(cnt) #5

@sudhasubramaniam

Description

@sudhasubramaniam

This is my code
import cv2
import numpy as np
img = cv2.imread('index.jpeg',0)
ret,thresh = cv2.threshold(img,127,255,0)
_,contours,hierarchy= cv2.findContours(thresh, 1, 2)

cnt = contour[0]
M = cv2.moments(cnt)
print(M)
area = cv2.contourArea(cnt)
perimeter = cv2.arcLength(cnt,True)

I'm getting this error. some one pls help me resolving it.
error: /tmp/build/80754af9/opencv_1512491964794/work/modules/imgproc/src/shapedescr.cpp:319: error: (-215) npoints >= 0 && (depth == 5 || depth == 4) in function contourArea

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions