问题
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