Ask Your Question
0

OpenCV 2.4.5 front camera preview is upside down?!

asked Apr 23 '13

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.

Preview: (hide)

2 answers

Sort by » oldest newest most voted
2

answered Oct 12 '14

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.

Preview: (hide)

Comments

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

song_cr gravatar imagesong_cr (Apr 25 '18)edit
1

answered Apr 23 '13

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.

Preview: (hide)

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 (Jul 17 '13)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 (Jul 17 '13)edit

Question Tools

Stats

Asked: Apr 23 '13

Seen: 6,301 times

Last updated: Oct 11 '14