This error occurs in OpenCV when trying to calculate the contour area of a shape, and can be caused by two possible issues:

  1. The number of points in the shape is negative: This means that there is an issue with the contour points that were provided. Check that the contour points are valid and that there are no missing or duplicate points.

  2. The depth of the contour points is not CV_32F or CV_32S: OpenCV requires that the depth of the contour points be either CV_32F (32-bit floating point) or CV_32S (32-bit signed integer). Check that the depth of the contour points is correct and convert them to the correct data type if necessary.

To resolve this error, ensure that the contour points are valid and that the depth is either CV_32F or CV_32S.

解决 OpenCV 'cv2.error: OpenCV(4.7.0) ... in function 'cv::contourArea'' 错误

原文地址: https://www.cveoy.top/t/topic/neLj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录