How to use imread from OpenCV in Matlab?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to use `imread` from OpenCV within Matlab. I have the following files:
`imreadCV.cpp`:
#include "opencvmex.hpp"
#include "mxarray.hpp"
using namespace cv;
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
std::string imname= prhs[0]->toString();
cv::Mat img = imread(imname);
cv::cvtColor(img, img, cv::COLOR_BGR2GRAY);
img.convertTo(img, CV_32F);
cv::Scalar s = 255;
divide(img, s, img);
plhs[0] = ocvMxArrayFromImage_double(img);
}
and the Matlab code:
function runMatlab
imname=['lenna.bmp'];
BW=im2double(imread(imname));
imname_CV=imreadCV(imname);
When I try `mexOpenCV imreadCV.cpp`, I get the error:
c:\me\mxarray.hpp(460):
warning C4099: 'matlab::ArgumentParser::Variant': type name first seen using 'struct' now seen using 'class'
c:\me\mxarray.hpp(460):
note: see declaration of 'matlab::ArgumentParser::Variant'
c:\me\mxarray.hpp(523):
warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
c:\me\mxarray.hpp(525):
warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
c:\me\mxarray.hpp(528):
warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
c:\me\mxarray.hpp(530):
warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
C:\me\imreadCV.cpp(9): error C2027: use of
undefined type 'mxArray_tag'
c:\program files\matlab\r2018b\extern\include\matrix.h(687): note: see declaration of 'mxArray_tag'
C:\me\imreadCV.cpp(12): error C3861: 'imread':
identifier not found
why is this?
0 Commenti
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!