3
私はあなたの助けが必要です。 私は、OpenCVのseamlessClone()
関数を使って2つのイメージの単純なブレンドを実装しようとしています。私が言うた例外を取得しています:ここでOpenCV Androidシームレスクローニングエラー:(-215)CV_MAT_TYPE(mtype)== m.type()
error: (-215) CV_MAT_TYPE(mtype) == m.type()
は、それ用のソースコードです:
public class SeamlessClone extends AppCompatActivity {
public static final String TAG = "Seamless Clone demo";
static {
if (!OpenCVLoader.initDebug()) {
// Handle initialization error
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seamless_clone);
Bitmap destinationBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.lightning);
Log.d(TAG, "bitmap: " + destinationBitmap.getWidth() + "x" + destinationBitmap.getHeight());
Mat destination = new Mat(destinationBitmap.getHeight(),
destinationBitmap.getWidth(), CvType.CV_8UC4);
Utils.bitmapToMat(destinationBitmap, destination);
Bitmap sourceBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.airplane);
Log.d(TAG, "bitmap: " + sourceBitmap.getWidth() + "x" + sourceBitmap.getHeight());
Mat source = new Mat(sourceBitmap.getHeight(),
sourceBitmap.getWidth(), CvType.CV_8UC4);
Utils.bitmapToMat(sourceBitmap, source);
Mat mask = new Mat(source.rows(),source.cols(),source.depth(),Scalar.all(255));
Point point = new Point(destination.cols()/2,destination.rows()/2);
Mat result = new Mat(destinationBitmap.getHeight(),
destinationBitmap.getWidth(), CvType.CV_8UC4);
Photo.seamlessClone(source, destination, mask, point, result, Photo.NORMAL_CLONE);
Utils.matToBitmap(result, destinationBitmap);
ImageView imageView = (ImageView) findViewById(R.id.clone_result);
imageView.setImageBitmap(destinationBitmap);
}
}
そして次はlogcatからのエラーログです:
E/OpenCV/StaticHelper: OpenCV error: Cannot load info library for OpenCV
E/cv::error(): OpenCV Error: Assertion failed (CV_MAT_TYPE(mtype) == m.type()) in void cv::_OutputArray::create(int, const int*, int, int, bool, int) const, file /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/matrix.cpp, line 2297
E/org.opencv.photo: photo::seamlessClone_10() caught cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/matrix.cpp:2297: error: (-215) CV_MAT_TYPE(mtype) == m.type() in function void cv::_OutputArray::create(int, const int*, int, int, bool, int) const
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.hemisphere.opencvexample, PID: 1905
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hemisphere.opencvexample/com.example.hemisphere.opencvexample.SeamlessClone}:
CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/matrix.cpp:2297: error: (-215) CV_MAT_TYPE(mtype) == m.type() in function void cv::_OutputArray::create(int, const int*, int, int, bool, int) const
]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/matrix.cpp:2297: error: (-215) CV_MAT_TYPE(mtype) == m.type() in function void cv::_OutputArray::create(int, const int*, int, int, bool, int) const
]
at org.opencv.photo.Photo.seamlessClone_0(Native Method)
at org.opencv.photo.Photo.seamlessClone(Photo.java:581)
at com.example.hemisphere.opencvexample.SeamlessClone.onCreate(SeamlessClone.java:72)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
... 10 more
アムIコードで何か間違っている?
ありがとうございました!