is it possible to adjust convex hull to draw blue line instead of green line?
meInvent bbird
jobmattcon at gmail.com
Fri Sep 16 20:20:27 EDT 2016
i succeed to use code to draw green line, but green line not draw the
large area, expect second uploaded picture, the blue line connect
the bottom of red line graph
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(cnt, 0.15 * peri, True)
#print("len(approx)="+str(len(approx)))
#if len(approx) == 2:
print("approx=" + str(approx))
cntcounter = cntcounter + 1
print("here1")
#x,y,w,h = cv2.boundingRect(cnt)
hull = cv2.convexHull(cnt,returnPoints = True)
print("here2")
while im is None:
time.sleep(1)
if im is not None:
print("here3")
#cv2.rectangle(im, (x,y), (x+w, y+h), (0,255,0), 2)
#cv2.imwrite("C:\\Users\\tester\\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)
previousx = 0
previousy = 0
for c in hull:
if previousx != 0 and previousy != 0 and c[0][0] != 0 and c[0][1] != 0 and abs(previousy - c[0][1]) > 10 and abs(c[0][0] - previousx) > 1:
while im is None:
time.sleep(1)
cv2.line(im,(previousx,previousy),(c[0][0],c[0][1]),(0,255,0),2)
print("")
#print("previousx=" + str(previousx))
#print("previousy=" + str(previousy))
#print("c[0][0]=" + str(c[0][0]))
#print("c[0][1]=" + str(c[0][1]))
previousx = c[0][0]
previousy = c[0][1]
https://drive.google.com/file/d/0Bxs_ao6uuBDUWVBFZzVIVGotRlk/view?usp=sharing
expected is
https://drive.google.com/file/d/0Bxs_ao6uuBDUNGZFS2F3WnJERzA/view?usp=sharing
More information about the Python-list
mailing list