Selasa, 28 Juli 2020

Video Player

package com.android.AndroidVideoPlayer;

import android.app.Activity;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;

//Implement SurfaceHolder interface to Play video
//Implement this interface to receive information about changes to the surface
public class AndroidVideoPlayer extends Activity implements SurfaceHolder.Callback{

MediaPlayer mediaPlayer;
SurfaceView surfaceView;
SurfaceHolder surfaceHolder;
boolean pausing = false;;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        Button buttonPlayVideo = (Button)findViewById(R.id.playvideoplayer);
       
        getWindow().setFormat(PixelFormat.UNKNOWN);
     
        //Displays a video file. 
        VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
     
       
        String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.k;
Uri uri = Uri.parse(uriPath);
        mVideoView.setVideoURI(uri);
        mVideoView.requestFocus();
        mVideoView.start();

       
       
        buttonPlayVideo.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
VideoView mVideoView = (VideoView)findViewById(R.id.videoview);
       // VideoView mVideoView = new VideoView(this);
        String uriPath = "android.resource://com.android.AndroidVideoPlayer/"+R.raw.k;
Uri uri = Uri.parse(uriPath);
        mVideoView.setVideoURI(uri);
        mVideoView.requestFocus();
        mVideoView.start();


}});
     }
   
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub

}

@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub

}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub

}
}
+++++++++++++++++++++++++++++++++++++

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
  <TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
  <Button
android:id="@+id/playvideoplayer" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="- PLAY Video -"
    />

   
   <VideoView
android:id="@+id/videoview" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
   

</LinearLayout>




CustomGridView

package com.androidexample.gridview;

import com.androidexample.gridview.adapter.CustomGridAdapter;
import android.app.Activity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;

public class GridViewExample extends Activity {

GridView gridView;

static final String[] GRID_DATA = new String[] { "Windows" ,
"iOS", "Android" ,"Blackberry","Java" ,
"JQuery", "Phonegap" ,"SQLite","Thread" ,
"Video"};

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.grid_view_android_example);

//Get gridview object from xml file
gridView = (GridView) findViewById(R.id.gridView1);

// Set custom adapter (GridAdapter) to gridview
gridView.setAdapter(new CustomGridAdapter(this, GRID_DATA));

gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {

Toast.makeText(
getApplicationContext(),
((TextView) v.findViewById(R.id.grid_item_label))
.getText(), Toast.LENGTH_SHORT).show();

}
});

}

}


BUAT FOLDER adapter

package com.androidexample.gridview.adapter;

import com.androidexample.gridview.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class CustomGridAdapter extends BaseAdapter {

private Context context;
private final String[] gridValues;

//Constructor to initialize values
public CustomGridAdapter(Context context, String[] gridValues) {
this.context = context;
this.gridValues = gridValues;
}

@Override
public int getCount() {

// Number of times getView method call depends upon gridValues.length
return gridValues.length;
}

@Override
public Object getItem(int position) {

return null;
}

@Override
public long getItemId(int position) {

return 0;
}


    // Number of times getView method call depends upon gridValues.length

public View getView(int position, View convertView, ViewGroup parent) {

//LayoutInflator to call external grid_item.xml file

LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View gridView;

if (convertView == null) {

gridView = new View(context);

// get layout from grid_item.xml
gridView = inflater.inflate(R.layout.grid_item, null);

// set value into textview

TextView textView = (TextView) gridView
.findViewById(R.id.grid_item_label);
textView.setText(gridValues[position]);

// set image based on selected text

ImageView imageView = (ImageView) gridView
.findViewById(R.id.grid_item_image);

String mobile = gridValues[position];

if (mobile.equals("Windows")) {

imageView.setImageResource(R.drawable.windows_logo);

} else if (mobile.equals("iOS")) {

imageView.setImageResource(R.drawable.ios_logo);

} else if (mobile.equals("Blackberry")) {

imageView.setImageResource(R.drawable.blackberry_logo);

} else {

imageView.setImageResource(R.drawable.android_logo);
}

} else {
gridView = (View) convertView;
}

return gridView;
}
}



grid_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dp" >
 
    <ImageView
        android:id="@+id/grid_item_image"
        android:layout_width="50px"
        android:layout_height="50px"
        android:layout_marginRight="10px"
        android:src="@drawable/android_logo" >
    </ImageView>
    
   <LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="0dp" 
    android:orientation="vertical">
    <TextView
        android:id="@+id/grid_item_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:layout_marginTop="3px"
        android:textSize="15px" >
    </TextView>
    
    <TextView
        android:id="@+id/grid_item_label_static"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Example"
        android:layout_marginTop="3px"
        android:textSize="12px" />
    
