OpenCV, Python: Eliminating eventual narrowing when stitching images -
thanks in large part great answers on stackoverflow (here, here, , here) i've been having pretty success in aligning images. there 1 issue, though, can see below. stitch many images together, smaller , smaller.
my theory on why going on camera wasn't perpendicular ground, added more , more images natural perspective in having camera not perpendicular ground caused far images become smaller. incorrect, though.
however, when transform first image it's "as if" taken perpendicular ground (i think) distortion still occurs.
does brilliant stackoverflow community have ideas on how can remedy situation?
this process use stitch images:
- using knowledge of corner lat/long points of images, warp such first image perpendicular ground. homography use "base" homography
- find common features between each image , last 1 using
goodfeaturestotrack()
,calcopticalflowpyrlk()
- use
findhomography()
find homography between 2 images. then, compose homography previous homographies to "net" homography - apply transformation , overlay image net result of i've done far.
there 1 major constraint
the mosaic must constructed 1 image @ time, camera moves. trying create real-time map drone flying, fitting each image last, 1 one.
my theory on why going on camera wasn't perpendicular ground.
this intuition. if camera angled, moves towards object, object becomes larger in frame. if you're stitching previous frame, current frame needs shrink fit object in previous frame.
full 3x3
homographies include distortions in x
, y
directions, 2x3
affine transformations not. stick current pipeline, can try finding affine or euclidean (rigid) transformation instead. difference between them affine warp allows shearing , stretching separately in x
, y
directions, euclidean transforms translation, rotation, , uniform scaling. both preserve parallel lines, whereas full homography not, end square image becoming more trapezoidal, , repeating shrink image. affine warp can still shrink in 1 direction, turning square rectangle still might shrink. euclidean transformations can scale whole square, still might shrink.
of course, won't perfect matches findhomography
either, should able close matches without distorting size much. there 2 options find euclidean or affine transformations opencv:
estimaterigidtransform()
instead ofwarpperspective()
either rigid warp parameterfullaffine=false
or affine warpfullaffine=true
.findtransformecc()
optional parametermotiontype=cv2.motion_euclidean
ormotiontype=cv2.motion_affine
(but affine default it's not necessary specify).
you can check out difference between algorithms on documentation pages, or try both see works best you.
if doesn't work out well, can try estimating homography warps frame perpendicular ground. if that, can try applying frames first, , matching images. otherwise, you'll want move more advanced methods finding homography between each frame.
Comments
Post a Comment