By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

trouble calling OpenCV cvFitLine

P: 1
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:

Expand|Select|Wrap|Line Numbers
  1. line = []
  2. 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:

Expand|Select|Wrap|Line Numbers
  1. FourFloats = ctypes.c_float * 4
  2. line = FourFloats()
  3. 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?

Dec 23 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.