I have earned many times using stackoverflow and google. I need to calculate the distance between my camera and the specified object.
To do this, I need to find the focal length of my camera. I also created a sample project, but I am throwing a Null Pointer Exception. Please, help..
The code is as follows.
public class MainActivity extends Activity { Camera mcamera; int focul_length; Parameters params; File mFile; public int PICTURE_ACTIVITY_CODE = 1; public String FILENAME = "sdcard/photo.jpg"; Camera.Parameters cameraParameters; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); launchTakePhoto(); } private void launchTakePhoto() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); cameraParameters = mcamera.getParameters(); CameraInfo myinfo = new CameraInfo(); float l=cameraParameters.getFocalLength();
source share