On 09/16/2016 04:24 AM, meInvent bbird wrote:
im = img.copy()
cntcounter = 0
for cnt in contours:
         epsilon = 0.1*cv2.arcLength(cnt,True)
         approx = cv2.approxPolyDP(cnt,epsilon,True)    
         #peri = cv2.arcLength(cnt, True)
         #approx = cv2.approxPolyDP(c, 0.5 * peri, True)
         if len(approx) == 4:
             print("approx=" + str(approx))
             cntcounter = cntcounter + 1
             x,y,w,h = cv2.boundingRect(cnt)
             while im is None:
             if im is not None:
                 im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2)
                 #im = cv2.line(im,(x,y),(x+w,y),(0,255,0),2)
                 #im = cv2.line(im,(x+w,y),(x+w,y+h),(0,255,0),2)
                 #im = cv2.line(im,(x,y+h),(x+w,y+h),(0,255,0),2)
                 #im = cv2.line(im,(x,y),(x,y+h),(0,255,0),2)


These two lines:

  while im is None:

are an infinite loop if im is None;

Since you haven't told us what im (or img, contours, cv2) are, I can't tell how im might become None, but it does look like you (confusingly) use im for two different things: an img.copy() and a cv2.rectangle, whatever those may be.

Pure guesswork: if cv2.rectangle draws a rectangle, what does it return? If it doesn't return anything, the line
    im = cv2.rectangle(...)
is how im gets the value of None.

Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology
(425) 895-4418


Reply via email to