nazirmohd2006 / javacv

Automatically exported from code.google.com/p/javacv
0 stars 0 forks source link

Stitcher crashes when used with images created from buffered images. #294

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Execute this pseudo-code

int imageCount =  5;
MatVector images = new MatVector(imageCount);
for(int index=0; index<imageCount;index++){
     try {
          BufferedImage bufferedImage = ImageIO.read(....);
          IplImage image = IplImage.createFrom(bufferedImage);
          images.put(index, image);
     } catch (IOException ex) {
          Exceptions.printStackTrace(ex);
     }
}
Stitcher stitcher = Stitcher.createDefault(false);
IplImage result = new IplImage(null);
stitcher.stitch(images, result);

What is the expected output? What do you see instead?
Stitched image which is composed of given images. Program sometimes crashes 
randomly.

What version of the product are you using? On what operating system?
0.4 Windows 8 64-bit

Please provide any additional information below.
Crashes occur only if I read images as bufferedImage and convert them into 
IplImage. If I read them with cvLoadImage as IplImage directly no problem 
occurs. The images I used are compatible with stitching. Additionally if there 
is no crash from the start then there seems to be less likely that another 
crash will occur for consecutive runs. However when the crash happens then 
consecutive crashes occurs more frequently. Therefore I believe that it has 
something to do with native memory pointers.

Original issue reported on code.google.com by kaan...@gmail.com on 18 Mar 2013 at 8:15

GoogleCodeExporter commented 8 years ago
Can you try to hang on to references of the IplImage objects you create in 
Java? MatVector doesn't do it on its own, at the moment anyway

Original comment by samuel.a...@gmail.com on 18 Mar 2013 at 8:31

GoogleCodeExporter commented 8 years ago
Thanks for the quick reply. I tried your suggestion and it seems to resolve my 
issue.
I stored IplImages in an array list parallel to the MatVector.

Thanks again very much.

Original comment by kaan...@gmail.com on 19 Mar 2013 at 8:01

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
can I know that where these result image saved? I have tried this code and 
there where no errors, but could not find the result image.If you can please 
consider about this issue.Thank you. 

Original comment by sahpiy...@gmail.com on 17 May 2013 at 5:27

GoogleCodeExporter commented 8 years ago
Hi, As this answer said i have tried this code 
  int numOfImages =Integer.parseInt(txtNumOfImages.getText()) ;
        Stitcher stitcher = Stitcher.createDefault(false);
        IplImage[] images;
        images=new IplImage[numOfImages];
        images.put(i,cvLoadImage(txtpath.getText()));
 int status = stitcher.stitch(images[numOfImages],result);

          System.out.println("result ok...(Y)");

            if( status == stitcher.OK )
            {

                cvSaveImage("images\\StitchImage.jpg", result);
                System.out.println("stitcher OK (Y)");

            }

          result = cvLoadImage("images\\StitchImage.jpg");

instead of using the MatVector as  MatVector images = new 
MatVector(numOfImages);

Can I please have an idea about how to implement 

              images.put(i,cvLoadImage(txtpath.getText())); and
         int status = stitcher.stitch(images,result);
with arrayList instead of MatVectorepleas. thank you.I am really stuck with my 
project here.

Original comment by hash...@gmail.com on 4 Sep 2013 at 10:30

GoogleCodeExporter commented 8 years ago
The original issue has been fixed, so please post questions you may have on the 
mailing list, thank you!

Original comment by samuel.a...@gmail.com on 16 Sep 2013 at 11:15