Wie finden Sie die Brennweite der android-Kamera?

Habe ich serached viel mit stackoverflow und google.Ich brauche zur Berechnung der Entfernung zwischen Kamera und Objekt.

Für die, die ich brauche zu finden meine Brennweite meiner Kamera.Ich habe das Beispiel-Projekt auch, aber seine Schaffung von Null-Pointer-Exception.Bitte um Hilfe..

Den code wie folgt.

    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(); //Here its creating Null Pointer Exception      
     mFile = new File(FILENAME);
            System.out.println("My Focul Length:--"+l);
    Uri outputFileUri = Uri.fromFile(mFile);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
    startActivityForResult(intent, PICTURE_ACTIVITY_CODE);
    }


    Also If possible please provide the code to get angle of Elevation.If possible.I need this very badly.I need your help guys!!



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
        {
            if (requestCode == PICTURE_ACTIVITY_CODE)
            {
            if (resultCode == RESULT_OK)
            {

            ImageView myimageView = (ImageView) findViewById(R.id.imageView1);
            Uri inputFileUri = Uri.fromFile(mFile);
            myimageView.setImageURI(inputFileUri);
            }
            }
            }






    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        //Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
  • Ist es überhaupt möglich? Viel Glück !!
  • Ja, es ist absolut möglich...Mit dem android.hardware.Kamera.Parameter-Klasse.Aber ich bin nicht in der Lage, um die Sache funktioniert 🙁
InformationsquelleAutor Chiradeep | 2013-08-30
Schreibe einen Kommentar