Can I use cv.CreateMat(2, 1, cv.CV_32FC1) in OpenCV 3.0.0?

asked 2015-06-23 09:06:06 -0600

Kevin Zhang gravatar image

updated 2015-06-24 09:05:35 -0600

Hi, everyone. I am a OpenCV newbie. Can I use cv.CreateMat(2, 1, cv.CV_32FC1) in OpenCV 3.0.0? If not, what is a good alternative?

Also, I want to do the camera calibration by using OpenCV. Referring to others' code, there is a function I used, but there is an error occuring.

retcode, cor = cv2.findChessboardCorners(image[i], patternSize, cv2.CALIB_CB_ADAPTIVE_THRESH | cv2.CALIB_CB_FILTER_QUADS)

cv2.error:2494: error: (-206) Unrecognized or unsupported array type in function cvGetMat

Any body can help me with this problem?

Thanks a lot!

Update~~~~~~~~~~~~~image description

edit retag flag offensive close merge delete

Comments

1

no, you can't use cv functions in opencv3.0 any more, the old cv python api was removed.

if you want to create an empty image in cv2, use numpy: img = np.zeros((h, w, 3), np.uint8)

berak gravatar imageberak ( 2015-06-23 10:15:47 -0600 )edit

Thanks, berak! As for the second problem, would you please give me any information?

Kevin Zhang gravatar imageKevin Zhang ( 2015-06-23 11:06:48 -0600 )edit

we'll try , at least ;)

but please, could you update your question, and show a liitle more code ?

somehow, it does not like your image[i] , but impossible to say why, atm.

berak gravatar imageberak ( 2015-06-23 11:10:27 -0600 )edit

Thanks berak! I update with a screenshot of the code, I am new to the forum so I am really sorry if any inconvenience caused! Thank you for your time and help~~~

Kevin Zhang gravatar imageKevin Zhang ( 2015-06-24 09:07:20 -0600 )edit

please no, not an unreadable screenshot ! ;(

please paste some text , so folks here can even go and try it ..

berak gravatar imageberak ( 2015-06-24 09:07:25 -0600 )edit

when in doubt, try python's builtin help function:

>>> help(cv2.findChessboardCorners)
Help on built-in function findChessboardCorners:

findChessboardCorners(...)
    findChessboardCorners(image, patternSize[, corners[, flags]]) -> retval, cor
ners

so, since there's an optional corners argument before the flags one, you have to specify flags as key-value pair, like:

retcode, cor = cv2.findChessboardCorners(image[i], patternSize, flags=cv2.CALIB_CB_ADAPTIVE_THRESH | cv2.CALIB_CB_FILTER_QUADS)
berak gravatar imageberak ( 2015-06-24 10:59:21 -0600 )edit