我有一個C++函數被聲明爲地圖返回類型爲byte [] []中的Java
無符號字符**分類
我使用下列接口文件中SWIG
%module PWrap
%include "std_string.i"
%include "arrays_java.i"
%apply byte[][] {unsigned char**};
%{
#include "Classifier.h"
%}
%include "Classifier.h"
這產生了一些文件,其中包括SWIGTYPE_p_p_unsigned_char對象
現在,這裏就是我嘗試使用這個C++函數在Java中:
SWIGTYPE_p_p_unsigned_char data = pc.classify();//this works, but I can't do anything with the data object execept pass it to other C++ functions expecting unsigned char**
byte[][] data2 =pc.classify();//this does not work - throws compile time error
那麼,我做錯了什麼讓這個映射工作正常?我知道矩陣的維數,因爲我將參數傳遞給C++函數來設置一切。換句話說,只要我能用Java以某種方式將其轉換爲字節,就可以以任何方式獲取數據。
在C++`unsigned char **`中可以指向任何東西。有沒有任何信息如何使用分類功能的結果?例如之後用戶需要釋放內存,用戶應該如何使用矩陣? – ssmir 2011-01-18 15:13:02
用戶不需要釋放它或任何東西 - 只需使用它進入圖像緩衝區 - 一次。 – Derek 2011-01-18 22:15:24