How OpenCV interface can be used with simulink?

1 visualización (últimos 30 días)
JAI PRAKASH
JAI PRAKASH el 11 de Mzo. de 2019
Comentada: madhan ravi el 14 de Mzo. de 2019
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 !!

Respuestas (1)

Vijaya Lakshmi Chagi
Vijaya Lakshmi Chagi el 14 de Mzo. de 2019
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 comentario
madhan ravi
madhan ravi el 14 de Mzo. de 2019
@Vijaya your second link works but the content seem to not exist.

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by