Ask Your Question
-1

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

asked 2018-11-20 12:45:38 -0600

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

edit retag flag offensive close merge delete

Comments

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

berak gravatar imageberak ( 2018-11-20 18:40:42 -0600 )edit

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

Phil2 gravatar imagePhil2 ( 2018-11-21 12:01:59 -0600 )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 ( 2018-11-21 12:05:01 -0600 )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 ( 2018-11-21 12:20:13 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-11-21 00:48:53 -0600

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);
edit flag offensive delete link more

Comments

Thank you.

Phil2 gravatar imagePhil2 ( 2018-11-21 12:03:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-11-20 12:45:38 -0600

Seen: 192 times

Last updated: Nov 21 '18