2014년 6월 4일 수요일

프리뷰 보이는 것과 다르게 Y-mirror되어서 이미지가 촬영되는 문제 관련


http://www.mangoboard.com/


프리뷰 보이는 것과 다르게 Y-mirror되어서 이미지가 촬영되는 문제 관련
디버깅을 해 보면
 카메라는 아래와 같다.

D/CameraService( 1350): sendCommand (orientation 1)



cameraService.cpp 파일에서 아래와 같이 수정
status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
    LOG1("sendCommand (pid %d)", getCallingPid());
    int orientation;
    Mutex::Autolock lock(mLock);
    status_t result = checkPidAndHardware();
    if (result != NO_ERROR) return result;

    if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
        // Mirror the preview if the camera is front-facing.
        orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
            LOG1("sendCommand (orientation %d)", orientation);//crazyboys 20140604
            orientation=0;//crazyboys 20140604

그리고, 카메라 초기화 코드 즉 MT9P111 카메라 센서에서 레지스터는
           {0xC850, 0x01, BYTE_LEN, 0},
           {0xC851, 0x01, BYTE_LEN,0},
           {0xC888, 0x01, BYTE_LEN,0},
           {0xC889, 0x01, BYTE_LEN, 0},        


4개 이다. 위의 값을 조정하여 프리뷰 화면을 맞추면 됩니다

packages\apps\Camera\src\com\android\camera\Util.java 파일도 수정을 해야 합니다. 

    public static int getDisplayOrientation(int degrees, int cameraId) {
        // See android.hardware.Camera.setDisplayOrientation for
        // documentation.
        Camera.CameraInfo info = new Camera.CameraInfo();
        Camera.getCameraInfo(cameraId, info);
        int result;

        if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            //result = (info.orientation + degrees) % 360;
            //result = (360 - result) % 360;  // compensate the mirror
            result = (info.orientation - degrees + 360) % 360;//crazyboys 20140604
        } else {  // back-facing
            result = (info.orientation - degrees + 360) % 360;
        }
        Log.v(TAG, "getDisplayOrientation"+result);
        return result;
    }

댓글 없음:

댓글 쓰기