Ask Your Question
1

I am trying to stitch a few images and getting assertion errors.

asked 2017-12-29 00:57:43 -0600

opencv-newb gravatar image

updated 2018-12-24 00:58:46 -0600

Image scheme is W*H*channels.

I have two images of dimensions : 600*429*3 and 600*523*3

There is a overlap between the two images. On trying to stitch I get the following error:

OpenCV Error: Assertion failed (dst.cols < 0x7fff && dst.rows < 0x7fff && src.cols < 0x7fff && src.rows < 0x7fff) in remap, file /home/user/3.4.0/opencv-3.4.0/modules/imgproc/src/imgwarp.cpp, line 1749

I looked around an little bit and was suggested to comment out an Assertion in the imgwarp.cpp file. I commented it out and then I got a different error:

OpenCV Error: Assertion failed (u != 0) in create, file /home/user/3.4.0/opencv-3.4.0/modules/core/src/matrix.cpp, line 436

I went ahead and commented that line as well. I recompiled and linked the .so file to my python cv2 package. The code ran fine,no errors this time, but the stitched image has a width of 30000 instead of 600. The final image is highly distorted.

How do I fix this?

edit retag flag offensive close merge delete

Comments

Is that 600x293 and 600x233 or 6004293x6005233 both images? That makes a bit of a difference.

Tetragramm gravatar imageTetragramm ( 2017-12-29 01:15:23 -0600 )edit

Apologies. New to this forum's formatting. It is fixed now.

opencv-newb gravatar imageopencv-newb ( 2017-12-29 01:19:20 -0600 )edit

I see. Can you post the images so we can test?

Tetragramm gravatar imageTetragramm ( 2017-12-29 14:28:22 -0600 )edit

https://imgur.com/a/wb4ng

These are the two images. I haven't still been able to figure out why the distortion is there. Can use a little help here. @

opencv-newb gravatar imageopencv-newb ( 2018-01-02 00:50:39 -0600 )edit

Have you tried setting the mode to scans? Like so?

Stitcher::create(Stitcher::SCANS);
Tetragramm gravatar imageTetragramm ( 2018-01-02 19:00:49 -0600 )edit

How do I do that in python?

opencv-newb gravatar imageopencv-newb ( 2018-01-02 21:09:03 -0600 )edit

Huh. I don't typically use python, but I don't actually see a way to do it. @berak, @LBerger, do you know?

Tetragramm gravatar imageTetragramm ( 2018-01-02 21:35:34 -0600 )edit

The documentation for python is really not upto the mark. I may switch to c++ if it doesn't work out.

opencv-newb gravatar imageopencv-newb ( 2018-01-02 21:49:09 -0600 )edit

Are you compiling your own? You can get the parameter by modifying the createStitcher function, but it looks like Stitcher::create is not exported to Python.

Tetragramm gravatar imageTetragramm ( 2018-01-02 22:35:45 -0600 )edit

`import cv2

stitcher = cv2.createStitcher(False)

result = stitcher.stitch(tup) `

This is what I am doing. The False argument I think is to not use the gpu.

opencv-newb gravatar imageopencv-newb ( 2018-01-02 23:04:13 -0600 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2018-01-03 03:37:14 -0600

LBerger gravatar image

updated 2018-01-03 03:53:43 -0600

That's not an answer but Images are necessary to explain. In your result image size is greater than 32767 if assertion is thrown.

My two images are : image description image description

Now result size depends of projection type in wraperwrap (it seems there is no python access):

Cylindrical projection image description

Spherical projection image description

plane projectionimage description

Fisheye projection is it a bug ? image description

edit flag offensive delete link more

Comments

What can be the fix then? Should I migrate to c++?

opencv-newb gravatar imageopencv-newb ( 2018-01-03 04:38:18 -0600 )edit

You should try to build opencv with example and then use example with your image in a console:

cpp-example-stitching_detailed.exe pano1.jpg pano2.jpg

I don't know python but may be you don't need to learn C++ if you can run this example from python. All stitching parameters are available from this example

LBerger gravatar imageLBerger ( 2018-01-03 05:08:12 -0600 )edit

I am able to run the c++ program with my images as arguments. the resultant is still 30000px wide.

opencv-newb gravatar imageopencv-newb ( 2018-01-03 05:27:20 -0600 )edit

add argument --warp fisheye

Can you post images ?

LBerger gravatar imageLBerger ( 2018-01-03 05:31:13 -0600 )edit
1

Actually, he probably wants the AffineWarper. The C++ Pano has the new SCANS mode. Which is:

    stitcher->setWaveCorrection(false);
    stitcher->setFeaturesMatcher(makePtr<detail::AffineBestOf2NearestMatcher>(false, try_use_gpu));
    stitcher->setBundleAdjuster(makePtr<detail::BundleAdjusterAffinePartial>());
    stitcher->setWarper(makePtr<AffineWarper>());
    stitcher->setExposureCompensator(makePtr<detail::NoExposureCompensator>());
Tetragramm gravatar imageTetragramm ( 2018-01-03 07:37:09 -0600 )edit
1

Image link: https://imgur.com/a/wb4ng

Also, doing --warp fisheye gave me a mirrored image. All the characters are flipped. Also, is there any way to do it in python?

EDIT: I tried to get the images flipped horizontally and it looks good. The thing is that the final image is horizontal instead of vertical. i was still able to use cv2.flip to get the final image. Is there any way for the flags' documentation and where to use what? Python documentation isn't looking good for me.

opencv-newb gravatar imageopencv-newb ( 2018-01-03 22:48:10 -0600 )edit

It is not possible to do it python without a pull request. But I think you can call program stitching_detailed from python. You will need to build opencv with -DBUILD_EXAMPLES:BOOL=ON

LBerger gravatar imageLBerger ( 2018-01-04 02:24:15 -0600 )edit

I am trying to expose the --warp fisheye flag into python by writing some bindings. Is there any proper way to do this?

opencv-newb gravatar imageopencv-newb ( 2018-01-04 23:06:50 -0600 )edit

What do you mean ?

LBerger gravatar imageLBerger ( 2018-01-05 02:12:27 -0600 )edit

The two images mentioned above got stitched properly when using the flag —warp fisheye. I need to being this functionality into python which isn’t there right now. Any ideas?

opencv-newb gravatar imageopencv-newb ( 2018-01-05 02:20:20 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-29 00:57:43 -0600

Seen: 2,217 times

Last updated: Jan 03 '18