2014-01-14 5 views
0

나는 삼성 gt i8260, samsung s4 및 sony ericsson xperia mini st15i에서 안드로이드 응용 프로그램을 테스트하고 있습니다.camera.cancelAutoFocus 반환하지 않거나 예외를 throw하지 않습니다

미리보기 모드와 자동 초점 (callback은 항상 매번 camera.autoFocus를 호출합니다)에서 코드의 특정 지점에서 응용 프로그램이 camera.cancelAutoFocus()를 호출 한 다음 손전등에 대한 일부 매개 변수를 설정합니다 (토치를 시작 또는 중지하기 위해 모드) 그리고 마지막으로 camera.autoFocus를 호출합니다.

S4와 Xperia 모두 잘 작동합니다. 그러나 gt는 camera.cancelAutoFocus를 호출 한 후 응답하지 않으며 반환도 예외도 발생시키지 않습니다. 그냥 달려있다.

cancelAutoFocus에 대한 문서

는 :

Cancels any auto-focus function in progress. Whether or not auto-focus is currently in progress, this function will return the focus position to the default. If the camera does not support auto-focus, this is a no-op. 

이 동작을 설명하지 않습니다.

cancelAutoFocus를 제거하면 setParameters에서 예외를 throw하는 Xperia 및 S4에서는 작동하지 않지만 GT에서는 작동하지 않습니다.

누구나 동일하거나 유사한 문제에 직면 해 있습니까? 이 문제를 어떻게 극복 할 수 있습니까? 하드웨어 고유입니까, 아니면 버그입니까?

답변

0

앱에 문제가 있다고 설명하지는 않지만 계속 초점을 사용하는 것을 고려해야합니다 (예 : Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE 또는 FOCUS_MODE_CONTINUOUS_VIDEO). 그 getSupportedFocusModes 먼저 하드웨어에서 지원하는 경우

http://developer.android.com/reference/android/hardware/Camera.Parameters.html#FOCUS_MODE_CONTINUOUS_PICTURE

것은()를 확인해야합니다.

이렇게하면 부드럽고 지속적인 초점 경험을 얻을 수 있습니다.

+0

나는 FOCUS_MODE_CONTINUOUS_VIDEO를 사용했습니다. 원하는 결과를 제공하지 않습니다. API 버전 제약 (9)으로 인해 CONTINUOUS_PICTURE를 사용할 수 없습니다. – Blim

0

이것은 내가 뭘하고 surfaceDestroyed 방법으로 제거

  • 필요하다면 내가
  • 시작 플래시 라이트 surfaceChanged에 자동 초점을 시작하고 모든 장치

    1. 근무하고 어떻게

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) 
    { 
        if(mCamera==null) 
         return; 
    
        Camera.Parameters parameters = null; 
        parameters = mCamera.getParameters(); 
        if (Holder.getSurface() == null) 
        { // preview surface does not exist 
         //mCamera = null; 
         return; 
        } 
    
        // Stopping the camera preview so as to set the new params 
        try 
        { 
         mCamera.stopPreview();// why the application is crashing here 
        } 
        catch(Exception e) 
        { 
         e.printStackTrace(); 
        } 
    
        try 
        { 
         mCamera.setParameters(parameters); 
         mCamera.startPreview(); 
    
         //Check Whether device supports AutoFlsh, If you YES then Enable AutoFlash 
         if (parameters.getSupportedFlashModes().contains(android.hardware.Camera.Parameters.FLASH_MODE_AUTO)) 
         { 
          parameters.setFlashMode(Parameters.FLASH_MODE_AUTO); 
         } 
    
         if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { 
          parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);//FOCUS_MODE_CONTINUOUS_VIDEO 
         } 
         else if (parameters.getSupportedFocusModes().contains(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO)) 
         { 
          mCamera.autoFocus(myAutoFocusCallback); 
          //parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); 
         } 
        } 
        catch(Exception e1) 
        { 
         e1.printStackTrace(); 
        } 
    } 
    
    
    public void surfaceDestroyed(SurfaceHolder holder) 
    { 
        try 
        { 
         mCamera.cancelAutoFocus(); 
         mCamera.stopPreview();  
         mCamera.release(); 
         mCamera = null; 
        } 
        catch(Exception e) 
        { 
         e.printStackTrace(); 
        } 
    } 
    
    // --------------- AutoFocusCallback methods implementations ----------// 
    AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback() 
    { 
        @Override 
        public void onAutoFocus(boolean arg0, Camera arg1) 
        {     
         isAutofoucsed =true; 
        } 
    }; 
    
  • +0

    카메라 미리보기 중에 토치를 켜고 싶습니다. 내가 카메라를 자동 초점을 응용 프로그램이 충돌하는 동안 토치를 사용하도록 매개 변수를 설정하려고하면 일부 장치 (xperia 미니)에서 아는 한. 그래서 자동 초점을하는 동안 임의의 시간에 자동 초점을 취소하려고합니다. 내 삼성 장치 cancelAutofocus 장치를 호출하지 않는 매개 변수의 설정에 영향을 미치지 않습니다 ... – Blim

    +0

    @Blim 지금 확인하십시오 또한이 코드 스 니펫으로 플래시 빛뿐만 아니라 btw 추가했습니다. 시작하는 어두운 개체에 카메라를 이동할 때 자동 초점도 있습니다. 미리보기 중에 플래시 라이트. 너는 아직도 이것에 문제가 있음을 나에게 알린다. – swiftBoy

    관련 문제