简体   繁体   中英

Python - opencv Draw Bounding Boxes around Canny edge image

I have a image that processed to find edges with canny edges algorithm, now i need to draw bounding boxes around this shapes. The problem is that when i use

cv2.findContours

i get this error

error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/contours.cpp:197: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl'

the image is the shape of a pig. 在此处输入图片说明

How can i accomplish this?

Need more information about your situation, but it looks like you have to convert your image before using that function. like

image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = image.astype("uint8")

try execute this code before using that function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM