Getting x,y in 3d coordinate system from 2d image pixel

Using camera with fixed position I have to track an object in motion and to localize it in some pre chosen coordinate system. Idea is to put a specific color marker on the top of the object with known height, so the Z coordinate will be known. After color tracking is done, I need to find out the X and Y from u and v image coordinates where the color is found. I have already done camera calibration and I'm planning to use cv::solvePnP to get rotation and translation vector. Also, I have learned about color tracking here and wrote a C++ api from it.

I have already found a similar question here and learned a lot from it, but the difference is that I only need to evaluate X and Y, since the Z coordinate is known (measured before). How can I get those X and Y coordinates with pre specified Z? Thanks for help!

Answers


Since you have calibrated (i presume on z=0) you can go from pixel to rw coordinates using the camera, translation and rotation matrices.

  1. You find a point you want to know the rw coordinates of. (the color marker)
  2. You lookup the x and y coordinate of this point (assuming z=0)
  3. You calculate the angles in x and y (in relation to the principle point)
  4. You use these angles to calculate what x and y would be at z=objectHeight

Need Your Help

Integer cube root

c optimization math gcc numerical-analysis

I'm looking for fast code for 64-bit (unsigned) cube roots. (I'm using C and compiling with gcc, but I imagine most of the work required will be language- and compiler-agnostic.) I will denote by...

PyroCMS - Show Blog Posts with date in future

pyrocms

in my PyroCMS website I want to display rock shows of a rock band that will occur in the future. I use a conditional to check whether the date of the blog post (which contains the rock show informa...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.