On 2016-09-17 01:20, meInvent bbird wrote:
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


Here's the code with the commented code and print statements removed and the indentation fixed:

im = img.copy()

for cnt in contours:
    hull = cv2.convexHull(cnt, returnPoints=True)
    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: cv2.line(im, (previousx, previousy), (c[0][0], c[0][1]), (0, 255, 0), 2)

        previousx = c[0][0]
        previousy = c[0][1]


expected is


I think the problem might be that you're setting previousx to c[0][0] and previousy to c[0][1] even if you don't draw the line (because of the indentation), so you get a series of unconnected lines.

I'm not sure whether you should be setting previousx and previousy to 0 each time around the outer loop. I can't test it, but if the previous fix doesn't work, it's one more thing to try.

Reply via email to