Image call from android to opencv
I am using android ndk with opencv , I am giving two images as input and then one as output , my 2 input images are one is image and second is vignette , I am getting some kind of logical error from java side , below is my code of java
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageview_1=(ImageView) findViewById(R.id.imageView1);
imageview_2=(ImageView) findViewById(R.id.imageView2);
InputStream is , Vign;
is = this.getResources().openRawResource(R.drawable.me);
final Bitmap bmInImg = BitmapFactory.decodeStream(is);
Vign = this.getResources().openRawResource(R.drawable.p);
final Bitmap bmInImg2 = BitmapFactory.decodeStream(Vign);
mPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
nPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
vPhotoIntArray = new int[bmInImg2.getWidth() * bmInImg2.getHeight()];
imageview_1.setImageBitmap(bmInImg);
// Copy pixel data from the Bitmap into the 'intArray' array
bmInImg.getPixels(mPhotoIntArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
bmInImg2.getPixels(vPhotoIntArray, 0, bmInImg2.getWidth(), 0, 0, bmInImg2.getWidth(), bmInImg2.getHeight());
mCannyOutArray = new int[bmInImg2.getWidth() * bmInImg2.getHeight()];
final Bitmap bmOutImg = Bitmap.createBitmap(bmInImg2.getWidth(), bmInImg2.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg2.getWidth(), 0, 0, bmInImg2.getWidth(), bmInImg2.getHeight());
Button button= (Button) findViewById(R.id.NextButton);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (count ==0)
{
Vig(bmInImg.getHeight(),bmInImg.getWidth(),bmInImg2.getHeight(),bmInImg2.getWidth(), mPhotoIntArray,vPhotoIntArray, mCannyOutArray);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg2.getWidth(), 0, 0, bmInImg2.getWidth(), bmInImg2.getHeight());
imageview_2.setImageBitmap(bmOutImg);
}
count++;
}
});
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
String outFileName = extStorageDirectory + "/me.png";
OutputBitmapToFile(bmOutImg, outFileName);
}
Above code give me vignette fine but the first image output is showing lininng on all image and when i add both vignette look fine but image inside is full of lines , if i change the code of bmOutImg.setPixels
from outside and inside condition if
to
Vig(bmInImg.getHeight(),bmInImg.getWidth(),bmInImg2.getHeight(),bmInImg2.getWidth(), mPhotoIntArray,vPhotoIntArray, mCannyOutArray);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
imageview_2.setImageBitmap(bmOutImg);
Then it shows lining on vignette image. What should be my mCannyOutArray
should be so that my both images show satisfactory result for my output.