mhnds

Untitled

Nov 1st, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. if (requestCode == SELECT_GALLERY_CODE
  2. && resultCode == Activity.RESULT_OK) {
  3. Uri selectedImageUri = data.getData();
  4.  
  5. imgView = (ImageView) findViewById(R.id.imageView);
  6. Bitmap imageBitmap = getOriginalBitMap(selectedImageUri);
  7.  
  8.  
  9. Frame frame = new Frame.Builder().setBitmap(imageBitmap).build();
  10. Detector<com.google.android.gms.vision.face.Face> detector = new com.google.android.gms.vision.face.FaceDetector.Builder(getApplicationContext())
  11. .setTrackingEnabled(false)
  12. .setLandmarkType(com.google.android.gms.vision.face.FaceDetector.ALL_LANDMARKS)
  13. .setClassificationType(com.google.android.gms.vision.face.FaceDetector.ALL_CLASSIFICATIONS)
  14. .build();
  15. SparseArray<com.google.android.gms.vision.face.Face> faces = detector.detect(frame);
  16. txtNumPeople.setText("" + faces.size());
  17.  
  18. for (int i = 0; i < faces.size(); i++) {
  19. com.google.android.gms.vision.face.Face eachFace = faces.valueAt(i);
  20. drawBox(imageBitmap, eachFace.getPosition(), eachFace.getHeight(), eachFace.getWidth());
  21. }
  22.  
  23. Frame barcodeFrame = new Frame.Builder().setBitmap(imageBitmap).build();
  24. BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(getApplicationContext())
  25. .setBarcodeFormats(Barcode.ALL_FORMATS).build();
  26. SparseArray<Barcode> barcodes = barcodeDetector.detect(barcodeFrame);
  27. if (barcodes.size() > 0) {
  28. txtBarcode.setText("Yes");
  29. } else {
  30. txtBarcode.setText("No");
  31. }
  32.  
  33. imgView.setImageBitmap(mFaceBitmap);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment