Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android onCameraFrame似乎不起作用_Android_Opencv - Fatal编程技术网

Android onCameraFrame似乎不起作用

Android onCameraFrame似乎不起作用,android,opencv,Android,Opencv,我试着画一个按钮列表。 但是,当我按下任何一个按钮时,我的应用程序都没有任何动作 这是我的密码: public Mat onCameraFrame(CvCameraViewFrame inputFrame) { final int viewMode = mViewMode; Log.i("test", "onCameraFrame"); switch (viewMode) { case VIEW_MODE_GRAY: title.setText(

我试着画一个按钮列表。 但是,当我按下任何一个按钮时,我的应用程序都没有任何动作

这是我的密码:

 public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    final int viewMode = mViewMode;
    Log.i("test", "onCameraFrame");
    switch (viewMode) {
    case VIEW_MODE_GRAY:
        title.setText("J");
        break;
    case VIEW_MODE_RGBA:
        break;
}
   return mRgba;
}

public boolean onOptionsItemSelected(MenuItem item) {

        if (item == mItemMode1) {
            mViewMode = VIEW_MODE_1;
        } else if (item == mItemMode2) {
            mViewMode = VIEW_MODE_2;
        } else if (item == mItemMode3) {
            mViewMode = VIEW_MODE_3;
        } else if (item == mItemModeRTDemo) {
            mViewMode = VIEW_MODE_RTDemo;
        }

        return true;
    }
实际上,我删除了
私人摄像机BridgeViewBase mOpenCvCameraView。在删除CamaraBridgeViewBase之前,我的列表工作正常。我不知道问题是否与我的操作有关

下面是我的xml文件

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

 <org.opencv.android.JavaCameraView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    opencv:show_fps="true"
    opencv:camera_id="any"
    android:id="@+id/tutorial2_activity_surface_view" />

 <org.opencv.android.NativeCameraView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    android:id="@+id/tutorial1_activity_native_surface_view"
    opencv:show_fps="true"
    opencv:camera_id="any" />

 <TextView
     android:id="@+id/title"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
     android:layout_alignParentTop="true"
     android:layout_marginLeft="39dp"
     android:text="title"
     android:textAppearance="?android:attr/textAppearanceMedium" />

onCameraFrame()
应该返回一个
Mat
,但您的代码不返回

你需要像这样的东西

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    final int viewMode = mViewMode;
    Log.i("test", "onCameraFrame");
    switch (viewMode)
    {
    case VIEW_MODE_GRAY:
        title.setText("J");
        return inputFrame.gray();
    case VIEW_MODE_RGBA:
        return inputFrame.rgba();
    }
}

我已经写了返回论点,但已经在结尾了。毕竟这个案子(我有4个案子,但另外2个现在没有行动)结束了。在所有情况下,以及在所有情况下,是否有任何不同的回报?