Native Method not found:=java.lang.UnsatisfiedLinkError: Native method not found: com.example.finalcamera.NextActivity.convertNativeGray:(JJII)I

asked 2015-01-01 03:48:22 -0600

Mirza gravatar image

public class NextActivity extends Activity implements OnItemSelectedListener{ Bitmap bitmap; ImageView imageView; String TAG="FinalCamera"; int selectedFilter,selectedKMap; SeekBar seekBar; Mat imgMat,tmp;

//native function
public native int convertNativeGray(long matAddrRgba, long matAddrGray,int selectedFilter1,int ksize);





//loading and connecting to opencv library
    /* private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
            @Override
            public void onManagerConnected(int status) {
                switch (status) {
                    case LoaderCallbackInterface.SUCCESS:
                    {
                        System.loadLibrary("mixed_sample");
                        Log.i(TAG, "OpenCV loaded successfully");
                        realProcessing();

                    } break;
                    default:
                    {
                        super.onManagerConnected(status);
                    } break;
                }
            }
        };
*/

    @Override    
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_next);
     imageView=(ImageView)findViewById(R.id.imageView1);
     bitmap  = getIntent().getExtras().getParcelable("name");
    imageView.setImageBitmap(bitmap);
    //for spinner
     Spinner spinner = (Spinner) findViewById(R.id.filter_spinner);
      // Create an ArrayAdapter using the string array and a default spinner layout
      ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
              R.array.Filters, android.R.layout.simple_spinner_item);
      // Specify the layout to use when the list of choices appears
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      // Apply the adapter to the spinner
      spinner.setAdapter(adapter);

      spinner.setOnItemSelectedListener(this);
      //for kmap
      seekBar = (SeekBar) findViewById(R.id.seekBar1);

      seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {


           public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {

                        selectedKMap = progresValue;
                        System.out.println("The selected KMap is"+selectedKMap);
                        }
          public void onStartTrackingTouch(SeekBar seekBar) {}
          public void onStopTrackingTouch(SeekBar seekBar) {}
         });




}

public void onResume() { super.onResume(); realProcessing(); }

     public void realProcessing()
{
    System.out.println("This is real processing");
    bitmap  = getIntent().getExtras().getParcelable("name");
     bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);

        tmp = new Mat (bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC1);
        imgMat = new Mat (bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC1);
       Utils.bitmapToMat(bitmap, tmp);
       System.out.println(tmp.getNativeObjAddr()+""+imgMat.getNativeObjAddr()+""+selectedFilter+""+selectedKMap);
       convertNativeGray(tmp.getNativeObjAddr(), imgMat.getNativeObjAddr(),2,5);


       Utils.matToBitmap(imgMat, bitmap);
     imageView.setImageBitmap(bitmap);
}




@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.next, menu);
    return true;
}
@Override
//when seekbar an item is selected then this method will be called
public void onItemSelected(AdapterView<?> parent, View view, 
        int pos, long id) {
    // TODO Auto-generated method stub
    selectedFilter=pos+1;
      System.out.println("This is selected filter="+selectedFilter);
}
@Override
//when nothing changed this method will be called
public void onNothingSelected(AdapterView<?> arg0) {
    // TODO Auto-generated method stub

}

} I am initializing the opencv library in main activity whose code is public class MainActivity extends Activity { final int CAMERA_PIC_REQUEST=1; String TAG="FinalCamera";

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                System.loadLibrary("mixed_sample");
                Log.i(TAG, "OpenCV loaded successfully");
               // realProcessing();

            } break;
            default:
            {
                super.onManagerConnected(status);
            } break;
        }
    }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button take_photo = (Button) findViewById(R.id.button1);
    take_photo.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(i,CAMERA_PIC_REQUEST);
            }
        });
}

public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mLoaderCallback);

}


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    Bitmap thumbnail = null;
    if (requestCode == CAMERA_PIC_REQUEST) {

        if (resultCode == RESULT_OK) {

            thumbnail ...
(more)
edit retag flag offensive close merge delete