Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Android Camera opens in landscape mode orientation for front camera in openCV\javaCV

I made an app for opening a front camera in my android phone. The problem is it always opens the camera but the image shown is in landscape mode only.

image description

So irrespective of I am holding the phone right direction , I am getting 90 degree of orientation difference.

How to sort out this problem. Layout-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:opencv="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".AppLockMainActivity" >

<!-- <ImageView
    android:id="@+id/myImageView"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:src="@drawable/bol" />-->

  <org.opencv.android.NativeCameraView
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:visibility="visible"        
        android:id="@+id/nativeCamera"
        opencv:show_fps="false"
        opencv:camera_id="front" />

Application.xml

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <activity
        android:name="com.example.applock.AppLockMainActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name" 
        android:configChanges="keyboardHidden|orientation" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
click to hide/show revision 2
retagged

updated 2013-10-05 02:48:12 -0600

berak gravatar image

Android Camera opens in landscape mode orientation for front camera in openCV\javaCV

I made an app for opening a front camera in my android phone. The problem is it always opens the camera but the image shown is in landscape mode only.

image description

So irrespective of I am holding the phone right direction , I am getting 90 degree of orientation difference.

How to sort out this problem. Layout-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:opencv="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".AppLockMainActivity" >

<!-- <ImageView
    android:id="@+id/myImageView"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:src="@drawable/bol" />-->

  <org.opencv.android.NativeCameraView
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:visibility="visible"        
        android:id="@+id/nativeCamera"
        opencv:show_fps="false"
        opencv:camera_id="front" />

Application.xml

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <activity
        android:name="com.example.applock.AppLockMainActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name" 
        android:configChanges="keyboardHidden|orientation" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>