我有以下图片:http://www.salesreceiptstore.com/fake_receipt_templates/make-a-fake-restaurant-receipt-Large.JPG 基本上收据上有数据...
如何自动删除背景。我需要这个才能使OCR步骤更快。
答案 0 :(得分:0)
我认为您可以使用直接从Java CropImage库移植的Xamarin CropImage库。
参考:
您也可以尝试这样的事情
ImageView imgView;
int PicCrop = 1;
-
private void PerformCorp (Uri picUri)
{
try
{
Intent cropIntent = new Intent("com.android.camera.action.CROP");
// indicate image type and Uri
cropIntent.SetDataAndType(picUri, "image/*");
// set crop properties
cropIntent.PutExtra("crop", "true");
// indicate aspect of desired crop
cropIntent.PutExtra("aspectX", 1);
cropIntent.PutExtra("aspectY", 1);
// indicate output X and Y
cropIntent.PutExtra("outputX", 128);
cropIntent.PutExtra("outputY", 128);
// retrieve data on return
cropIntent.PutExtra("return-data", true);
// start the activity - we handle returning in onActivityResult
StartActivityForResult(cropIntent,PicCrop);
}
// respond to users whose devices do not support the crop action
catch (ActivityNotFoundException ex)
{
// display an error message
Toast.MakeText(this, "Whoops - your device doesn't support the crop action!",ToastLength.Short).Show();
}
}
-
protected override void OnActivityResult(int requestCode, int resultCode, Intent data)
//:base.OnActivityResult(requestCode,resultCode,data)
{
if (requestCode == PicCrop) {
if (data != null) {
// get the returned data
Bundle extras = data.Extras;
// get the cropped bitmap
Android.Graphics.Bitmap selectedBitmap = extras.GetParcelable("data");
imgView.SetImageBitmap(selectedBitmap);
}
}
}