Ask Your Question
-1

undistord image and create bird view by use of nr. of points

asked Nov 20 '18

Phil2 gravatar image

Dear experts,

I am struggeling with following task:

Imagine an image showing a 3D surface with some markers on it. Assume, that the marker positions are known for image and object coordinates. However nothing from the one and only camera is known. The task is to remove perspective distortion and create a top view (bird view). Now...since I am a beginner in openCV...where to start? Is it even possible to perform this task?

I am sure that I am not the first one who tries to achive this. My coding lanuage would be C.

Thank you,

Phil2

Preview: (hide)

Comments

opencv does no more support any C bindings since 2010, you'll have to use C++

berak gravatar imageberak (Nov 21 '18)edit

How unfortune :-)...I want to write a GUI with LabWindows/CVI, which is C...

Phil2 gravatar imagePhil2 (Nov 21 '18)edit

"might look pretty young but i'm all backdated yeah" ;)

in other words: what you want is no more feasible. (and you really missed the bus)

berak gravatar imageberak (Nov 21 '18)edit

understood...<joke>but i am working on an air-bus <\joke> ... existing software is written with CVI (hence C), e.g the code for handling camera raw images (no bmp, jpg etc) is not available in C++/phyton etc. Probably I have a chance to bind phyton to CVI and than write my GUI in a C/phyton mix....though this also is kind of awkward.

Phil2 gravatar imagePhil2 (Nov 21 '18)edit

1 answer

Sort by » oldest newest most voted
1

answered Nov 21 '18

berak gravatar image

you need 4 (2d) points from your 3d view, and 4 2d points where you want them projected. make sure they're in the same order (e.g. starting top-left and going clockwise), then it's similar to:

 Mat img = imread("3dview.jpg");
vector<Point2f> pts;  // hardcoded, in clockwise order
pts.push_back(Point2f(895,204)); 
pts.push_back(Point2f(995,195));
pts.push_back(Point2f(1222,292));
pts.push_back(Point2f(1099,307));

Size sz(250,500);    // desired output size
vector<Point2f> rct; // desired coords, same order
rct.push_back(Point2f(0,0));
rct.push_back(Point2f(sz.width,0));
rct.push_back(Point2f(sz.width,sz.height));
rct.push_back(Point2f(0,sz.height));

Mat P = getPerspectiveTransform(pts,rct);
Mat persp;
warpPerspective(img, persp, P, sz, INTER_LINEAR);
Preview: (hide)

Comments

Thank you.

Phil2 gravatar imagePhil2 (Nov 21 '18)edit

Question Tools

1 follower

Stats

Asked: Nov 20 '18

Seen: 239 times

Last updated: Nov 21 '18