Re: why this code loop forever after a draw a rectangle
after succeed to draw lines in graph, however, https://drive.google.com/file/d/0Bxs_ao6uuBDUWVBFZzVIVGotRlk/view?usp=sharing expected the blue line connect the bottom of red line graph https://drive.google.com/file/d/0Bxs_ao6uuBDUNGZFS2F3WnJERzA/view?usp=sharing how can convex hull be adjusted to do like second graph of sky blue line On Saturday, September 17, 2016 at 7:48:46 AM UTC+8, meInvent bbird wrote: > img is the image > > im is a new memory of image using img.copy() > > > On Saturday, September 17, 2016 at 7:46:42 AM UTC+8, meInvent bbird wrote: > > thank you very much, > > it out of the loop now. > > because drawLine function return things > > > > i just change drawLine to rectangle, > > have not thought that rectangle not return thing, just edit the parameter > > > > > > > > On Saturday, September 17, 2016 at 5:26:53 AM UTC+8, MRAB wrote: > > > On 2016-09-16 20:14, Gary Herron wrote: > > > > 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) > > > >> #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) > > > > > > > > > > > > These two lines: > > > > > > > >while im is None: > > > > time.sleep(1) > > > > > > > > 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. > > > > > > > It looks like the OP is using OpenCV. > > > > > > You're right about cv2.rectangle; it does return None. > > > > > > The line: > > > > > > im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2) > > > > > > makes a copy of the image im, draws a rectangle on it, and then binds > > > None to im. > > > > > > The copied rectangle is discarded because there's no reference to it, so > > > the entire line in pointless. > > > > > > It basically does the same thing as: > > > > > > im = None > > > > > > only slower! -- https://mail.python.org/mailman/listinfo/python-list
Re: why this code loop forever after a draw a rectangle
img is the image im is a new memory of image using img.copy() On Saturday, September 17, 2016 at 7:46:42 AM UTC+8, meInvent bbird wrote: > thank you very much, > it out of the loop now. > because drawLine function return things > > i just change drawLine to rectangle, > have not thought that rectangle not return thing, just edit the parameter > > > > On Saturday, September 17, 2016 at 5:26:53 AM UTC+8, MRAB wrote: > > On 2016-09-16 20:14, Gary Herron wrote: > > > 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) > > >> #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) > > > > > > > > > These two lines: > > > > > >while im is None: > > > time.sleep(1) > > > > > > 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. > > > > > It looks like the OP is using OpenCV. > > > > You're right about cv2.rectangle; it does return None. > > > > The line: > > > > im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2) > > > > makes a copy of the image im, draws a rectangle on it, and then binds > > None to im. > > > > The copied rectangle is discarded because there's no reference to it, so > > the entire line in pointless. > > > > It basically does the same thing as: > > > > im = None > > > > only slower! -- https://mail.python.org/mailman/listinfo/python-list
Re: why this code loop forever after a draw a rectangle
thank you very much, it out of the loop now. because drawLine function return things i just change drawLine to rectangle, have not thought that rectangle not return thing, just edit the parameter On Saturday, September 17, 2016 at 5:26:53 AM UTC+8, MRAB wrote: > On 2016-09-16 20:14, Gary Herron wrote: > > 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) > >> #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) > > > > > > These two lines: > > > >while im is None: > > time.sleep(1) > > > > 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. > > > It looks like the OP is using OpenCV. > > You're right about cv2.rectangle; it does return None. > > The line: > > im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2) > > makes a copy of the image im, draws a rectangle on it, and then binds > None to im. > > The copied rectangle is discarded because there's no reference to it, so > the entire line in pointless. > > It basically does the same thing as: > > im = None > > only slower! -- https://mail.python.org/mailman/listinfo/python-list
Re: why this code loop forever after a draw a rectangle
On 2016-09-16 20:14, Gary Herron wrote: 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) #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) These two lines: while im is None: time.sleep(1) 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. It looks like the OP is using OpenCV. You're right about cv2.rectangle; it does return None. The line: im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2) makes a copy of the image im, draws a rectangle on it, and then binds None to im. The copied rectangle is discarded because there's no reference to it, so the entire line in pointless. It basically does the same thing as: im = None only slower! -- https://mail.python.org/mailman/listinfo/python-list
Re: why this code loop forever after a draw a rectangle
On 09/16/2016 05:18 AM, meInvent bbird wrote: i follow this post to give some time it to operate, wait a long time still looping http://answers.opencv.org/question/60094/libpng-warning-image-width-is-zero-in-ihdr/ i can not stand this Ninja coding life any more, i have to open my code for ask this error import cv2 import numpy as np #from matplotlib import pyplot as plt import time #print("1=" + str(int(sys.argv[1]))) #print("2=" + str(int(sys.argv[2]))) #print("3=" + str(int(sys.argv[3]))) img_rgb = cv2.imread(r'C:\Users\martin\Documents\scree2.png') img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) template = cv2.imread(r'C:\Users\martin\Documents\dragob.png',0) w, h = template.shape[::-1] res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED) threshold = 0.64 loc = np.where( res >= threshold) pt = [(0,0)] while not zip(*loc[::-1]): threshold = threshold - 0.02 loc = np.where( res >= threshold) counter = 1 print("threshold="+str(threshold)) for pt2 in zip(*loc[::-1]): cv2.rectangle(img_rgb, pt2, (pt2[0] + w, pt2[1] + h), (0,0,255), 2) pt = pt2 crop_img = img_rgb[pt[1]:(pt[1]+h), pt[0]:(pt[0]+w)] counter = counter + 1 cv2.imwrite("C:\\Users\\tester\\Documents\\res.png",crop_img) #import cv2 #winName = "Movement Indicator" #cv2.namedWindow(winName, cv2.WINDOW_NORMAL) img = cv2.imread(r'C:\Users\tester\Documents\res.png',1) gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) height, width = gray.shape edges = cv2.Canny(gray,height,width,apertureSize = 3) #edges = cv2.Canny(gray,30,200) #gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) #ret,thresh = cv2.threshold(edges.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE,0) ret,thresh = cv2.threshold(edges,250,150,0) contours,hierarchy = cv2.findContours(thresh, 1, 2) #contours = sorted(contours, key = cv2.contourArea, reverse = True)[:10] 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") #im = img.copy() 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) #cv2.imwrite("C:\\Users\\martin\\Documents\\masda"+str(cntcounter)+".png",imi) #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) On Friday, September 16, 2016 at 7:34:04 PM UTC+8, Waffle wrote: On 16 September 2016 at 14:24, meInvent bbirdwrote: 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() Reading the manual for opencv, we see that cv2.rectangle does indeed return None: Python: cv.Rectangle(img, pt1, pt2, color, thickness=1, lineType=8, shift=0) → None So the first pass through your loop does indeed set im to None with the line im = cv2.rectangle(im.copy(), (x,y), (x+w, y+h), (0,255,0), 2) and the next pass through the loop hits the infinite loop: while im is None: time.sleep(1)
Re: why this code loop forever after a draw a rectangle
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) #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) These two lines: while im is None: time.sleep(1) 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 -- https://mail.python.org/mailman/listinfo/python-list
Re: why this code loop forever after a draw a rectangle
i follow this post to give some time it to operate, wait a long time still looping http://answers.opencv.org/question/60094/libpng-warning-image-width-is-zero-in-ihdr/ i can not stand this Ninja coding life any more, i have to open my code for ask this error import cv2 import numpy as np #from matplotlib import pyplot as plt import time #print("1=" + str(int(sys.argv[1]))) #print("2=" + str(int(sys.argv[2]))) #print("3=" + str(int(sys.argv[3]))) img_rgb = cv2.imread(r'C:\Users\martin\Documents\scree2.png') img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) template = cv2.imread(r'C:\Users\martin\Documents\dragob.png',0) w, h = template.shape[::-1] res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED) threshold = 0.64 loc = np.where( res >= threshold) pt = [(0,0)] while not zip(*loc[::-1]): threshold = threshold - 0.02 loc = np.where( res >= threshold) counter = 1 print("threshold="+str(threshold)) for pt2 in zip(*loc[::-1]): cv2.rectangle(img_rgb, pt2, (pt2[0] + w, pt2[1] + h), (0,0,255), 2) pt = pt2 crop_img = img_rgb[pt[1]:(pt[1]+h), pt[0]:(pt[0]+w)] counter = counter + 1 cv2.imwrite("C:\\Users\\tester\\Documents\\res.png",crop_img) #import cv2 #winName = "Movement Indicator" #cv2.namedWindow(winName, cv2.WINDOW_NORMAL) img = cv2.imread(r'C:\Users\tester\Documents\res.png',1) gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) height, width = gray.shape edges = cv2.Canny(gray,height,width,apertureSize = 3) #edges = cv2.Canny(gray,30,200) #gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) #ret,thresh = cv2.threshold(edges.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE,0) ret,thresh = cv2.threshold(edges,250,150,0) contours,hierarchy = cv2.findContours(thresh, 1, 2) #contours = sorted(contours, key = cv2.contourArea, reverse = True)[:10] 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") #im = img.copy() 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) #cv2.imwrite("C:\\Users\\martin\\Documents\\masda"+str(cntcounter)+".png",imi) #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) On Friday, September 16, 2016 at 7:34:04 PM UTC+8, Waffle wrote: > On 16 September 2016 at 14:24, meInvent bbirdwrote: > > 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() -- https://mail.python.org/mailman/listinfo/python-list
Re: why this code loop forever after a draw a rectangle
On 16 September 2016 at 14:24, meInvent bbirdwrote: > 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() -- https://mail.python.org/mailman/listinfo/python-list