2014-06-13 3 views
1

매트 목록이있어서이를 바이트 배열로 변환해야합니다. 문제는이 오버 헤드가 생성된다는 것입니다. arraycopy 부분은 잘 작동하므로 걱정하지 마십시오. 제가 잘못 본게 아니라면, 자바에서 내가 mat.get 오프셋과 큰 패치 배열의 참조를 전달할 수 없습니다안드로이드에서 OpenCV : 많은 매트에서 바이트 [] 배열을 얻을 수있는 효율적인 방법

// These array comes allocated an filled with data 
    byte[] patches; // Big array to store all patches 
    int offsets[]; // Array with positions to copy 

    for(int i = 0; i < matList.size(); i++) 
    { 
     // Create a little array of mat size and get the data 
     int size = matList.get(i).rows() * matList.get(i).cols(); 
     byte[] patch = new byte[size];  
     matList.get(i).get(0, 0, patch); 
     // Copy this little array to the big array 
     System.arraycopy(patch, 0, patches, offsets[i], patch.length); 
    } 

이보다 그것을 할 수있는 더 좋은 방법이있는 경우 내 질문은 (0, 0, array) 함수를 사용하여 이러한 모든 작은 패치를 할당하지 않도록합니다.

답변

0

모든 Mat의 너비가 동일한 경우 Core.vconcat 방법으로 하나의 Mat 개체에 연결할 수 있습니다. 그런 다음 하나의 get으로 원시 바이트를 가져올 수 있습니다.

+0

불행히도 크기가 다릅니다. 어쨌든 좋은 팁. – dxb

관련 문제