Java Code Examples for com.google.android.gms.vision.CameraSource#CAMERA_FACING_FRONT
The following examples show how to use
com.google.android.gms.vision.CameraSource#CAMERA_FACING_FRONT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GooglyEyesActivity.java From android-vision with Apache License 2.0 | 6 votes |
/** * Creates the face detector and the camera. */ private void createCameraSource() { Context context = getApplicationContext(); FaceDetector detector = createFaceDetector(context); int facing = CameraSource.CAMERA_FACING_FRONT; if (!mIsFrontFacing) { facing = CameraSource.CAMERA_FACING_BACK; } // The camera source is initialized to use either the front or rear facing camera. We use a // relatively low resolution for the camera preview, since this is sufficient for this app // and the face detector will run faster at lower camera resolutions. // // However, note that there is a speed/accuracy trade-off with respect to choosing the // camera resolution. The face detector will run faster with lower camera resolutions, // but may miss smaller faces, landmarks, or may not correctly detect eyes open/closed in // comparison to using higher camera resolutions. If you have any of these issues, you may // want to increase the resolution. mCameraSource = new CameraSource.Builder(context, detector) .setFacing(facing) .setRequestedPreviewSize(320, 240) .setRequestedFps(60.0f) .setAutoFocusEnabled(true) .build(); }
Example 2
Source File: GraphicOverlay.java From Bluefruit_LE_Connect_Android with MIT License | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 3
Source File: GraphicOverlay.java From android-vision with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 4
Source File: GraphicOverlay.java From android-vision with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.facing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 5
Source File: GraphicOverlay.java From android-vision with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.facing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 6
Source File: GraphicOverlay.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 7
Source File: GraphicOverlay.java From fuse-qreader with MIT License | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 8
Source File: GraphicOverlay.java From quickstart-android with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate system. */ public float translateX(float x) { if (overlay.facing == CameraSource.CAMERA_FACING_FRONT) { return overlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 9
Source File: GraphicOverlay.java From Questor with MIT License | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 10
Source File: GraphicOverlay.java From VehicleInfoOCR with GNU General Public License v3.0 | 5 votes |
float translateX(float x) { if (overlay.facing == CameraSource.CAMERA_FACING_FRONT) { return overlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 11
Source File: GraphicOverlay.java From android-vision with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 12
Source File: GraphicOverlay.java From FaceFilter with MIT License | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 13
Source File: GraphicOverlay.java From samples-android with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 14
Source File: GraphicOverlay.java From android-vision with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 15
Source File: GraphicOverlay.java From fast_qr_reader_view with MIT License | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate system. */ public float translateX(float x) { if (overlay.facing == CameraSource.CAMERA_FACING_FRONT) { return overlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 16
Source File: GraphicOverlay.java From Android-face-filters with Apache License 2.0 | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 17
Source File: GraphicOverlay.java From flutter_mobile_vision with MIT License | 5 votes |
public float translateX(float x) { if (overlay.facing == CameraSource.CAMERA_FACING_FRONT) { return overlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 18
Source File: GraphicOverlay.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 5 votes |
/** * Adjusts the x coordinate from the preview's coordinate system to the view coordinate * system. */ public float translateX(float x) { if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example 19
Source File: BarcodeCaptureActivity.java From google-authenticator-android with Apache License 2.0 | 4 votes |
private void createCameraSource() { int screenWidth; int screenHeight; if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); screenHeight = size.y; screenWidth = size.x; } else { Display display = getWindowManager().getDefaultDisplay(); screenHeight = display.getHeight(); screenWidth = display.getWidth(); } if (screenWidth > screenHeight) { int tmp = screenWidth; screenWidth = screenHeight; screenHeight = tmp; } // There are devices that don't have a rear camera, like a version of the Nexus 7. Here we // check if the device has a rear camera, and if not, try to use the front camera instead. int cameraFacing = CameraSource.CAMERA_FACING_BACK; PackageManager packageManager = getPackageManager(); if (!packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA) && packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) { cameraFacing = CameraSource.CAMERA_FACING_FRONT; } // A barcode detector is created to track barcodes. An associated focussing processor instance // is set with a barcode tracker to receive the barcode detection results, track the barcodes, // filter out the barcodes that are not inside the square rectangle and return the callback // when a valid barcode is detected. final AuthenticatorApplication application = (AuthenticatorApplication) getApplicationContext(); BarcodeDetector barcodeDetector = application.getBarcodeDetector(); BarcodeTracker barcodeTracker = new BarcodeTracker(); barcodeTracker.setDetectionListener(mDetectionListener); // We disable central filter for front-facing camera as it is hard for users to place the // barcode completely inside the square with a front-facing camera. barcodeDetector.setProcessor( new BarcodeCentralFocusingProcessor(barcodeDetector, barcodeTracker, cameraFacing == CameraSource.CAMERA_FACING_BACK /* centralFilterEnabled */)); CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), barcodeDetector) .setFacing(cameraFacing) // TODO: Consider removing autofocus. For Pixel 2 phones, scanning the QR Code becomes // difficult. .setAutoFocusEnabled(true) .setRequestedPreviewSize(screenHeight, screenWidth) .setRequestedFps(PREFERRED_FRAMERATE); mCameraSource = builder.build(); }
Example 20
Source File: FaceGraphic.java From quickstart-android with Apache License 2.0 | 4 votes |
/** * Draws the face annotations for position on the supplied canvas. */ @Override public void draw(Canvas canvas) { FirebaseVisionFace face = firebaseVisionFace; if (face == null) { return; } // Draws a circle at the position of the detected face, with the face's track id below. // An offset is used on the Y axis in order to draw the circle, face id and happiness level in the top area // of the face's bounding box float x = translateX(face.getBoundingBox().centerX()); float y = translateY(face.getBoundingBox().centerY()); canvas.drawCircle(x, y - 4 * ID_Y_OFFSET, FACE_POSITION_RADIUS, facePositionPaint); canvas.drawText("id: " + face.getTrackingId(), x + ID_X_OFFSET, y - 3 * ID_Y_OFFSET, idPaint); canvas.drawText( "happiness: " + String.format("%.2f", face.getSmilingProbability()), x + ID_X_OFFSET * 3, y - 2 * ID_Y_OFFSET, idPaint); if (facing == CameraSource.CAMERA_FACING_FRONT) { canvas.drawText( "right eye: " + String.format("%.2f", face.getRightEyeOpenProbability()), x - ID_X_OFFSET, y, idPaint); canvas.drawText( "left eye: " + String.format("%.2f", face.getLeftEyeOpenProbability()), x + ID_X_OFFSET * 6, y, idPaint); } else { canvas.drawText( "left eye: " + String.format("%.2f", face.getLeftEyeOpenProbability()), x - ID_X_OFFSET, y, idPaint); canvas.drawText( "right eye: " + String.format("%.2f", face.getRightEyeOpenProbability()), x + ID_X_OFFSET * 6, y, idPaint); } // Draws a bounding box around the face. float xOffset = scaleX(face.getBoundingBox().width() / 2.0f); float yOffset = scaleY(face.getBoundingBox().height() / 2.0f); float left = x - xOffset; float top = y - yOffset; float right = x + xOffset; float bottom = y + yOffset; canvas.drawRect(left, top, right, bottom, boxPaint); // draw landmarks drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.MOUTH_BOTTOM); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.LEFT_CHEEK); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.LEFT_EAR); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.MOUTH_LEFT); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.LEFT_EYE); drawBitmapOverLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.NOSE_BASE); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.RIGHT_CHEEK); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.RIGHT_EAR); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.RIGHT_EYE); drawLandmarkPosition(canvas, face, FirebaseVisionFaceLandmark.MOUTH_RIGHT); }