Android向けOpenCVでMatからbyte配列にする方法とbyte配列からMatにする方法です

byte配列からMatへの変換

//仮にVGAで8bitグレースケールとする
final Mat tDistMat = new Mat(640, 480, CvType.CV_8UC1);
tDistMat.put(0, 0, tSourceBytes);

Matからbyte配列への変換

byte[] tImageBytes = new byte[(int) (tSourceMatImage.total() * tSourceMatImage.channels())];
tSourceMatImage.get(0, 0, tImageBytes);