java - OpenCV: What are the parameters for the WarpPerspective function? -
i'm building application in java uses opencv. haven't used library before, , java implementation bit lacking in documentation. need undo perspective warped image make squared up. need transform trapezoid rectangle. need stretch shorter of 2 parallel sides match length of longer parallel side. know need compute homographies , use warpperspective function, have no idea how structure command. know homography is, don't know how declare 1 , don't know feed warpperspective. let me emphasize, understand theory, need learn text syntax in code.
for sake of example, let's source trapezoid has corners @ (0,20), (0,80), (200,0), , (200,100). want end rectangular "stretch" (0,0), (0,100),(200,0), , (200,200). can provide code example? images in mat form.
java code
corners.add(new point(215,90)); corners.add(new point(470,90)); corners.add(new point(540,240)); corners.add(new point(150,240)); double maxwidth = 540 - 150 ;//bottomright.x - bottomleft.x double maxheight = 240 - 90 ; //bottomright.y - topleft.y target.add(new point(0,0)); target.add(new point(maxwidth-1,0)); target.add(new point(0,maxheight-1)); target.add(new point(maxwidth-1,maxheight-1)); trans=imgproc.getperspectivetransform(converters.vector_point2f_to_mat(corners), converters.vector_point2f_to_mat(target)); imgproc.warpperspective(img, proj, trans, new size(maxwidth,maxheight)); orignal.updateframe(utils.frommattobufferedimage(img));
proj destination mat
Comments
Post a Comment