com.google.android.gms.vision.CameraSource Java Examples
The following examples show how to use
com.google.android.gms.vision.CameraSource.
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: PandroidScannerView.java From pandroid with Apache License 2.0 | 6 votes |
@RequiresPermission(Manifest.permission.CAMERA) public void start(CameraSource cameraSource) throws IOException, SecurityException { if (cameraSource == null) { stop(); } mCameraSource = cameraSource; if (mCameraSource != null) { mStartRequested = true; startIfReady(); requestLayout(); invalidate(); } }
Example #2
Source File: FaceAnalyser.java From UserAwareVideoView with Apache License 2.0 | 6 votes |
/** * Create face decoder and camera source. */ private void creteCameraTracker() { mDetector = new FaceDetector.Builder(mActivity) .setTrackingEnabled(false) .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) .build(); mDetector.setProcessor( new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()) .build()); if (!mDetector.isOperational()) { mUserAwareVideoView.onErrorOccurred(); Log.e("Start Tracking", "Face tracker is not operational."); } mCameraSource = new CameraSource.Builder(mActivity, mDetector) .setRequestedPreviewSize(640, 480) .setFacing(CameraSource.CAMERA_FACING_FRONT) .setRequestedFps(30.0f) .build(); }
Example #3
Source File: QREader.java From qreader with Apache License 2.0 | 6 votes |
private void startCameraView(Context context, CameraSource cameraSource, SurfaceView surfaceView) { if (cameraRunning) { throw new IllegalStateException("Camera already started!"); } try { if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { Log.e(LOGTAG, "Permission not granted!"); } else if (!cameraRunning && cameraSource != null && surfaceView != null) { cameraSource.start(surfaceView.getHolder()); cameraRunning = true; } } catch (IOException ie) { Log.e(LOGTAG, ie.getMessage()); ie.printStackTrace(); } }
Example #4
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 #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.mFacing == CameraSource.CAMERA_FACING_FRONT) { return mOverlay.getWidth() - scaleX(x); } else { return scaleX(x); } }
Example #6
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 #7
Source File: QrDialogFragment.java From octoandroid with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBarcodeDetector = new BarcodeDetector.Builder(getActivity()) .setBarcodeFormats(Barcode.QR_CODE) .build(); mCameraSource = new CameraSource.Builder(getActivity(), mBarcodeDetector).build(); }
Example #8
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 #9
Source File: CameraSourcePreview.java From UserAwareVideoView with Apache License 2.0 | 5 votes |
public void start(CameraSource cameraSource) throws IOException { if (cameraSource == null) { stop(); } mCameraSource = cameraSource; if (mCameraSource != null) { mStartRequested = true; startIfReady(); } }
Example #10
Source File: FaceAnalyser.java From Prevent-Screen-Off with Apache License 2.0 | 5 votes |
/** * Create the {@link FaceDetector} and initialize the {@link CameraSourcePreview}. To start eye tracking you * should call {@link #startEyeTracker()} directly. This will call this method internally. */ private void creteCameraTracker() { //check for the camera permission if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { mScreenListener.onErrorOccurred(Errors.CAMERA_PERMISSION_NOT_AVAILABLE); return; } //check if the front camera is available? if (!isFrontCameraAvailable()) { mScreenListener.onErrorOccurred(Errors.FRONT_CAMERA_NOT_AVAILABLE); return; } mDetector = new FaceDetector.Builder(mActivity) .setTrackingEnabled(false) .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) .build(); mDetector.setProcessor(new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()) .build()); //The decoder is not operational if (!mDetector.isOperational()) { mScreenListener.onErrorOccurred(Errors.UNDEFINED); return; } mCameraSource = new CameraSource.Builder(mActivity, mDetector) .setRequestedPreviewSize(640, 480) .setFacing(CameraSource.CAMERA_FACING_FRONT) .setRequestedFps(30.0f) .build(); }
Example #11
Source File: CameraSourcePreview.java From Prevent-Screen-Off with Apache License 2.0 | 5 votes |
public void start(CameraSource cameraSource) throws IOException { if (cameraSource == null) { stop(); } mCameraSource = cameraSource; if (mCameraSource != null) { mStartRequested = true; startIfReady(); } }
Example #12
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 #13
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 #14
Source File: CameraSourcePreview.java From android-vision with Apache License 2.0 | 5 votes |
public void start(CameraSource cameraSource) throws IOException { if (cameraSource == null) { stop(); } mCameraSource = cameraSource; if (mCameraSource != null) { mStartRequested = true; startIfReady(); } }
Example #15
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 #16
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 #17
Source File: CameraSourcePreview.java From android-vision with Apache License 2.0 | 5 votes |
public void start(CameraSource cameraSource) throws IOException { if (cameraSource == null) { stop(); } mCameraSource = cameraSource; if (mCameraSource != null) { mStartRequested = true; startIfReady(); } }
Example #18
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 #19
Source File: FaceTrackerActivity.java From android-vision with Apache License 2.0 | 5 votes |
/** * Creates and starts the camera. Note that this uses a higher resolution in comparison * to other detection examples to enable the barcode detector to detect small barcodes * at long distances. */ private void createCameraSource() { Context context = getApplicationContext(); FaceDetector detector = new FaceDetector.Builder(context) .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) .build(); detector.setProcessor( new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()) .build()); if (!detector.isOperational()) { // Note: The first time that an app using face API is installed on a device, GMS will // download a native library to the device in order to do detection. Usually this // completes before the app is run for the first time. But if that download has not yet // completed, then the above call will not detect any faces. // // isOperational() can be used to check if the required native library is currently // available. The detector will automatically become operational once the library // download completes on device. Log.w(TAG, "Face detector dependencies are not yet available."); } mCameraSource = new CameraSource.Builder(context, detector) .setRequestedPreviewSize(640, 480) .setFacing(CameraSource.CAMERA_FACING_BACK) .setRequestedFps(30.0f) .build(); }
Example #20
Source File: CameraSourcePreview.java From android-vision with Apache License 2.0 | 5 votes |
public void start(CameraSource cameraSource) throws IOException { if (cameraSource == null) { stop(); } mCameraSource = cameraSource; if (mCameraSource != null) { mStartRequested = true; startIfReady(); } }
Example #21
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 #22
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 #23
Source File: GraphicOverlay.java From particle-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 #24
Source File: CameraSourcePreview.java From google-authenticator-android with Apache License 2.0 | 5 votes |
/** * Starts the display of the camera preview. If the camera source passed to this method is null, * then the previous camera source is stopped and its resources get released. * * @param cameraSource the camera source from where the preview frames come from. * @param graphicOverlay CameraSourcePreview will set the preview info to the GraphicOverlay * instance when available. * @throws SecurityException if there is no permission to use the camera when this method was * called. */ public void start(CameraSource cameraSource, GraphicOverlay graphicOverlay) throws SecurityException { this.graphicOverlay = graphicOverlay; if (cameraSource != null) { this.cameraSource = cameraSource; startRequested = true; startIfReady(); } else { release(); } }
Example #25
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 #26
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 #27
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 #28
Source File: CaptureActivity.java From cashuwallet with MIT License | 5 votes |
private Camera getCamera() { Field[] declaredFields = CameraSource.class.getDeclaredFields(); for (Field field : declaredFields) { if (field.getType() != Camera.class) continue; field.setAccessible(true); try { return (Camera) field.get(cameraSource); } catch (IllegalAccessException e) { return null; } } return null; }
Example #29
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 #30
Source File: CameraSourcePreview.java From Android-face-filters with Apache License 2.0 | 5 votes |
public void start(CameraSource cameraSource) throws IOException { if (cameraSource == null) { stop(); } mCameraSource = cameraSource; if (mCameraSource != null) { mStartRequested = true; startIfReady(); } }