Error "Access violation executing location 0x00000000" when using mwArray in Visual-C++
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to use Matlab function in VSC++ mfc 2012 to edit image. I got an this error:
Unhandled exception at 0x74E9C9F1 in pa2sample.exe: 0xC0000005: Access violation executing location 0x00000000
when I use mwArray. This is my code in C++:
BYTE* im=new BYTE();
ImgProc(1,mwArray (im),mwArray(img));
This code will use the Matlab function to convert image into grayscale image. img variable is the BYTE pointer to the buffer where image places. im variable is the output image.
ImgProc is a Matlab function:
function im=ImgProc(x)
im=rgb2gray(x);
Here is the ImgProc C++ function after converted from Matlab
ImgProc(int nargout, mwArray& im, const mwArray& x);
I appreciate if someone could help me. I have got stuck for 2 days.
1 件のコメント
回答 (1 件)
Friedrich
2013 年 10 月 22 日
編集済み: Friedrich
2013 年 10 月 22 日
Hi,
you don't need to allocate memory for the output. MATLAB will do this for you:
mwArray out;
ImgProc(1,out,mwArray(img));
Also are you sure the call to mwArray(img) succeeds? What is img (data type and size)? AFAIK there is no constructor which would match your usecase here
12 件のコメント
Friedrich
2013 年 10 月 23 日
Does the call to ImgProcInitialize succeed? It also has a return value? What datatype dies sFileName have?
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!