removing contour from cvFindcontour result

120 views
Skip to first unread message

Andrew Wilson

unread,
Jul 16, 2010, 2:31:36 PM7/16/10
to ctypes...@googlegroups.com
Hello,
  I'm trying to remove some contours from the sequence output from cvFindContours.  The code is listed below, for small sets of contours it works fine but when there are many contours retrieved I get a ctypes ValueError Exception "ctypes object structure too deep".  Any idea what this means and how to fix it?
  Thanks
  Andrew


def FilterContours(contour, fxn, *fxnargs):
    c = contour
    while(True):
        args = (c,) + fxnargs
        if(fxn(*args)): #remove it from the seq
            if(c.h_prev and c.h_next):                                      
                try:
                    c.h_prev[0].h_next = c.h_next
                    c.h_next[0].h_prev = c.h_prev
                except ValueError as e:
                    print e
                    pass # why do I get a "ctypes object structure too deep"                                        
            elif(c.h_next): #first one
                contour = c.h_next[0]
        if(c.h_next): #increment it
            c = c.h_next[0]
        else:
            break       
    return contour

Reply all
Reply to author
Forward
0 new messages