</LinearLayout>       
    
 
</LinearLayout>




grid_view_android_example.xml
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gridView1"
    android:numColumns="auto_fit"
    android:gravity="center"
    android:columnWidth="100dp"
    android:stretchMode="columnWidth"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

</GridView>



GET ACCOUNT MAIL

package com.example.registeredemails;

import android.os.Bundle;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.util.Log;
import android.widget.TextView;

public class RegisteredEmailAccounts extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.registered_email_account);
final TextView accountsData = (TextView) findViewById(R.id.accounts);

String possibleEmail="";

   try{
       possibleEmail += "************* Get Registered Gmail Account *************\n\n";
       Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
     
       for (Account account : accounts) {
       
    possibleEmail += " --> "+account.name+" : "+account.type+" , \n";
         possibleEmail += " \n\n";
       
       }
  }
      catch(Exception e)
      {
       Log.i("Exception", "Exception:"+e) ;
      }
     
     
      try{
       possibleEmail += "**************** Get All Registered Accounts *****************\n\n";
     
       Account[] accounts = AccountManager.get(this).getAccounts();
       for (Account account : accounts) {
       
      possibleEmail += " --> "+account.name+" : "+account.type+" , \n";
          possibleEmail += " \n";
       
       }
  }
      catch(Exception e)
      {
       Log.i("Exception", "Exception:"+e) ;
      }
 
   // Show on screen   
   accountsData.setText(possibleEmail);
     
       Log.i("Exception", "mails:"+possibleEmail) ;
}


}
++++++++++++++++
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".RegisteredEmailAccounts" >

    <TextView
        android:id="@+id/accounts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

</RelativeLayout>


++++++++++++++++++++


 <uses-permission android:name="android.permission.GET_ACCOUNTS" />

WebView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
     
   <WebView 
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>     
</LinearLayout>


package com.androidexample.webview;

import java.io.File;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.webkit.ConsoleMessage;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebSettings.PluginState;
import android.widget.Toast;

public class ShowWebView extends Activity {
private WebView webView;
final Activity activity = this;
public Uri imageUri;
private static final int FILECHOOSER_RESULTCODE   = 2888;
    private ValueCallback<Uri> mUploadMessage;
    private Uri mCapturedImageURI = null;
   
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.show_web_view);
   
String webViewUrl = "http://www.androidexample.com/media/webview/details.html";
webView = (WebView) findViewById(R.id.webView1); 
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);
   
    //webView.getSettings().setUseWideViewPort(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(false);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setSupportZoom(true);
   
    webView.loadUrl(webViewUrl);
   
startWebView();
}

private void startWebView() {
webView.setWebViewClient(new WebViewClient() {     
        ProgressDialog progressDialog;
        public boolean shouldOverrideUrlLoading(WebView view, String url) {             
        if(url.contains("ExternalLinks")){
        view.getContext().startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return true;
       
        } else {
                view.loadUrl(url);
                return true;
            }          
        }
        public void onLoadResource (WebView view, String url) {
            if (progressDialog == null && url.contains("androidexample")
            )
            {
                progressDialog = new ProgressDialog(ShowWebView.this);
                progressDialog.setMessage("Loading...");
                progressDialog.show();
            }
        }
       
        // Called when all page resources loaded
        public void onPageFinished(WebView view, String url) {
       
            try{
            // Close progressDialog
            if (progressDialog.isShowing()) {
                progressDialog.dismiss();
                progressDialog = null;
            }
            }catch(Exception exception){
                exception.printStackTrace();
            }
        }
     
    });
   
    webView.setWebChromeClient(new WebChromeClient() {
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType){ 
           /**updated, out of the IF **/
                            mUploadMessage = uploadMsg;
           /**updated, out of the IF **/
            try{
            File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "AndroidExampleFolder");
                if (!imageStorageDir.exists()) {
                    imageStorageDir.mkdirs();
                }
                File file = new File(imageStorageDir + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg");
                mCapturedImageURI = Uri.fromFile(file); // save to the private variable

                final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
               // captureIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");

                Intent chooserIntent = Intent.createChooser(i, "Image Chooser");
                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[] { captureIntent });

                startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
              }
             catch(Exception e){
            Toast.makeText(getBaseContext(), "Camera Exception:"+e, Toast.LENGTH_LONG).show();
             }
            //}
        }
       
        public void openFileChooser(ValueCallback<Uri> uploadMsg){
            openFileChooser(uploadMsg, "");
        }
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileChooser(uploadMsg, acceptType);
        }

        public boolean onConsoleMessage(ConsoleMessage cm) {       
            onConsoleMessage(cm.message(), cm.lineNumber(), cm.sourceId());
        //Toast.makeText(getBaseContext(), cm.message()+" :message", Toast.LENGTH_LONG).show();
            return true;
        }
        public void onConsoleMessage(String message, int lineNumber, String sourceID) {
        }
        /** Added code to clarify chooser. **/
   
    });
 
   
   
   
}


