Error Microsoft C++ exception: mwException at memory location when passing CString to Matlab function

6 views (last 30 days)
I passed the path of file to the Matlab function, so it can read it. However, I got crashed again. Here what I did:
in Matlab:
function ImgProc(pathname)
mov=VideoReader(pathname);
nFrames=mov.NumberOfFrames;
for k=1:10
img=read(mov,k);
img=rgb2gray(img);
img = imresize(img, [64, 64]);
imshow(img);
code in C++: sFileName is CString which contains the video file path.
CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Movie Files (*.avi;*.mpg;*.mp4)|*.avi;*.mpg;*.mp4||"), this);
CString sFileName = dlgFile.GetPathName();
bool a=mclInitializeApplication(NULL,0);
bool b= ImgProcInitialize();
mwArray out(sFileName);
ImgProc(out);
ImgProcTerminate();
mclTerminateApplication();
ImgProc function in C++:
ImgProc(const mwArray& pathname);
please help

Answers (0)

Community Treasure Hunt

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

Start Hunting!