OpenCV resolvePnP without camera and distortion matrices

回眸只為那壹抹淺笑 提交于 2021-02-08 10:55:39

问题


I am trying to make a AR app for android in witch the user points the camera to a square marker and a 3d model should show on top of the marker.

I am using OpenCV to get the rotation and translation of the marker but..

To get these 2 matrices, I use solvePnP for which I have to provide a camera matrix and a distortion matrix which (from my understanding) are specific for each camera type. Unfortunately, this is a huge drawback for me since the app should be supported by most Android devices and I also can't ask the user to run the camera calibration procedure (functions provided by openCV).

So the question: is there a way to eliminate the camera and distortion matrices? Or, is there another way to calculate the marker 3D position relative to the device?

I tried QCAR and Unity AR but (since the 3D models are downloaded form a server and are changing constantly), I was forced to go with OpenCV.

Any help will be really appreciated.

Thanks.


回答1:


Bad news for you. The answer is a definitive and irrevocable and big NO NO.

You really can't know anything about your image if you don't know anything about your camera. And the camera is described by the two matrices: camera mat and distortions mat.

But.. along with the bad news, there are some good news. You can do something, maybe.

Distortion matrix can be ignored in many AR applications. You just don't care about the small distortions.

And the camera matrix can be easily constructed if you know camera's field of view: Camera matrix:

w/(2*tan(camera.fovX())), 0, w/2, 0,
0, h/(2*tan(camera.fovY())), h/2, 0,
0, 0,   1, 0

Now, you'll say that you changed good for bad: you need camera fov, and for that you need to calibrate. The good news is that on android you can getHorizontalAperture() and getVerticalAperture(), or something. Aperture == field of view.

Finally, the really bad news: on many phones, the returned value isn't correct. Because the manufacturers did not care about it. And it returns bogus angles: 10 degress, 180 degrees, etc.

Good luck!



来源:https://stackoverflow.com/questions/8824126/opencv-resolvepnp-without-camera-and-distortion-matrices

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!