@Override 
protected void onActivityResult(int requestCode, int resultCode,  Intent intent) {
if(requestCode==FILECHOOSER_RESULTCODE)  { 
    if (null == this.mUploadMessage) {
            return;
        }
   Uri result=null;
   try{
        if (resultCode != RESULT_OK) {
            result = null;
           
        } else {
            result = intent == null ? mCapturedImageURI : intent.getData();
        }
    }
        catch(Exception e){
            Toast.makeText(getApplicationContext(), "activity :"+e, Toast.LENGTH_LONG).show();
        }
       
    mUploadMessage.onReceiveValue(result);
    mUploadMessage = null;

}

}
@Override
    public void onBackPressed() {
        if(webView.canGoBack()) {
            webView.goBack();
        } else {
            super.onBackPressed();
        }
    }

}



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidexample.webview"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"/>

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
       
        <activity
            android:label="@string/app_name"
            android:name=".ShowWebView"
            android:theme="@android:style/Theme.NoTitleBar">
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>











App Deteksi TM

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:opencv="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:screenOrientation="landscape">

    <org.opencv.android.JavaCameraView
        android:id="@+id/deteksi"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        opencv:camera_id="any"
        opencv:show_fps="true"

        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center|bottom"
        android:layout_margin="16dp"
        android:gravity="center"
        android:orientation="horizontal"
        android:weightSum="2"
        android:layout_marginTop="260dp">

        <Button
            android:id="@+id/btnCek"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="COMPARE"
            android:layout_gravity="center"/>
    </LinearLayout>

</RelativeLayout>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/hasil"  >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:padding="10dip" >
        <!--  View Title Label -->



        <ImageView
            android:id="@+id/Hasil_gambar"
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:layout_gravity="center_horizontal"
             />


        <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="30dip"
            android:text="Nama"
            android:textColor="#000000"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/judul"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textStyle="bold"
            android:layout_gravity="center_horizontal"
            android:text="Nama"
            android:textColor="#000000" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Kingdom"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/kingdom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold"/>

        <TextView

            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Divisi"
            android:layout_gravity="center_horizontal"
            android:textColor="#000000"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/divisi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textColor="#000000"
            android:textSize="20sp"
            android:textStyle="bold"/>

        <TextView

            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Subdivisi"
            android:layout_gravity="center_horizontal"
            android:textColor="#000000"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/subdivisi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold"/>

        <TextView

            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Kelas"
            android:layout_gravity="center_horizontal"
            android:textColor="#000000"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/kelas"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:textSize="20sp"
            android:layout_gravity="center_horizontal"
            android:textStyle="bold"/>

        <TextView

            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Ordo"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/ordo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold"/>

        <TextView

            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Famili"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/famili"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:textSize="20sp"
            android:layout_gravity="center_horizontal"
            android:textStyle="bold"/>

        <TextView

            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Genus"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/genus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold"/>

        <TextView

            android:layout_width="wrap_content"
            android:layout_marginTop="15dip"
            android:layout_height="wrap_content"
            android:text="Spesies"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/spesies"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#000000"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textStyle="bold"/>

    </LinearLayout>

</ScrollView>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fau.deteksidaun">

    <uses-permission android:name="android.permission.CAMERA" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.front"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.front.autofocus"
        android:required="false" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/daun"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".HalamanUtama">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

package com.example.fau.deteksidaun;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.android.Utils;
import org.opencv.core.DMatch;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.Scalar;
import org.opencv.features2d.DescriptorExtractor;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.FeatureDetector;
import org.opencv.features2d.Features2d;
import org.opencv.imgproc.Imgproc;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

