Hi Guys, Maybe you all are expert in terms of using RecyclerView in android. This blog is simple example for using filter option with RecyclerView adapter. As for now you will instantiate RecyclerView and set the adapter to RecyclerView as following way. RecyclerView list = (RecyclerView) findViewById(R.id.list); list.setLayoutManager(new LinearLayoutManager(this)); list.setHasFixedSize(true); ArrayList<Number> numbers = new ArrayList<>(); String ONEs[] = {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN"}; String TENs[] = {"ZERO", "TEN", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY", "HUNDRED"}; String HUNDREDS[] = {"ZERO", "HUNDRED", "TWO HUND
Hi Friends, Maybe you all heard/used text scanning using camera feature or extracting text from Image. But this sample made it very easy for you. You can made it in very simple line of code.
You can download the source code from OCRSample and import the library as a module into your project.
Example usage : MainActivity.java
Here is the video output of this source code
If you are really interested in this code, then please share this post with your friends, also share your feedback as comment here.
Thank You
You can download the source code from OCRSample and import the library as a module into your project.
Example usage : MainActivity.java
public class MainActivity extends AppCompatActivity {
private TextView textView;
private final int CAMERA_SCAN_TEXT = 0;
private final int LOAD_IMAGE_RESULTS = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.actionCamera:
//Scan text from camera.
OCRCapture.Builder(this)
.setUseFlash(true)
.setAutoFocus(true)
.buildWithRequestCode(CAMERA_SCAN_TEXT);
break;
case R.id.actionPhoto:
Intent intentGallery = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intentGallery, LOAD_IMAGE_RESULTS);
break;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data != null) {
if (requestCode == CAMERA_SCAN_TEXT) {
if (resultCode == CommonStatusCodes.SUCCESS) {
textView.setText(data.getStringExtra(TextBlockObject));
}
} else if (requestCode == LOAD_IMAGE_RESULTS) {
Uri pickedImage = data.getData();
try {
//Extract text from image.
String text = OCRCapture.Builder(this).getTextFromUri(pickedImage);
//You can also use getTextFromBitmap(Bitmap bitmap) or getTextFromImage(String imagePath) buplic APIs from ibrary.
textView.setText(text);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
Here is the video output of this source code
Interesting right?
If you are really interested in this code, then please share this post with your friends, also share your feedback as comment here.
Source code on GitHub
Thank You
Hi, It can detect chinese language
ReplyDelete