Ask Your Question
0

Why do some of the functions in the OpenCV C++ interface have struct declarations in them?

asked 2013-11-20 20:32:57 -0500

joeish80829 gravatar image

updated 2013-11-21 02:32:32 -0500

berak gravatar image

new to c++ interface i saw these two similiar/same functions on this page

http://docs.opencv.org/modules/ml/doc/support_vector_machines.html?highlight=cvsvm#bool%20CvSVM::train%28const%20CvMat%20trainData,%20const%20CvMat%20responses,%20const%20CvMat%20varIdx,%20const%20CvMat%20sampleIdx,%20CvSVMParams%20params%29

under the CvSVM::train heading

C++:

bool CvSVM::train(const Mat& trainData, const Mat& responses, const Mat& varIdx=Mat(), const Mat& sampleIdx=Mat(), CvSVMParams params=CvSVMParams() )

C++:

 bool CvSVM::train(const CvMat* trainData, const CvMat* responses,  const CvMat* varIdx=0, const CvMat* sampleIdx=0, CvSVMParams params=CvSVMParams() )

they are the same but one uses the 'const Mat& ' and the other CvMat* Im writing a wrapper for opencv and I was wondering if, to make it complete would I need to include all the C structs ...or can C++ use the C structs or is CvMat and other structs both C and C++...I was under the impression that C++ used classes and C structs in opencv but if someone could shed light on this I would appreciate that....Also in the opencv cpp samples folder letter_recog.cpp there is alot of CvMat* in it....is that code just old and hasnt been updated yet. Opencv doc. says CvMat is deprecated so of the two above functions I guess i would just use the const Mat& one right and assume OpenCv documentation though posted on website is still maybe a bit "in proccess" . Any light shed on these queries is much appreciated

edit retag flag offensive close merge delete

Comments

1

Actually I think you are pointing out the largest problem in current modules, being the ML module. It is the last module that still contains the old C - API wrapped with C++ wrappers, instead of a completely remaked C++ interface. Being patient is the only way to go. And indeed, many of the samples have still C - style structs and functions, but that is because there isn't a decent C++ wrapper system yet.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-11-22 04:01:51 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-11-22 02:51:19 -0500

Moster gravatar image

I would personally only care about the cv::Mat stuff, unless there are functions that are not ported to c++ yet. Why? The c api is deprecated. c++ is the way to go. Samples might not be updated yet.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-11-20 20:32:57 -0500

Seen: 187 times

Last updated: Nov 22 '13