opencv - Image stitching: NullPointerException -


i have run code. seems result.png not generated result:

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);         }         result = cvloadimage("result.png");         final canvasframe canvas = new canvasframe("my image", 1);         // request closing of application when image window closed.        canvas.setdefaultcloseoperation(javax.swing.jframe.exit_on_close);         // show image on window.        canvas.showimage(result);        } } 

and error

exception in thread "main" java.lang.nullpointerexception @ com.googlecode.javacv.canvasframe.showimage(canvasframe.java:366)     @ com.googlecode.javacv.canvasframe.showimage(canvasframe.java:363)     @ imagestitching.main(imagestitching.java:50)  java:50 canvas.showimage(result); 

apparently, result null when call showimage.

the problem in code test if status ok (if ( status == stitcher.ok )), , try load file anyway. code should like:

if ( status != stitcher.ok ) {     std::cout << "error" << std::endl;     return 1; } 

then see problem comes stitching.


moreover, don't need write result file before showing it.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -