Here is my problem, i have multiple objects in an single image (example 5 objects, object1, object2 so on ) I want to draw all objects contour individually , example object1 on black back ground, Object2 on Black Back Ground so on so that i can later find white pixel coordinate of respective object and take up some decision for my algorithm
here is the code i tried,but i got error: (-215:Assertion failed) 0 <= contourIdx && contourIdx < (int)last in function 'cv::drawContours'
blank = np.zeros(frame.shape[0:2], dtype='uint8')
Backupblank = np.zeros(frame.shape[0:2], dtype='uint8')
contours, hierarchy = cv.findContours(bw_img, cv.RETR_LIST, cv.CHAIN_APPROX_NONE)
for cnt in contours:
ImgContour = ImgContour + 1
cv.drawContours(blank, contours, ImgContour, (255,255,255), -1)
Backupblank = blank
blank = np.zeros(frame.shape[0:2], dtype='uint8')