views:

632

answers:

2

Hello, I have a webcam pointed at a table at a slant and with it I track markers. I have a transformationMatrix in OpenSceneGraph and its translation part contains the relative coordinates from the tracked Object to the Camera. Because the Camera is pointed at a slant, when I move the marker across the table the Y and Z axis is updated, although all I want to be updated is the Z axis, because the height of the marker doesnt change only its distance to the camera. This has the effect when when project a model on the marker in OpenSceneGraph, the model is slightly off and when I move the marker arround the Y and Z values are updated incorrectly.

So my guess is I need a Transformation Matrix with which I multiply each point so that I have a new coordinate System which lies orthogonal on the table surface. Something like this: A * v1 = v2 v1 being the camera Coordinates and v2 being my "table Coordinates" So what I did now was chose 4 points to "calibrate" my system. So I placed the marker at the top left corner of the Screen and defined v1 as the current camera coordinates and v2 as (0,0,0) and I did that for 4 different points. And then taking the linear equations I get from having an unknown Matrix and two known vectors I solved the matrix.

I thought the values I would get for the matrix would be the values I needed to multiply the camera Coordinates with so the model would updated correctly on the marker. But when I multiply the known Camera Coordinates I gathered before with the matrix I didnt get anything close to what my "table coordinates" were suposed to be.

Is my aproach completely wrong, did I just mess something up in the equations? (solved with the help of wolframalpha.com) Is there an easier or better way of doing this? Any help would be greatly appreciated, as I am kind of lost and under some time pressure :-/ Thanks, David

A: 

If you know the location in the physical world of your four markers and you've recorded the positions as they appear on the camera, you ought to be able to derive some sort of transform.

When you do the calibration, surely you'd want to put the marker at the four corners of the table not the screen? If you're just doing the corners of the screen, I imagine you're probably not taking into acconut the slant of the table.

Is the table literally just slanted relative to the camera or is it also rotated at all?

Jon Cage
Thanks for the quick answer,The Camera doesnt see the entire table, the table is just the surface I move the markers on.The Camera is just pointing at the table surface from an angle. So the table corners aren't even in the camera view anymore. So I tried to go to the farthest parts the camera can still "see".So the corners of the "Screen"If you need a picture of the setup, please ask me and I will try and put one online asap,thanks,David
David
I wondered if that was the case. That makes sense then - sounds like you're probably looking at this the right way. Have you tried putting a regular grid on the table to make sure there's no barrel distortion out towards the edge of the image? It's possible that the webcam is more curved towards the corners which might throw out your calibration.. ?
Jon Cage
+1  A: 

when I move the marker across the table the Y and Z axis is updated, although all I want to be updated is the Z axis, because the height of the marker doesnt change only its distance to the camera.

Only true when your camera's view direction is aligned with your Y axis (or Z axis). If the camera is not aligned with Y, it means the transform will apply a rotation around the X axis, hence modifying both the Y and Z coordinates of the marker.

So my guess is I need a Transformation Matrix with which I multiply each point so that I have a new coordinate System which lies orthogonal on the table surface.

Yes it is. After that, you will have 2 transforms:

  1. T_table to express marker's coordinates in the table referential,
  2. T_camera to express table coordinates in the camera referential.

Finding T_camera from a single 2d image is hard because there's no depth information.

This is known as the Pose problem -- it has been studied by -among others- Daniel DeMenthon. He developed a fast and robust algorithm to find the pose of an object:

  • articles available on its research homepage, section 4 "Model Based Object Pose" (and particularly "Model-Based Object Pose in 25 Lines of Code", 1995);
  • code at the same place, section "POSIT (C and Matlab)".

Note that the OpenCv library offers an implementation of the DeMenthon's algorithm. This library also offers a convenient and easy-to-use interface to grab images from a webcam. It's worth a try: OpenCv homepage

Julien L.
Hey thanks for your answer.I have successfully created a Matrix which can transform between the coordinates my webcam gives me for the marker position and my Table coordinates. But I am not quite sure where to go from here. If I just take those new points it projects the model right in front of the Camera isntead of on the Marker. If I translate it on to the marker it still updates incorrecty. The problem is it does it updates according to the reflection of the monitor, which is basically at a 90° angle to the montitor(45° to the glass panel) and not straight on the table. Any ideas?
David
Sorry for the 2 part comment :)So it updates correctly along the projected image, but I want it to update correctly along the table.I was told to transform the camera coordinate System onto the origin of the viewplane (which should be the origin of the reflected monitor origin) and then multiply the inverse camera matrix from there. This would totally neglect the matrix I created which transforms between my created coordinate System and the cameras. (The person said my table coordinates were irrelevent to the scene)I dont really fully understand it.Any help would be greatly appreciated.
David
This is an almost one-month late reply, sorry for that. Anyway I am not quite sure what your setup is. But if what you want is only marker's coordinates in the camera referential, either apply the Pose algorithm on the marker or use 2 webcams to triangulate the position of the marker (in both cases, you will need to find known and recognizable points on your marker and in both cases you won't need the table).
Julien L.