I Use JavaCV On Android 4.0.3 it run to error with
OpenCV Error: Assertion failed (ssize.area() > 0) in unknown function, file C:\slave\WinInstallerMegaPack\src\opencv\modules\imgproc\src\imgwarp.cpp, line 1432
Finding features...
Exception in thread "main" java.lang.RuntimeException: C:\slave\WinInstallerMegaPack\src\opencv\modules\imgproc\src\imgwarp.cpp:1432: error: (-215) ssize.area() > 0
at com.googlecode.javacv.cpp.opencv_stitching$Stitcher.stitch(Native Method)
at Lesson3_Stitch.main(Lesson3_Stitch.java:17)
Anyone can teach me how to fix it ? Thank you.
this is my code :
public static void main(String[] args) {
Stitcher stitcher = Stitcher.createDefault(true);
MatVector images = new MatVector(2);
images.put(0, cvLoadImage("sample1.png"));
images.put(1, cvLoadImage("sample2.png"));
IplImage result = new IplImage();
int status = stitcher.stitch(images, images);
if (status != Stitcher.OK) {
cvSaveImage("result.png", result);
System.out.println("cant stitch image" + status);
}
result = cvLoadImage("sample1.png");
final CanvasFrame canvas = new CanvasFrame("My Image", 1);
// Request closing of the application when the image window is closed.
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
// Show image on window.
// canvas.showImage(result);
}
private static void cvSaveImage(String string, IplImage result) {
// TODO Auto-generated method stub
}
private static IplImage cvLoadImage(String string) {
// TODO Auto-generated method stub
return null;
}
You need to import OpenCV for Android however you code cannot work due you use a custom function for cvLoadImage which returns null. This cannot work.
You could try to use CV.loadImage or some variations. Right now I have no OpenCV installation for testing.