diff options
author | Dimitar Borisov <x0152684@ti.com> | 2012-09-13 13:01:42 +0300 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-11-26 18:51:26 +0200 |
commit | c986059849fffaf93121b775d0bd7d65bae60b66 (patch) | |
tree | aec8a0dd414b9022eb2b0528cc182f29eda950a1 | |
parent | b22a262f3374b13a915c8f2778ced616b5f72c3f (diff) | |
download | hardware_ti_omap4-c986059849fffaf93121b775d0bd7d65bae60b66.zip hardware_ti_omap4-c986059849fffaf93121b775d0bd7d65bae60b66.tar.gz hardware_ti_omap4-c986059849fffaf93121b775d0bd7d65bae60b66.tar.bz2 |
camera_test: rotation fixes for image capture and video
Currently when capture video preview orientation is correct but captured video is rotated.
This is fixed when change preview sufrace orientation.
capture mode:
- display orientation = 90 degrees for both primary and secondary
- sensor orientation = 0 degrees for both primary and secondary
- capature rotation = 90 degrees for primary, 270 degrees for secondary
video mode:
- sensor orientation = 270 degrees for primary, 90 degrees for secondary
- display orientation = 0 degrees
Keys:
KEY_SENSOR_ORIENTATION - sensor orientation
KEY_ROTATION - capature rotation
CAMERA_CMD_SET_DISPLAY_ORIENTATION - display orientation
Change-Id: Id001140b68f002ccfbe6f2255a3a0ab2a29e99bf
Signed-off-by: Dimitar Borisov <x0152684@ti.com>
-rw-r--r-- | test/CameraHal/camera_test_menu.cpp | 41 | ||||
-rw-r--r-- | test/CameraHal/camera_test_script.cpp | 13 |
2 files changed, 48 insertions, 6 deletions
diff --git a/test/CameraHal/camera_test_menu.cpp b/test/CameraHal/camera_test_menu.cpp index aa8bfd8..a1f5ed2 100644 --- a/test/CameraHal/camera_test_menu.cpp +++ b/test/CameraHal/camera_test_menu.cpp @@ -1010,6 +1010,8 @@ int configureRecorder() { char videoFile[384],vbit_string[50]; videoFd = -1; + struct CameraInfo cameraInfo; + camera->getCameraInfo(camera_index, &cameraInfo); if ( ( NULL == recorder.get() ) || ( NULL == camera.get() ) ) { printf("invalid recorder and/or camera references\n"); @@ -1072,10 +1074,16 @@ int configureRecorder() { recording_counter++; - if ( recorder->setVideoSize(Vcapture_Array[VcaptureSizeIDX]->width, Vcapture_Array[VcaptureSizeIDX]->height) < 0 ) { - printf("error while configuring video size\n"); - - return -1; + if (cameraInfo.orientation == 90 || cameraInfo.orientation == 270 ) { + if ( recorder->setVideoSize(Vcapture_Array[VcaptureSizeIDX]->height, Vcapture_Array[VcaptureSizeIDX]->width) < 0 ) { + printf("error while configuring video size\n"); + return -1; + } + } else { + if ( recorder->setVideoSize(Vcapture_Array[VcaptureSizeIDX]->width, Vcapture_Array[VcaptureSizeIDX]->height) < 0 ) { + printf("error while configuring video size\n"); + return -1; + } } if ( recorder->setVideoEncoder(videoCodecs[videoCodecIDX].type) < 0 ) { @@ -1306,6 +1314,11 @@ int startPreview() { } else { // back-facing orientation = (cameraInfo.orientation - dinfo.orientation + 360) % 360; } + + if(!strcmp(params.get(KEY_MODE), "video-mode") ) { + orientation = 0; + } + camera->sendCommand(CAMERA_CMD_SET_DISPLAY_ORIENTATION, orientation, 0); camera->setParameters(params.flatten()); @@ -2055,6 +2068,15 @@ void stopPreview() { void initDefaults() { + struct CameraInfo cameraInfo; + + camera->getCameraInfo(camera_index, &cameraInfo); + if (cameraInfo.facing == CAMERA_FACING_FRONT) { + rotation = cameraInfo.orientation; + } else { // back-facing + rotation = cameraInfo.orientation; + } + antibanding_mode = getDefaultParameter("off", numAntibanding, antiband); focus_mode = getDefaultParameter("auto", numfocus, focus); fpsRangeIdx = getDefaultParameter("5000,30000", rangeCnt, fps_range_str); @@ -2080,7 +2102,6 @@ void initDefaults() { metaDataToggle = false; expBracketIdx = BRACKETING_IDX_DEFAULT; flashIdx = getDefaultParameter("off", numflash, flash); - rotation = 0; previewRotation = 0; zoomIDX = 0; videoCodecIDX = 0; @@ -2474,6 +2495,7 @@ int functional_menu() { int j = 0; int k = 0; const char *valstr = NULL; + struct CameraInfo cameraInfo; memset(area1, '\0', MAX_LINES*(MAX_SYMBOLS+1)); memset(area2, '\0', MAX_LINES*(MAX_SYMBOLS+1)); @@ -3069,11 +3091,20 @@ int functional_menu() { ippIDX = 3; params.set(KEY_IPP, ipp_mode[ippIDX]); params.set(CameraParameters::KEY_RECORDING_HINT, CameraParameters::FALSE); + previewRotation = 0; + params.set(KEY_SENSOR_ORIENTATION, previewRotation); } else if ( !strcmp(modevalues[capture_mode], "video-mode") ) { params.set(CameraParameters::KEY_RECORDING_HINT, CameraParameters::TRUE); + camera->getCameraInfo(camera_index, &cameraInfo); + previewRotation = ((360-cameraInfo.orientation)%360); + if (previewRotation >= 0 || previewRotation <=360) { + params.set(KEY_SENSOR_ORIENTATION, previewRotation); + } } else { ippIDX = ippIDX_old; params.set(CameraParameters::KEY_RECORDING_HINT, CameraParameters::FALSE); + previewRotation = 0; + params.set(KEY_SENSOR_ORIENTATION, previewRotation); } params.set(KEY_MODE, (modevalues[capture_mode])); diff --git a/test/CameraHal/camera_test_script.cpp b/test/CameraHal/camera_test_script.cpp index 7d77386..97d765c 100644 --- a/test/CameraHal/camera_test_script.cpp +++ b/test/CameraHal/camera_test_script.cpp @@ -209,6 +209,7 @@ int execute_functional_script(char *script) { //int frameR = 20; int frameRConst = 0; int frameRRange = 0; + struct CameraInfo cameraInfo; LOG_FUNCTION_NAME; @@ -763,16 +764,26 @@ int execute_functional_script(char *script) { case 'u': // HQ should always be in ldc-nsf // if not HQ, then return the ipp to its previous state - if( !strcmp(modevalues[capture_mode], "high-quality") ) { + if ( !strcmp((cmd + 1), "high-quality") ) { ippIDX_old = ippIDX; ippIDX = 3; params.set(KEY_IPP, ipp_mode[ippIDX]); params.set(CameraParameters::KEY_RECORDING_HINT, CameraParameters::FALSE); + previewRotation = 0; + params.set(KEY_SENSOR_ORIENTATION, previewRotation); } else if ( !strcmp((cmd + 1), "video-mode") ) { params.set(CameraParameters::KEY_RECORDING_HINT, CameraParameters::TRUE); + camera->getCameraInfo(camera_index, &cameraInfo); + previewRotation = ((360-cameraInfo.orientation)%360); + if (previewRotation >= 0 || previewRotation <=360) { + params.set(KEY_SENSOR_ORIENTATION, previewRotation); + } + printf("previewRotation: %d\n", previewRotation); } else { ippIDX = ippIDX_old; params.set(CameraParameters::KEY_RECORDING_HINT, CameraParameters::FALSE); + previewRotation = 0; + params.set(KEY_SENSOR_ORIENTATION, previewRotation); } a = checkSupportedParamScript(modevalues, nummodevalues, cmd); if (a > -1) { |