Question

I am trying to stitch multiple images by using JavaCV 0.1 and OpenCV 2.4.0 in Java, i use this code for stitching images :

stitcher = Stitcher.createDefault(false);

MatVector images = new MatVector(imageN.size());
for(...){
   CvArr image = cvLoadImage(imageN);
   images.put(index,image);
}

MatVector result = new MatVector(1);
int status = stitcher.stitch(images,result);

if( status == stitcher.OK )
{
   cvSaveImage(result.getIplImage(0));
}

NOTE 1 : Loaded images in this example are valid image for stitching.

NOTE 2 : C++ version of the code runs with no problem on current configuration

In stitcher.stitch method opencv throws an assertion exception such as "k == MAT". How should i fix this? Is MatVector usage is right in this sample code?

Thanks...

Was it helpful?

Solution

I found it, it is a bug related with JavaCv.

Actually JavaCv is not guilty.OpenCV stitcher API uses cv::OutputArray for returning stitched image but this method casts cv::OutputArray to cv::Mat when executing. JavaCV ports OpenCV method only by using parameter interface and so it converts the parameter as std::vector, this results as a assertion failure.

It is required to convert std::vector to Mat to make it working. I don't know any other way exist for this conversion but otherwise it is possible to be fixed by only lib's author.

It is said that c++ version is working but in fact, it is working when pano parameter is given as cv::Mat, when std::vector is entered it gives the same failure assertions again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top