How OpenCV interface can be used with simulink?

조회 수: 1 (최근 30일)
JAI PRAKASH
JAI PRAKASH 2019년 3월 11일
댓글: madhan ravi 2019년 3월 14일
I am comfortable to use OpenCV interface with Matlab.
But don't know how to use it with Simulink. (For further building).
Anyways my c++ function(imdecode.cpp) which works on matlab is
#include "opencvmex.hpp"
#include "opencv2/imgcodecs.hpp"
#define _DO_NOT_EXPORT
#if defined(_DO_NOT_EXPORT)
#define DllExport
#else
#define DllExport __declspec(dllexport)
#endif
using namespace cv;
using namespace std;
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
cv::Ptr<cv::Mat> rawData = ocvMxArrayToImage_uint8(prhs[0]);
Mat frame = imdecode(*rawData, -1);
plhs[0] = ocvMxArrayFromImage_uint8(frame);
}
Any help !!

답변 (1개)

Vijaya Lakshmi Chagi
Vijaya Lakshmi Chagi 2019년 3월 14일
MATLAB provides an API to interface with OpenCV functions with mxArrays. Using the Simulink input/output ports, you will need to create mxArrays. You can use the following link to create mxArrays depending on the input types.
You can use the OpenCV functions to convert data types and then call the OpenCV C++ functions. Once you generate output from the C++ functions, you can pass it to Simulink Outputs using S-function API calls.
The other workflow is to bring existing OpenCV files/projects into MATLAB using Mex. Then use the MATLAB function block to call the generated mex file in Simulink
  댓글 수: 1
madhan ravi
madhan ravi 2019년 3월 14일
@Vijaya your second link works but the content seem to not exist.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by