Reputation: 51
I am currently trying to port a code which is based on opencv 2.x to opencv 3.x (higher than 3.1). Within this code a function, namely cvGetMat(...) is being used. Since this function doesn't exist in opencv 3.x, I need a proper replacement. Does anyone know, how to replace this function properly? I already looked for it both in the opencv documentation and here at stackoverflow but couldn't find anything.
Here's a snipped code segment using this function
void cvCanny3( const void* srcarr, void* dstarr,
void* dxarr, void* dyarr,
int aperture_size )
{
CvMat srcstub, *src = cvGetMat( srcarr, &srcstub );
CvMat dststub, *dst = cvGetMat( dstarr, &dststub );
CvMat dxstub, *dx = cvGetMat( dxarr, &dxstub );
CvMat dystub, *dy = cvGetMat( dyarr, &dystub );
...
...
...
}
When I run this code I just get following error as expected:
‘cvGetMat’ was not declared in this scope CvMat srcstub, *src = cvGetMat( srcarr, &srcstub ); ^~~~~~~~
Upvotes: 0
Views: 1248
Reputation: 14467
cvGetMat
is from old C-based interface (it creates a CvMat object from raw C array), you should convert your code to newer C++ interface and make it use cv::Mat
type (wrap your src_addr
C array to C++ cv::Mat
instance).
E.g., your call to cvGetMat should be replaced by cv::Mat variable declaration.
cv::Mat src(num_rows, num_cols, src_type, src_arr);
The num_rows
, num_cols
and src_type
determine size and semantics of src_arr
array. Probably, you will have to drop 'const' modifier on you src_arr
input.
See cv::Mat
reference for more details.
All the cvFunctionName
calls usually have their C++ counterparts in 'cv::' namespace. E.g., cvRemap
would become cv::remap
etc.
Upvotes: 1