public class Deteksi extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{


    String gab="";
    int jd=10;
    Button btnCek;
    String[]arObject;
    String[]arNama;

String hasilObject="";
    private static final String TAG = "OCVSample::Activity";
    private static final int REQUEST_PERMISSION = 100;
    private int w, h;
    private CameraBridgeViewBase mOpenCvCameraView;
    TextView tvName;
    Scalar RED = new Scalar(255, 0, 0);
    Scalar GREEN = new Scalar(0, 255, 0);
    FeatureDetector detector;
    DescriptorExtractor descriptor;
    DescriptorMatcher matcher;

    Mat descriptors2;
    MatOfKeyPoint keypoints2;

    MatOfKeyPoint [] key1;
    Mat desc1[],citra1[];

    static {
        if (!OpenCVLoader.initDebug())
            Log.d("ERROR", "Unable to load OpenCV");
        else
            Log.d("SUCCESS", "OpenCV loaded");
    }

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS: {
                    Log.i(TAG, "OpenCV loaded successfully");
                    // mOpenCvCameraView.enableView();
                    try {
                        initializeOpenCVDependencies();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                break;
                default: {
                    super.onManagerConnected(status);
                }
                break;
            }
        }
    };

    private void initializeOpenCVDependencies() throws IOException {
        mOpenCvCameraView.enableView();
        detector = FeatureDetector.create(FeatureDetector.ORB);
        descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

        Button btnCek=(Button)findViewById(R.id.btnCek);
        btnCek.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                Intent i = new Intent(Deteksi.this, HasilKlasifikasi.class);
                i.putExtra("hasil ", hasilObject);
                startActivity(i);
            }});



        arObject=new String[jd];
