How to appropriately destroy mxArray created by ocvMxArrayFromImage_{DataType} functions
古いコメントを表示
Dear all, I am trying to integrate Matlab code into C++ program with OpenCV. I found the program will gradually increase memory usage.
After some working around, I believe the problem has something to do with destroying mxArray. I wrote a simple test program with an infinite loop that keeps create mxArray and destroy it, as shown below
cv::Mat imageMat = cv::imread(imagePath);
while(true)
{
mxArray* imageMXA = ocvMxArrayFromImage_uint8(imageMat);
mxDestroyArray(imageMXA);
}
this program will gradually increase memory usage.
However, another test program that creates mxArray with mxCreateNumericArray does not have such problem. the code is shown below
while(true)
{
mxArray* imageMXA = mxCreateNumericArray(dimensionNumber, dimensions, mxDOUBLE_CLASS, mxREAL);
mxDestroyArray(imageMXA);
}
It seems that there is something wrong in the code that destroy the mxArray created by ocvMxArrayFromImage_{DataType} functions. My question is, how should I appropriately destroy such mxArray?
7 件のコメント
James Tursa
2018 年 3 月 28 日
編集済み: James Tursa
2018 年 3 月 28 日
You would probably need to see the code for ocvMxArrayFromImage_uint8 to answer your question, and you don't have that. However, it looks like it is a simple nD transpose and reordering operation, so it wouldn't be too difficult to write your own conversion routine if needed.
Eddie Chiou
2018 年 3 月 29 日
編集済み: Eddie Chiou
2018 年 3 月 29 日
Eddie Chiou
2018 年 3 月 29 日
James Tursa
2018 年 3 月 29 日
I can't offer any advice unless I see your code.
Eddie Chiou
2018 年 3 月 29 日
James Tursa
2018 年 3 月 29 日
Is channels always either going to be 1 or 3?
Eddie Chiou
2018 年 3 月 29 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Computer Vision Toolbox についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!