Reputation: 380
I have tried with this 1 code but I am not sure if am right
Mat originalImage = Highgui.imread(path);
int[] imageInByte = new int[(int) (originalImage.total() * originalImage.channels())];
also I want to know how to get mat from integer array?
Upvotes: 1
Views: 345
Reputation: 16
Mat mRgb = Imgcodecs.imread("test.jpg");
MatOfInt iRgb = new MatOfInt(CvType.CV_32S);// middle type
mRgb.convertTo(iRgb, CvType.CV_32S);// 复制mRgb的数据到 iRgb
int[] dataArray = new int[(int)(iRgb.total()*iRgb.channels())];
iRgb.get(0,0, dataArray);// iRgb数据 int[]
Upvotes: 0
Reputation: 14538
After allocating the array,
byte imageInByte[] = new byte[originalImage.total() * originalImage.channels()];
You can copy the array from C++/JNI,
originalImage.get(0, 0, imageInByte);
To update the array in C++/JNI
originalImage.put(0, 0, imageInByte);
Upvotes: 1