import numpy as np
import cv2
img = cv2.imread("/home/user/Pictures/shapes_and_colors.png")
_,threshold = cv2.threshold(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY),60,255,cv2.THRESH_BINARY)
_,contours = cv2.findContours(threshold,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
[x,y,w,h] = cv2.boundingRect(contour)
I got this error
error: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/shapedescr.cpp:784: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'pointSetBoundingRect'
How to remove this error.