How to calculate Distance D to object from a tilted camera with known H? - camera

Considering the camera is not tilted, it is easy to get the distance. However, can you refer a source where camera is tilted at some angle on y axis. By tilt i mean pitch. Also the camera is not looking directly at the object.

Related

How to calculate Rotation matrix for Rotation from GPS Co-ordinate system to SLAM Co-ordinate system

In our SLAM algorithm, we want to rotate GPS co-ordinates to SLAM co-ordinate system so that those GPS positions can be used for bundle adjustment in monocular SLAM (Scale correction).
We have used following procedure for rotation.
Convert Lat, Long, Att GPS co-ordinates to XYZ co-ordinate using Geoconverter library. (Resetting origin same as SLAM co-ordinate's origin)
Therefore, calculate rotation matrix between XYZ GPS co-ordinates and SLAM co-ordinates using rodrigues rotation formula for the first vector after origin.
Then, for each XYZ GPS position use the rotation matrix to calculate the GPS co-ordinates in SLAM co-ordinate system.
However, the results are not as expected, the GPS co-ordinate plane does not align with SLAM co-ordinates, hence bundle adjustment fails.
To check the actual position of the GPS co-ordinates after rotation, we plotted them (as shown below).
Front view (GPS(olive), SLAM(blue), MapPoints(black))
Without MapPoints
Side view to understand GPS and SLAM are in different plane
Side view with MapPoints
Side view different angle
Can you point out the mistake in the process or suggest an alternate process to align GPS data.
Thanks
Saurabh Kumar

Detecting Angle using Kinect

I have a flat pan and using kinetic v1.
I want to receive the angle of the pan using kinetic camera.
for eg: If I put the angle in 45 degrees so kinetic will read the closet or exact angle it placed.
is this possible or any solutions ?
Thanks.
I don't know exactly how the data comes back in Kinect V1 but I believe this methodology should work for you.
First: You have to assume that the Kinect is your level of reference, if it is necessary to get the pans angle relative to the ground then make sure the Kinect is level with the ground.
Second: Separate the pan data from all other data. This should be straight forward, the pan should be the closets object so transmit the closest measurements into 3D coordinate points (array of x,y,z).
Third: Assuming you wish for horizontal angle find the highest and lowest grounds of data and average their depth from the camera. Then save both those depths and the vertical distance they are away from each other.
Fourth: Now you can essentially do the math for a triangle. Given you know the width of the pan(saves steps to know the objects size otherwise you have to estimate that too) you can solve for a triangle with sides a: distance to point 1, side b: distance to point 2, side c: size of pan and finding the angle of where points a and c or b and c meet will give you the horizontal angle of the pan relative to the Kinect.
Fifth: For verification your measurements came back correct you can then use the angle you found to calculate the width of the pan given the angle and distance of the top and bottom most points.
Needless to say, you need to make sure that your understanding of trig is solid for this task.

Optical Flow egomotion estimation

below you can see the result of the optical flow if a camera makes a translation movement. If the camera makes a roll rotation the result looks like the second picture. Is it possible to retrieve the yaw angle from a camera if its only rotation around the yaw axis?
I think in the optical flow you can recognize if the camera is rotating around the yaw axis (z-axis), but i don't know how to retrieve the information how much the cam has rotated.
I would be gradeful for any hints. Thanks
Translation:
Roll rotation:
Orientation of camera:
If you have a pure rotation of your cam then you can use findhomography. You need four point correspondence in your pictures. For a pure rotation the homography matrix is already a rotation matrix. Otherwise you need to decompose the homograohy matrix. For a camera movement off 6 dof you can use the function find essential matrix and decompose this to translation and rotation.

Three.js camera understanding

Here's the task:
We have an Mesh, drawn in position POS with rotation ROT
Also we have a camera Which position and rotation is relative to Mesh For example camera point is CPOS and camera rotation is CROT.
How to calculate resulting angle for camera? I was assuming that it something like:
camera.rotation.x = mesh.rotation.x + viewport.rotation.x
camera.rotation.y = mesh.rotation.y + viewport.rotation.y
camera.rotation.z = mesh.rotation.z + viewport.rotation.z
That worked strange and wrong.
Then I decided to read about it on docs and completely dissapointed.
There are several kind of rotation structures (Euler, Quaternion). But What a want is something different.
Imagine, like you are on spaceship. And it moves in space. You are sitting at starboard turret and looking at objects. They seems like passing by...
Then you want to turn your head - Angel of your head is known to you (in raw opengl, I'd just multiplied head rotation matrix on ship's rotation matrix and got my projection matrix).
In other words I want only x and y axis for camera rotations, combined in matrix. Then I want to multiply it with position-rotation matrix of an object. And this final matrix would be my projection matrix.
How could I do the same in THREE.js?
-----EDIT-----
Thank you for the answer.
Which coords should I give to a camera? It should be local, mesh relative coords, or something absolute?
I understand, that this questions are obvious, but there's no any description about relative objects in THREE.JS docs (besides api description). And the answer might be ambiguous.
Add the camera as a child of the mesh like so:
mesh.add( camera );
When the camera is a child of an object, the camera's position and orientation are specified relative to the parent object.
You can set the camera's orientation by setting either the camera's quaternion or Euler rotation -- your choice.
Please note that the renderer updates the object's matrix and matrixWorld for you. You do not need to do that manually.
three.js r.63

Circular Motion of calibrated camera with given degree

according to this project (carving a dinosaur) I'd like to create a dataset with 36 images taken from an object and estimate the appropriate camera projection matrix.
Therefore I calibrated my camera once (extrinsic/intrinsic) for the first image with three chessboard patterns and now I want to add circular motion (rougly 10 degrees) according to the 36 images I've taken to get something like shown here:
My camera is static while the photographed object was rotated 10 degrees for every image.
How do I achieve this? Is it correct to create rotation matrices by hand and add it just to my camera projection matrix?
Thanks for advice
Modifying rotation matrices is not enough, you need to change position of the camera. In structure from motion problem it is assumed that scene is static, while camera is moving. You can consider such case because only relational movement is important.
Let the extrinsic camera matrix be A = R[I | -C], where C is position of camera center in global frame and R is rotation from global frame to the camera frame. Let Ra represent rotation by angle alpha about vertical axis in global frame. It can be written as (cos(alpha),-sin(alpha),0;sin(alpha),cos(alpha),0;0,0,1). Then the required camera matrix can be computed as A2 = R2[I | -C2], where R2 = R * transpose(Ra) and C2 = Ra * C.
However, you should ensure two things when using this approach. Firstly vertical axis of global frame must correspond to a real-world vertical direction. Secondly the origin of global frame must lie on the axis of the camera center rotation. The latter can be achieved by putting the object at the origin of global frame.
If angles are measured inaccurately or global frame is not centered well, then the computed extrinsic matrix can also be inaccurate. It can be used as an initial estimate for a structure from motion algorithm in this case. The other alternative is to calibrate the camera for each frame, not only the first one.