2012-08-01 3 views
4

사용자 정의 카메라 애플리케이션을 만들려고합니다. 사용자가이 애플리케이션에서 포커스 모드를 선택할 수있게하고 싶습니다.Android 카메라 터치 포커스

포커스 모드는 기본적으로 자동 초점입니다.

클릭 할 수 있도록 cameraView를 설정하면 화면에 한 지점을 터치 할 때 카메라의 초점이 그 지점에 오게됩니다. 어떻게 시작할 수 있니? 화면에 지점을 터치하면 아래 내 코드

public void takePhoto(File photoFile, String workerName, int width, int height, int  quality) { 
if (getAutoFocusStatus()){ 
    camera.autoFocus(new AutoFocusCallback() { 
     @Override 
     public void onAutoFocus(boolean success, Camera camera) { 
      camera.takePicture(shutterCallback, rawCallback, jpegCallback); 
     } 
    }); 
}else{ 
    camera.takePicture(shutterCallback, rawCallback, jpegCallback); 
} 

this.photoFile = photoFile; 
this.workerName = workerName; 
this.imageOutputWidth = width; 
this.imageOutputHeight = height; 
} 

public void takePhoto(File photoFile, int width, int height, int quality) { 
takePhoto(photoFile, null, width, height, quality); 
} 

답변

3

, 당신은 Camera.Area을 얻어야한다. 초점 영역은 현재 포커스 모드가 FOCUS_MODE_AUTO, FOCUS_MODE_MACRO, FOCUS_MODE_CONTINUOUS_VIDEO 또는 FOCUS_MODE_CONTINUOUS_PICTURE 인 경우에만 적용됩니다. 그런 다음 포커스를 trgigger하려면 setFocusAreas 메서드를 호출해야합니다. 카메라의 시야는 왼쪽 상단 모서리 (-1000, -1000)에서 오른쪽 하단 모서리 (1000, 1000)로 매핑됩니다. 좌표 변환을해야합니다.