How OpenCV interface can be used with simulink?
1 次查看(过去 30 天)
显示 更早的评论
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 !!
0 个评论
回答(1 个)
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!