3

I have tried this code and it is gives error with the stitcher. whether I have use import static com.googlecode.javacv.cpp.opencv_stitching.Stitcher; it is give the same error with the stitcher. If you can please can I have a solution for this issue please. Thank you.

code is..

public class ImageStitching {

    public static void main(String[] args){
        MatVector images = new MatVector(2);
        images.put(0,cvLoadImage("sample1.png"));
        images.put(1,cvLoadImage("sample2.png"));

        IplImage result = new IplImage(null);
        int status = stitcher.stitch(images,result);

        if( status == stitcher.OK )
        {
            cvSaveImage("result.png", result);
        }
    }
}
JonasVautherin
  • 7,297
  • 6
  • 49
  • 95
  • You should tell us what the error is... – JonasVautherin May 16 '13 at 11:29
  • Exception in thread "main" java.lang.Error: Unresolved compilation problems: stitcher cannot be resolved stitcher cannot be resolved to a variable at ImageStitching.main(ImageStitching.java:24) java:24 is int status = stitcher.stitch(images,result); – user2294002 May 16 '13 at 11:35

1 Answers1

3

You haven't declared stitcher in your code...

Stitcher stitcher = Stitcher.createDefault(false);

JonasVautherin
  • 7,297
  • 6
  • 49
  • 95
  • Thank you.The error was solved.But the result image does not appear any where in the project.I am new to javacv. If you can please can I have a solution for this error please,Thank you – user2294002 May 17 '13 at 01:45
  • First of all, if it solved the problem, you should validate the answer. Then, the result image is actually "result". You should try to print it in a canvas (have a look at the JavaCV example [here](https://code.google.com/p/javacv/wiki/OpenCV2_Cookbook_Examples)). – JonasVautherin May 17 '13 at 05:25
  • Sorry,It is alright to load the result to the canvas,but there is no such a image as result.that is mean Exception in thread "main" java.lang.NullPointerException at canvas.showImage(image);com.googlecode.javacv.CanvasFrame.showImage(CanvasFrame.java:366) at com.googlecode.javacv.CanvasFrame.showImage(CanvasFrame.java:363) at ImageStitching.main(ImageStitching.java:54) This error is there java:54 is canvas.showImage(image); – user2294002 May 17 '13 at 11:09
  • Because in your case you must use "result" and not "image": `canvas.showImage(result);` – JonasVautherin May 17 '13 at 11:25
  • i have run this code with these lines of codes result = cvLoadImage("result.jpg"); final CanvasFrame canvas = new CanvasFrame("My Image", 1); canvas.showImage(result); error was Exception in thread "main" java.lang.NullPointerException at com.googlecode.javacv.CanvasFrame.showImage(CanvasFrame.java:366) at com.googlecode.javacv.CanvasFrame.showImage(CanvasFrame.java:363) at ImageStitching.main(ImageStitching.java:57) java:57 is canvas.showImage(result); – user2294002 May 18 '13 at 06:00
  • You should validate the answer. For your second question, you apparently save "result.png" and try to open "result.jpg". – JonasVautherin May 18 '13 at 11:16
  • Sorry it should be "result.png" and if it is "result.png" it is give the same error.I think the thing is there is no any result.png created from this code. – user2294002 May 18 '13 at 11:32
  • Then this is another question. Validate this one and put the new code in a new question. – JonasVautherin May 18 '13 at 12:26
  • Thank you i have edited the code here if( status != stitcher.OK ) { //cvSaveImage("result.png", result); System.out.println("cant stitch image"+status); return; } the error display as"cant stitch image1" – user2294002 May 23 '13 at 07:03
  • This has nothing to do with this question. You should validate this one (click on the green mark next to the score) and continue [here](http://stackoverflow.com/questions/16624953/image-stitching-using-javacv-opencv-image-stitcher). – JonasVautherin May 23 '13 at 07:10