Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem in Drawing Contour

Hi guys I have written a simple code which draws the contour.

import numpy as np
import cv2
img = cv2.imread('New Bitmap Image.bmp')  
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)   
ret,thresh = cv2.threshold(gray,129,255,cv2.THRESH_BINARY)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print len(contours)
cv2.drawContours(thresh,contours,-1,(0,255,0),3)

cv2.imshow('thresh1',thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()

Instead of drwaing contour it gives a black screen . I dont know why this happens

I am using python 2.7 with cv2

Input image is image description

Problem in Drawing Contour

Hi guys I have written a simple code which draws the contour.

import numpy as np
import cv2
img = cv2.imread('New Bitmap Image.bmp')  
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)   
ret,thresh = cv2.threshold(gray,129,255,cv2.THRESH_BINARY)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
print len(contours)
cv2.drawContours(thresh,contours,-1,(0,255,0),3)

cv2.imshow('thresh1',thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()

Instead of drwaing contour it gives a black screen . I dont know why this happens

I am using python 2.7 with cv2

Input image is

image description