{"action":"created","issue":{"url":"https://api.github.com/repos/kyamagu/mexopencv/issues/218","labels_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/218/labels{/name}","comments_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/218/comments","events_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/218/events","html_url":"https://github.com/kyamagu/mexopencv/issues/218","id":119915992,"number":218,"title":"MATLAB 2015a crashed in \"MxArray(m)\" when I converted cv::Mat back to mxArray","user":{"login":"jacky8230","id":16115923,"avatar_url":"https://avatars.githubusercontent.com/u/16115923?v=3","gravatar_id":"","url":"https://api.github.com/users/jacky8230","html_url":"https://github.com/jacky8230","followers_url":"https://api.github.com/users/jacky8230/followers","following_url":"https://api.github.com/users/jacky8230/following{/other_user}","gists_url":"https://api.github.com/users/jacky8230/gists{/gist_id}","starred_url":"https://api.github.com/users/jacky8230/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacky8230/subscriptions","organizations_url":"https://api.github.com/users/jacky8230/orgs","repos_url":"https://api.github.com/users/jacky8230/repos","events_url":"https://api.github.com/users/jacky8230/events{/privacy}","received_events_url":"https://api.github.com/users/jacky8230/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-12-02T10:50:04Z","updated_at":"2015-12-03T16:58:26Z","closed_at":null,"body":"OS: Windows7 64bits\r\nMATLAB version : MATLAB 2015a\r\nOpenCV version : 2.4.9\r\nC/C++ Compiler : Microsoft Visual Studio 2010\r\n\r\nHere is an example copied from \"https://github.com/kyamagu/mexopencv/tree/v2.4\"\r\n\r\n%=================================================================\r\n#include \"mexopencv.hpp\"\r\nvoid mexFunction(int nlhs, mxArray *plhs[],\r\n                 int nrhs, const mxArray *prhs[])\r\n{\r\n\r\n    // Check arguments\r\n    if (nlhs!=1 || nrhs!=1)\r\n        mexErrMsgIdAndTxt(\"myfunc:invalidArgs\", \"Wrong number of arguments\");\r\n\r\n    // Convert MxArray to cv::Mat\r\n    cv::Mat mat = MxArray(prhs[0]).toMat();\r\n\r\n    // Do whatever you want\r\n\r\n    // Convert cv::Mat back to mxArray*\r\n    plhs[0] = MxArray(mat);\r\n}\r\n%=================================================================\r\n(1)\r\nIt doesn't show any error message when I use mexopencv.make('opencv_path', 'D:\\OpenCV2.4.9\\build') to compile each file. But in runtimes, MATLAB always crashed at the line \"plhs[0] = MxArray(mat)\". I'm pretty sure that the error caused by \"MxArray(mat)\" function. Due to this reason, I can't use any cv.xxx function which has been compiled.\r\n\r\nplhs[0] = MxArray(mat); % => MATLAB crashed\r\nplhs[0] = MxArray(prhs[0]); % => OK\r\n\r\nI run same compiled mex files at MATLAB 2013b, and everything is going well. How can I fix this problem in MATLAB 2015a?\r\n\r\n(2)\r\nBy the way, I try to use cv.imread('peppers.png') in MATLAB 2015a, but it shows the strange error message as follows:\r\nError using imread\r\nimread failed\r\n\r\nIt seems that this command just call MATLAB's imread function instead of cv.imread. But in 2013b version, it calls cv.imread correctly.\r\n\r\n\r\n(3)\r\nThis simple code below also crashed because of the same problem mentioned at (1).\r\nimg = cv.blur(rand(100)); % => crashed in 2015a, but work well in 2013b.\r\n\r\n\r\nThank you\r\n\r\nJacky"},"comment":{"url":"https://api.github.com/repos/kyamagu/mexopencv/issues/comments/161715380","html_url":"https://github.com/kyamagu/mexopencv/issues/218#issuecomment-161715380","issue_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/218","id":161715380,"user":{"login":"jacky8230","id":16115923,"avatar_url":"https://avatars.githubusercontent.com/u/16115923?v=3","gravatar_id":"","url":"https://api.github.com/users/jacky8230","html_url":"https://github.com/jacky8230","followers_url":"https://api.github.com/users/jacky8230/followers","following_url":"https://api.github.com/users/jacky8230/following{/other_user}","gists_url":"https://api.github.com/users/jacky8230/gists{/gist_id}","starred_url":"https://api.github.com/users/jacky8230/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacky8230/subscriptions","organizations_url":"https://api.github.com/users/jacky8230/orgs","repos_url":"https://api.github.com/users/jacky8230/repos","events_url":"https://api.github.com/users/jacky8230/events{/privacy}","received_events_url":"https://api.github.com/users/jacky8230/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T16:58:26Z","updated_at":"2015-12-03T16:58:26Z","body":"Thank you.\r\n@amroamroamro and @kyamagu \r\nYou are right. I check the folder both D:\\MATLAB\\R2013b\\bin\\win64 and D:\\MATLAB\\R2015a\\bin\\win64.I find that there are ```opencv_*242.dll``` files in R2013b and ```opencv_*249.dll``` files in R2015a. \r\n\r\nI don't realize how can I compiled these MEX-files in R2015a. These binaries worked well in R2013b but not R2015a.\r\n\r\nHow can I solve this problem? Just delete all ```opencv_*242.dll``` files in R2013b and then rebuild mexOpenCV?\r\n\r\nI use dependency walker to check where those .dlls loaded from.\r\n\r\n**_________________________R2013b_________________________**\r\n![2013b](https://cloud.githubusercontent.com/assets/16115923/11566831/187b49dc-9a1f-11e5-864e-7b984cca2d2b.PNG)\r\n\r\n**_________________________R2015a_________________________**\r\n![2015a](https://cloud.githubusercontent.com/assets/16115923/11566871/4e289c7e-9a1f-11e5-9f6c-d447d5a3bda3.PNG)\r\n\r\nHow can I let them both loaded from ```$opencvroot\\build\\x64\\vc10``` instead of ```$matlabroot\\bin\\win64```?"}}