why this code loop forever after a draw a rectangle
Joonas Liik
liik.joonas at gmail.com
Fri Sep 16 07:33:49 EDT 2016
On 16 September 2016 at 14:24, meInvent bbird <jobmattcon at gmail.com> 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)
> #print("len(approx)="+str(len(approx)))
> if len(approx) == 4:
> print("approx=" + str(approx))
> cntcounter = cntcounter + 1
> print("here1")
> x,y,w,h = cv2.boundingRect(cnt)
> print("here2")
> while im is None:
> time.sleep(1)
> if im is not None:
> print("here3")
> 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)
>
>
> cv2.imwrite(r'C:\Users\tester\Documents\masda.png',im)
> --
> https://mail.python.org/mailman/listinfo/python-list
not sure but.. this bit reads really suspicious:
while im is None:
time.sleep(1)
if im is ever None then how will it ever become not None? unless there
is some other thread at work i can't really see this happening.
and if there is some other thread at work then there is probably some
better solution than sleep()
More information about the Python-list
mailing list