arNama=new String[jd];
desc1=new Mat[jd];
citra1=new Mat[jd];
key1=new MatOfKeyPoint[jd];

        arObject[0]="obj1.jpg";
        arObject[1]="obj2.jpg";
        arObject[2]="obj3.jpg";

        arNama[0]="Object 1";
        arNama[1]="Object 2";
        arNama[2]="Object 3";

        AssetManager assetManager = getAssets();

        for(int k=0;k<jd;k++) {
            citra1[k] = new Mat();
            InputStream istr1 = assetManager.open(arObject[k]);//a.jpeg
            Bitmap bitmap1 = BitmapFactory.decodeStream(istr1);
            Utils.bitmapToMat(bitmap1, citra1[k] );
            Imgproc.cvtColor(citra1[k] , citra1[k] , Imgproc.COLOR_RGB2GRAY);


            citra1[k] .convertTo(citra1[k] , 0);
            desc1[k] = new Mat();
            key1[k] = new MatOfKeyPoint();
            detector.detect(citra1[k] , key1[k]);
            descriptor.compute(citra1[k] , key1[k], desc1[k]);
        }
        //============================================1
    }
    public Deteksi() {
        Log.i(TAG, "Instantiated new " + this.getClass());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.i(TAG, "called onCreate");
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.activity_deteksi);


        if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, REQUEST_PERMISSION);
        }
        mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.deteksi);
        mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
        mOpenCvCameraView.setCvCameraViewListener(this);
    }


    @Override
    public void onPause() {
        super.onPause();
        if (mOpenCvCameraView != null)
            mOpenCvCameraView.disableView();
    }
    @Override
    public void onResume() {
        super.onResume();
        if (!OpenCVLoader.initDebug()) {
            Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
            OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, Deteksi.this, mLoaderCallback);
        } else {
            Log.d(TAG, "OpenCV library found inside package. Using it!");
            mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
        }

        }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mOpenCvCameraView != null)
            mOpenCvCameraView.disableView();
    }
    @Override
    public void onCameraViewStarted(int width, int height) {
        w = width;
        h = height;
    }

    @Override
    public void onCameraViewStopped() {

    }

    public Mat recognize(Mat aInputFrame) {//aInputFrame=objek dari Kamera
        double nmin = 10000000;
        int indexKe=0;

        Imgproc.cvtColor(aInputFrame, aInputFrame, Imgproc.COLOR_RGB2GRAY);
        descriptors2 = new Mat();
        keypoints2 = new MatOfKeyPoint();
        detector.detect(aInputFrame, keypoints2);
        descriptor.compute(aInputFrame, keypoints2, descriptors2);


        MatOfDMatch matches = null;
        Double max_dist = 0.0;
        Double min_dist = 100.0;
        int JM = 0;

        matches = new MatOfDMatch();
        for(int k=0;k<jd;k++){
        if (citra1[k].type() == aInputFrame.type()) {
            try {
                matcher.match(desc1[k], descriptors2, matches);

                List<DMatch> matchesList1 = matches.toList();

                max_dist = 0.0;
                min_dist = 100.0;

                JM = matchesList1.size();
                for (int i = 0; i < JM; i++) {
                    Double dist = (double) matchesList1.get(i).distance;
                    if (dist < min_dist)
                        min_dist = dist;
                    if (dist > max_dist)
                        max_dist = dist;
                }
                Log.d("MAXMIN15", "@Object1=" + max_dist + "@" + min_dist + "@" + (1.2 * min_dist));
                if (min_dist < nmin) {
                    indexKe = k;
                    nmin = min_dist;
                }

            } catch (Exception ee) {
            }
        } else {
            return aInputFrame;
        }

    }//loop


        //=================================================================================3
        matches = new MatOfDMatch();
        if (citra1[indexKe].type() == aInputFrame.type()) {
            try {
                matcher.match(desc1[indexKe], descriptors2, matches);
            } catch (Exception ee) {
            }

        } else {
            return aInputFrame;
        }

        List<DMatch> matchesListOut = matches.toList();
        JM = matchesListOut.size();
        List<DMatch>  listBest=null;
        Mat imgBest=new Mat();
        MatOfKeyPoint keyBest=null;

            listBest=matchesListOut;
            imgBest=citra1[indexKe];
            keyBest=key1[indexKe];
        hasilObject=arNama[indexKe];

        //=================================================================================================LAST
        int mm=0;
        LinkedList<DMatch> good_matches = new LinkedList<DMatch>();
        for (int i = 0; i < JM; i++) {
            if (listBest.get(i).distance <= (1.2 * min_dist)) {//1.5 * min_dist
                good_matches.addLast(listBest.get(i));
                mm++;
            }
        }
        gab=gab+String.valueOf(mm)+"#";
        Log.d("GAB","#"+gab+"+++++++++++++++++++++++++++++++++++++++++++++");

        MatOfDMatch goodMatches = new MatOfDMatch();
        goodMatches.fromList(good_matches);
        Mat outputImg = new Mat();


        MatOfByte drawnMatches = new MatOfByte();
        if (aInputFrame.empty() || aInputFrame.cols() < 1 || aInputFrame.rows() < 1) {
            return aInputFrame;
        }
        Features2d.drawMatches(imgBest, keyBest, aInputFrame, keypoints2, goodMatches, outputImg, GREEN, RED, drawnMatches, Features2d.NOT_DRAW_SINGLE_POINTS);
        Imgproc.resize(outputImg, outputImg, aInputFrame.size());


        return outputImg;
    }


        @Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
        return recognize(inputFrame.rgba());
    }
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.example.fau.deteksidaun;

import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.IOException;
import java.io.InputStream;

public class HasilKlasifikasi extends AppCompatActivity {
String namafile="tes.jpg";
    private AssetManager assetManager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hasil_klasifikasi);
        assetManager = getAssets();


        Intent i = this.getIntent();
        String daun=i.getStringExtra("hasil");

      

        ImageView Hasil_gambar= (ImageView) findViewById(R.id.Hasil_gambar);
        TextView txtJudul= (TextView) findViewById(R.id.judul);txtJudul.setText(nama);
        TextView txtKingdom = (TextView) findViewById(R.id.kingdom);txtKingdom.setText(kingdom);
        TextView txtdivisi= (TextView) findViewById(R.id.divisi);txtdivisi.setText(divisi);
        TextView txtsubdivisi= (TextView) findViewById(R.id.subdivisi);;txtsubdivisi.setText(subdivisi);
        TextView txtkelas= (TextView) findViewById(R.id.kelas);txtkelas.setText(kelas);
        TextView txtordo= (TextView) findViewById(R.id.ordo);txtordo.setText(ordo);
        TextView txtfamili= (TextView) findViewById(R.id.famili);txtfamili.setText(famili);
        TextView txtgenus= (TextView) findViewById(R.id.genus);txtgenus.setText(genus);
        TextView txtspesies= (TextView) findViewById(R.id.spesies);txtspesies.setText(spesies);

        try {
            InputStream is = assetManager.open(namafile);
            Bitmap bitmap = BitmapFactory.decodeStream(is);
            Hasil_gambar.setImageBitmap(bitmap);
        } catch (IOException e) {
            Log.e("Hasil_gambar", e.getMessage());
        }
    }


    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}









