How to find out the focal length of the camera in ios and what is the height of the sensor?

I searched for everything where you can find the focal length of the camera and its rear sensor height. But I did not receive specific details.

I am developing one application that will calculate the actual height of a real-world object from the height seen in the image taken from the ios camera.

distance to the object (mm) =

focal length (mm) * real height of the object (mm) * image height (pixels) --------------------------- ----- ------------------------------------------- <br> object height (pixels ) * Sensor height (mm)

here I have the distance values ​​to the object as static, the height of the image in pixels. Now I need the focal length and height of the sensor to find out the real height of the object.

Thanks in advance. bskania

+7
source share
2 answers

A way to solve this problem.

First, take one object of the real world and its measure, that is, height and width (example of a coke cane) Now take the snap of the object you want to measure. For iphone or ipad, the focal length is fixed to 25 mm. Now create the object that you want to measure, and resize the image of the stone pavement of the real world in accordance with the object you want to measure.

use the equation

object_distance = (focus * real_object_height) / object_height;

here, real_object_height = coke height; and object_height = coke height with resizing

and accordingly measure the height of the object using the equation

height_of_frame = ((obj_distance) * measured_object_height_in_mm / 1000.0)) / focal;

width_of_frame = ((obj_distance) * measured_object_width_in_mm / 1000.0)) / focal;

this way you can find out the distance of the object and its measure. but you need two static data, that is, the focal length of the camera you are using, and the measurement of one real-world object for comparison.

Thanks, bskania.

0
source

EXIF Headers

iOS devices provide camera focal length in JPEG EXIF ​​headers. It is displayed inside iPhoto and almost any other tool.

Parameters for its software programming

A list of EXIF ​​header keys can be found in the CGImageProperties Reference .

 NSURL *imageFileURL = [NSURL fileURLWithPath:...]; CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)imageFileURL, NULL); if (imageSource == NULL) { // Error loading image ... return; } NSDictionary *options = @{kCGImageSourceShouldCache, @NO}; CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (CFDictionaryRef)options); if (imageProperties) { NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth); NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight); NSLog(@"Image dimensions: %@ x %@ px", width, height); CFRelease(imageProperties); } CFRelease(imageSource); 
+3
source

All Articles