2015-01-20 3 views
0

Bitmap 객체에서 Mat 객체를 변환해야합니다. 이건 내 코드입니다 :지도를 비트 맵으로 변환

public void convertor(Mat tmp1){ 
    Mat tmp = new Mat(tmp1.size(), CvType.CV_8UC1); 
    Imgproc.cvtColor(tmp1, tmp, Imgproc.COLOR_RGB2BGRA); 
    Bitmap bp = Bitmap.createBitmap(tmp.rows(), tmp.cols(), Bitmap.Config.ARGB_8888); 
    Utils.matToBitmap(tmp, bp);} 

그리고 이것은 오류입니다 :

01-20 17:23:56.315: E/cv::error()(17783): OpenCV Error: Assertion failed (src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols) in void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp, line 97 
01-20 17:23:56.325: E/org.opencv.android.Utils(17783): nMatToBitmap catched cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean) 
01-20 17:23:56.325: E/AndroidRuntime(17783): FATAL EXCEPTION: Thread-3783 
01-20 17:23:56.325: E/AndroidRuntime(17783): Process: com.example.motionsnap, PID: 17783 
01-20 17:23:56.325: E/AndroidRuntime(17783): CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean) 
01-20 17:23:56.325: E/AndroidRuntime(17783): ] 

가 어떻게이 문제를 해결할 수 있습니까? matToBitmap을 사용하지 않고 다른 방법이 있습니까?

감사합니다.

답변

0

수정 됨. 비트 맵의 ​​크기 매개 변수는] 드시] 드시 변경해야합니다.

public Bitmap createBitmapfromMat(Mat snap){ 
    Bitmap bp = Bitmap.createBitmap(snap.cols(), snap.rows(), Bitmap.Config.ARGB_8888); 
    Utils.matToBitmap(snap, bp); 
    return bp; 
} 
관련 문제