Algoritma Android

package com.example.fau.deteksidaun;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.android.Utils;
import org.opencv.core.DMatch;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.Scalar;
import org.opencv.features2d.DescriptorExtractor;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.FeatureDetector;
import org.opencv.features2d.Features2d;
import org.opencv.imgproc.Imgproc;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

public class Deteksi extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{


    String gab="";
    int jd=49;
    Button btnCek;
    String[]arDaun;
    String[]arNama;

String hasildaun="";
    private static final String TAG = "OCVSample::Activity";
    private static final int REQUEST_PERMISSION = 100;
    private int w, h;
    private CameraBridgeViewBase mOpenCvCameraView;
    Scalar RED = new Scalar(255, 0, 0);
    Scalar GREEN = new Scalar(0, 255, 0);
    FeatureDetector detector;
    DescriptorExtractor descriptor;
    DescriptorMatcher matcher;

    Mat descriptors2;
    MatOfKeyPoint keypoints2;

    MatOfKeyPoint [] key1;
    Mat desc1[],citra1[];

    static {
        if (!OpenCVLoader.initDebug())
            Log.d("ERROR", "Unable to load OpenCV");
        else
            Log.d("SUCCESS", "OpenCV loaded");
    }

    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS: {
                    Log.i(TAG, "OpenCV loaded successfully");
                    // mOpenCvCameraView.enableView();
                    try {
                        initializeOpenCVDependencies();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                break;
                default: {
                    super.onManagerConnected(status);
                }
                break;
            }
        }
    };

    private void initializeOpenCVDependencies() throws IOException {
        mOpenCvCameraView.enableView();
        detector = FeatureDetector.create(FeatureDetector.ORB);
        descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);

        Button btnCek=(Button)findViewById(R.id.btnCek);
        btnCek.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                Intent i = new Intent(Deteksi.this, HasilKlasifikasi.class);
                i.putExtra("hasildaun", hasildaun);
                startActivity(i);
            }});



        arDaun=new String[jd];
        arNama=new String[jd];
        desc1=new Mat[jd];
        citra1=new Mat[jd];
        key1=new MatOfKeyPoint[jd];

        arDaun[0]="daunjambu1.jpg";
        arDaun[1]="daunjambu3.jpg";
        arDaun[2]="daunjambu4.jpg";
        arDaun[3]="daunjambu5.jpg";
        arDaun[4]="daunjambu6.jpg";
        arDaun[5]="daunjambu7.jpg";
        arDaun[6]="daunjambu8.jpg";
        arDaun[7]="daunjambu9.jpg";
        arDaun[8]="daunjambu10.jpg";

        arDaun[9]="daunjarak1.jpg";
        arDaun[10]="daunjarak2.jpg";
        arDaun[11]="daunjarak3.jpg";
        arDaun[12]="daunjarak4.jpg";
        arDaun[13]="daunjarak5.jpg";
        arDaun[14]="daunjarak6.jpg";
        arDaun[15]="daunjarak7.jpg";
        arDaun[16]="daunjarak8.jpg";
        arDaun[17]="daunjarak9.jpg";
        arDaun[18]="daunjarak10.jpg";

        arDaun[19]="daunjeruk1.jpg";
        arDaun[20]="daunjeruk2.jpg";
        arDaun[21]="daunjeruk3.jpg";
        arDaun[22]="daunjeruk4.jpg";
        arDaun[23]="daunjeruk5.jpg";
        arDaun[24]="daunjeruk6.jpg";
        arDaun[25]="daunjeruk7.jpg";
        arDaun[26]="daunjeruk8.jpg";
        arDaun[27]="daunjeruk9.jpg";
        arDaun[28]="daunjeruk10.jpg";

        arDaun[29]="daunpepaya1.jpg";
        arDaun[30]="daunpepaya2.jpg";
        arDaun[31]="daunpepaya3.jpg";
        arDaun[32]="daunpepaya4.jpg";
        arDaun[33]="daunpepaya5.jpg";
        arDaun[34]="daunpepaya6.jpg";
        arDaun[35]="daunpepaya7.jpg";
        arDaun[36]="daunpepaya8.jpg";
        arDaun[37]="daunpepaya9.jpg";
        arDaun[38]="daunpepaya10.jpg";

        arDaun[39]="daunsingkong1.jpg";
        arDaun[40]="daunsingkong2.jpg";
        arDaun[41]="daunsingkong3.jpg";
        arDaun[42]="daunsingkong4.jpg";
        arDaun[43]="daunsingkong5.jpg";
        arDaun[44]="daunsingkong6.jpg";
        arDaun[45]="daunsingkong7.jpg";
        arDaun[46]="daunsingkong8.jpg";
        arDaun[47]="daunsingkong9.jpg";
        arDaun[48]="daunsingkong10.jpg";


        arNama[0]="daunjambu";
        arNama[1]="daunjambu";
        arNama[2]="daunjambu";
        arNama[3]="daunjambu";
        arNama[4]="daunjambu";
        arNama[5]="daunjambu";
        arNama[6]="daunjambu";
        arNama[7]="daunjambu";
        arNama[8]="daunjambu";

        arNama[9]="daunjarak";
        arNama[10]="daunjarak";
        arNama[11]="daunjarak";
        arNama[12]="daunjarak";
        arNama[13]="daunjarak";
        arNama[14]="daunjarak";
        arNama[15]="daunjarak";
        arNama[16]="daunjarak";
        arNama[17]="daunjarak";
        arNama[18]="daunjarak";

        arNama[19]="daunjeruk";
        arNama[20]="daunjeruk";
        arNama[21]="daunjeruk";
        arNama[22]="daunjeruk";
        arNama[23]="daunjeruk";
        arNama[24]="daunjeruk";
        arNama[25]="daunjeruk";
        arNama[26]="daunjeruk";
        arNama[27]="daunjeruk";
        arNama[28]="daunjeruk";

        arNama[29]="daunpepaya";
        arNama[30]="daunpepaya";
        arNama[31]="daunpepaya";
        arNama[32]="daunpepaya";
        arNama[33]="daunpepaya";
        arNama[34]="daunpepaya";
        arNama[35]="daunpepaya";
        arNama[36]="daunpepaya";
        arNama[37]="daunpepaya";
        arNama[38]="daunpepaya";

        arNama[39]="daunsingkong";
        arNama[40]="daunsingkong";
        arNama[41]="daunsingkong";
        arNama[42]="daunsingkong";
        arNama[43]="daunsingkong";
        arNama[44]="daunsingkong";
        arNama[45]="daunsingkong";
        arNama[46]="daunsingkong";
        arNama[47]="daunsingkong";
        arNama[48]="daunsingkong";


        AssetManager assetManager = getAssets();

        for(int k=0;k<jd;k++) {
            citra1[k] = new Mat();
            Log.d("BACA",k+"="+arDaun[k]);

            InputStream istr1 = assetManager.open(arDaun[k]);//a.jpeg
            Bitmap bitmap1 = BitmapFactory.decodeStream(istr1);
            Utils.bitmapToMat(bitmap1, citra1[k] );
            Imgproc.cvtColor(citra1[k] , citra1[k] , Imgproc.COLOR_RGB2GRAY);


            citra1[k] .convertTo(citra1[k] , 0);
            desc1[k] = new Mat();
            key1[k] = new MatOfKeyPoint();
            detector.detect(citra1[k] , key1[k]);
            descriptor.compute(citra1[k] , key1[k], desc1[k]);
        }
        //============================================1
    }
    public Deteksi() {
        Log.i(TAG, "Instantiated new " + this.getClass());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.i(TAG, "called onCreate");
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.activity_deteksi);


        if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, REQUEST_PERMISSION);
        }
        mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.deteksi);
        mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
        mOpenCvCameraView.setCvCameraViewListener(this);
    }


    @Override
    public void onPause() {
        super.onPause();
        if (mOpenCvCameraView != null)
            mOpenCvCameraView.disableView();
    }
    @Override
    public void onResume() {
        super.onResume();
        if (!OpenCVLoader.initDebug()) {
            Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
            OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, Deteksi.this, mLoaderCallback);
        } else {
            Log.d(TAG, "OpenCV library found inside package. Using it!");
            mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
        }

        }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mOpenCvCameraView != null)
            mOpenCvCameraView.disableView();
    }
    @Override
    public void onCameraViewStarted(int width, int height) {
        w = width;
        h = height;
    }

    @Override
    public void onCameraViewStopped() {

    }

    public Mat recognize(Mat aInputFrame) {//aInputFrame=objek dari Kamera
        double nmin = 10000000;
        int indexKe=0;

        Imgproc.cvtColor(aInputFrame, aInputFrame, Imgproc.COLOR_RGB2GRAY);
        descriptors2 = new Mat();
        keypoints2 = new MatOfKeyPoint();
        detector.detect(aInputFrame, keypoints2);
        descriptor.compute(aInputFrame, keypoints2, descriptors2);


        MatOfDMatch matches = null;
        Double max_dist = 0.0;
        Double min_dist = 100.0;
        int JM = 0;

        matches = new MatOfDMatch();
        for(int k=0;k<jd;k++){
        if (citra1[k].type() == aInputFrame.type()) {
            try {
                matcher.match(desc1[k], descriptors2, matches);

                List<DMatch> matchesList1 = matches.toList();

                max_dist = 0.0;
                min_dist = 100.0;

                JM = matchesList1.size();
                for (int i = 0; i < JM; i++) {
                    Double dist = (double) matchesList1.get(i).distance;
                    if (dist < min_dist)
                        min_dist = dist;
                    if (dist > max_dist)
                        max_dist = dist;
                }
                Log.d("MAXMIN15", "@DAUN1=" + max_dist + "@" + min_dist + "@" + (1.2 * min_dist));
                if (min_dist < nmin) {
                    indexKe = k;
                    nmin = min_dist;
                }

            } catch (Exception ee) {
            }
        } else {
            return aInputFrame;
        }

    }//loop


        //=================================================================================3
        matches = new MatOfDMatch();
        if (citra1[indexKe].type() == aInputFrame.type()) {
            try {
                matcher.match(desc1[indexKe], descriptors2, matches);
            } catch (Exception ee) {
            }

        } else {
            return aInputFrame;
        }

        List<DMatch> matchesListOut = matches.toList();
        JM = matchesListOut.size();
        List<DMatch>  listBest=null;
        Mat imgBest=new Mat();
        MatOfKeyPoint keyBest=null;

            listBest=matchesListOut;
            imgBest=citra1[indexKe];
            keyBest=key1[indexKe];
        hasildaun=arNama[indexKe];

        //=================================================================================================LAST
        int mm=0;
        LinkedList<DMatch> good_matches = new LinkedList<DMatch>();
        for (int i = 0; i < JM; i++) {
            if (listBest.get(i).distance <= (1.2 * min_dist)) {//1.5 * min_dist
                good_matches.addLast(listBest.get(i));
                mm++;
            }
        }
        gab=gab+String.valueOf(mm)+"#";
        Log.d("GAB","#"+gab+"+++++++++++++++++++++++++++++++++++++++++++++");

        MatOfDMatch goodMatches = new MatOfDMatch();
        goodMatches.fromList(good_matches);
        Mat outputImg = new Mat();


        MatOfByte drawnMatches = new MatOfByte();
        if (aInputFrame.empty() || aInputFrame.cols() < 1 || aInputFrame.rows() < 1) {
            return aInputFrame;
        }
        Features2d.drawMatches(imgBest, keyBest, aInputFrame, keypoints2, goodMatches, outputImg, GREEN, RED, drawnMatches, Features2d.NOT_DRAW_SINGLE_POINTS);
        Imgproc.resize(outputImg, outputImg, aInputFrame.size());


        return outputImg;
    }


        @Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
        return recognize(inputFrame.rgba());
    }
}







<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:opencv="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:screenOrientation="landscape"
    tools:context="com.example.fau.deteksidaun.Deteksi">

    <org.opencv.android.JavaCameraView
        android:id="@+id/deteksi"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        opencv:camera_id="any"
        opencv:show_fps="true"

        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center|bottom"
        android:layout_margin="16dp"
        android:gravity="center"
        android:orientation="horizontal"
        android:weightSum="2"
        android:layout_marginTop="260dp">

        <Button
            android:id="@+id/btnCek"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="COMPARE"
            android:layout_gravity="center|bottom"
            />
    </LinearLayout>

</RelativeLayout>





<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fau.deteksidaun">

    <uses-permission android:name="android.permission.CAMERA" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.front"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.front.autofocus"
        android:required="false" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/daun"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".HalamanUtama">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".CaraPenggunaan" />
        <activity android:name=".Tentang" />
        <activity android:name=".Deteksi"  android:screenOrientation="landscape" />
        <activity android:name=".HasilKlasifikasi"></activity>
    </application>

</manifest>