trouble calling OpenCV cvFitLine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JimPGH
    New Member
    • Dec 2008
    • 1

    trouble calling OpenCV cvFitLine

    I am trying to use the OpenCV cvFitLine() function using the Python SWIG interface to OpenCV. My problem has to do with the fact that the last argument is a pointer to an array of four floats (to return the fitted line parameters). My first mindless attempt looked like this:

    Code:
    line = []
    cv.cvFitLine(img, cv.CV_DIST_L2, 0, 0.01, 0.01, line)
    This produced the error:

    TypeError: in method 'cvFitLine', argument 6 of type 'float *'
    After googling around bit, I decided that ctypes would give me the array pointer that I needed, so I modified my code as follows:

    Code:
    FourFloats = ctypes.c_float * 4
    line = FourFloats()
    cv.cvFitLine(img, cv.CV_DIST_L2, 0, 0.01, 0.01, ctypes.byref(line))
    But this produced the same error. I'm stuck. Can someone please point me in the right direction?


    Thanks...
Working...