Ask Your Question
1

How do I wrap the OpenCV InputArray class method getMat in C?

asked 2013-12-25 07:41:58 -0600

joeish80829 gravatar image

Here is my attempt:

my .cpp

#include "opencv_generated.hpp"
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {

Mat* cv_InputArray_getMat(Mat* self) {
    return new Mat(self->getMat);
}
}

my .hpp

#include <opencv2/opencv.hpp>
#include <vector>
#ifndef __OPENCV_GENERATED_HPP
#define __OPENCV_GENERATED_HPP
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {
Mat* cv_InputArray_getMat(Mat* self);

}

I compile it with this

 g++ -Wall -shared -fPIC -o libcl-opencv-glue.so cl-opencv-glue.cpp

I get this error:

root@w-VirtualBox:/home/w/opencv-master/glue# 
g++ -Wall -shared -fPIC -o libopencv-glue.so opencv-glue.cpp
opencv-glue.cpp: In function ‘cv::Mat* cv_InputArray_getMat(cv::Mat*)’:
opencv-glue.cpp:9:30: error: ‘class cv::Mat’ has no member named ‘getMat’
         return new Mat(self->getMat);
                              ^
opencv-glue.cpp:10:5: warning: control reaches end of non-void function 
[-Wreturn-type]
     }
     ^

Normally when i wrap c++ opencv functions in c i use a opaque Mat* pointer to stand in for the InputArray function parameters im wrapping. I tried substituting a opaque InputArray* pointer for the Mat* in every different combination but got longer error message list the more InputArray* substitutions I made.....Any advice is much valued

Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2017-04-19 06:07:20 -0600

Avio gravatar image

cv::Mat class has getUMat() member, while cv::UMat class has getMat() member.

edit flag offensive delete link more

Comments

UMat containers are for OpenCL and GPU processing ... they have nothing to do with C wrapping ...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-04-21 03:03:35 -0600 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-12-25 07:41:58 -0600

Seen: 428 times

Last updated: Apr 19