Before the rush

Before the rush
by evan-pak

Submit your Photo
Hall of Fame

Please participate in Meta
and help us grow.

Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on camera pose estimation. For this, I need the focal length of my smartphone camera in pixels. (My phone is HTC Wildfire S, with Android 2.3).

share|improve this question
I don't think that makes a lot of sense, really... I'm not sure what you mean by trying to convert an optical property like a lens focal length into a digital propery, I just don't see how that translates. – John Cavan Sep 13 '12 at 20:21
Regardless of what the focal length is, the image will still be the same pixel dimensions. Focal length does not translate into pixels, those two things are disjoint concepts. Could you explain exactly what your goals are? We may then be able to help you. – jrista Sep 13 '12 at 20:29
You normally need focal length to do matching between 2d images and 3D models. Focal length makes up your camera matrix which u need to compute the pose via RANSAC. If you get good pose between your 2D image and 3D model then you say you have found the match. I kept my query really simple so everyone can understand. – Nabeel Younus Khan Sep 13 '12 at 21:41
@Nabeel: I, honestly, have no idea what your last comment was about. Matching between 2D and 3D, RANSAC, computing poses? A little more clarification would be helpful. I don't think anyone in general will know what "focal length makes up your camera matrix" means. – jrista Sep 13 '12 at 21:58
I think you'll get better results if you ask for a) the actual size of a pixel from the camera's sensor (roughly, sensor dimensions divided by number of pixels in the output) and b) the focal length of the lens. You can get these things by looking at spec sheets, but they're often rounded, so you're much better off measuring and working backwards. – mattdm Sep 14 '12 at 0:42
up vote 4 down vote accepted

This is really easy. Matlab camera calibration toolbox (Bouquet) or OpenCV camera calibration will do this for you if you take 10-20 images of a checkerboard. The intrinsic parameters give you the true center of the lens in pixels and the focal length in pixels. It will be pretty close to [focal length in mm]*[resolution]/[sensor size in mm], but due to mechanical inaccuracies not close enough for accurate pose estimation.

share|improve this answer
The resolution factor will be pretty difficult to determine. You have lens resolution, sensor resolution, the RSS of those two, and any other degredation imposed by the likes of low pass filters and whatnot. Not to mention the effects of diffraction. – jrista Sep 13 '12 at 21:10
Luckily, he doesn't need that factor to do what he needs to do, as the calibration will give him the numbers in the unit "pixels". And lens resolution doesnt have anything to do with it. Its like converting between cm and mm, you get the result in mm by multiplying the amount in cm by mm/cm . If you have 1000 pixels distributed evenly over 4.8mm, then it is 1000/4.8. and a 20mm focal length would be 20*1000/4.8 =4166 pixels, ideally, and the calibration would give a number close to that (maybe fx=4036 fy=4123), because 20mm is approximate and so is the 4.8mm sensor size, lines of dead space. – Michael Nielsen Sep 13 '12 at 21:56
So your saying the spatial resolution of the sensor is all your care about for this equation? I'm asking because when you combine the spatial resolution of a lens with the spatial resolution of a sensor, the "actual" resolution of the system is usually considerably lower than any of its components. – jrista Sep 13 '12 at 22:00
It has to do with 3D geometry , where the system needs to "bootstrap" a relationship between real world coordinates and the an arbitrary normalized "unit" system. This unit is pixels. The only place in the system where this is given is by the pixel size on the sensor. the mathematical models take into account 6 factors of lens distortions, non-square pixel cells, nonrightangled x/y axes, and misaligned lenses. The fact that the lens may blur too much does not change this conversion. it just makes the image blurry. – Michael Nielsen Sep 13 '12 at 23:44
It does not change the fact that 1 pixel is e.g. 5.5 x 5.503 um and a chessboard corner may be at position (354.87mm, 456.65mm, 3020.34mm) corresponding to pixel (305.35px , 243.745px ). And for that conversion you need stratification to the euclidean system. – Michael Nielsen Sep 13 '12 at 23:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.