Ask Your Question
0

OpenCV 2.4.5 front camera preview is upside down?!

asked 2013-04-23 04:36:54 -0600

s4eed gravatar image

I tried to use my device front camera with this code :

<org.opencv.android.JavaCameraView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone"
        android:id="@+id/tutorial1_activity_java_surface_view"
        opencv:show_fps="true"
        opencv:camera_id="front" />

It worked but the preview is upside down! How to fix it? I use OpenCV 2.4.5.
Here is my user interface file :

<LinearLayout 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="match_parent"
    android:orientation="horizontal"
    android:layout_height="match_parent" >

    <org.opencv.android.JavaCameraView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone"
        android:id="@+id/tutorial1_activity_java_surface_view"
        opencv:show_fps="true"
        opencv:camera_id="front" />

    <org.opencv.android.NativeCameraView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone"
        android:id="@+id/tutorial1_activity_native_surface_view"
        opencv:show_fps="true"
        opencv:camera_id="front" />

</LinearLayout>

Both of native camera and java camera have this problem.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
2

answered 2014-10-11 19:11:02 -0600

spiritinlife gravatar image

Hello in case you are still wondering the flip function that is suggested by the other topics for android is : Core.flip(aInputFrame,aInputFrame,1); //1 is for y-axis

You should put this in the first line of the -> public Mat onCameraFrame(Mat aInputFrame) <-function , to achieve the desired effect.

edit flag offensive delete link more

Comments

My method signature is not same as yours. Mine is public Mat onCameraFrame(CvCameraViewFrame inputFrame). Any idea, please?

song_cr gravatar imagesong_cr ( 2018-04-25 09:04:21 -0600 )edit
1

answered 2013-04-23 09:20:15 -0600

Simply said, this problems has already been answered in this topic.

Next time please use the search button. More tips on how to use this forum can be found here.

edit flag offensive delete link more

Comments

Hi.

The other topic you mention concerns the same issue, but in iOS.

How would it apply to Android phones? I can't say I understand where and what change to make, sorry.

BR, Luís

Luis gravatar imageLuis ( 2013-07-17 13:26:08 -0600 )edit

Use the flip function on the incomming data, it is because of difference between both coördinate systems. Be sure to flip around the correct horizontal axis :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-17 13:59:07 -0600 )edit

Question Tools

Stats

Asked: 2013-04-23 04:36:54 -0600

Seen: 6,278 times

Last updated: Oct 11 '14