com.google.zxing.client.android.camera.CameraManager Java Examples

The following examples show how to use com.google.zxing.client.android.camera.CameraManager. 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: QRCodeReaderView.java    From ShareBox with Apache License 2.0 6 votes vote down vote up
public QRCodeReaderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (isInEditMode()) {
        return;
    }

    if (checkCameraHardware()) {
        mCameraManager = new CameraManager(getContext());
        mCameraManager.setPreviewCallback(this);
        getHolder().addCallback(this);
        setBackCamera();
    } else {
        throw new RuntimeException("Error: Camera not found");
    }
}
 
Example #2
Source File: CaptureActivityHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #3
Source File: CaptureActivityHandler.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #4
Source File: QRCodeReaderView.java    From flutter_qr_reader with MIT License 6 votes vote down vote up
public QRCodeReaderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (isInEditMode()) {
        return;
    }

    if (checkCameraHardware()) {
        mCameraManager = new CameraManager(getContext());
        mCameraManager.setPreviewCallback(this);
        getHolder().addCallback(this);
        setBackCamera();
    } else {
        throw new RuntimeException("Error: Camera not found");
    }
}
 
Example #5
Source File: CaptureActivityHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #6
Source File: CaptureActivityHandler.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #7
Source File: CaptureActivityHandler.java    From reacteu-app with MIT License 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                        Collection<BarcodeFormat> decodeFormats,
                        String characterSet,
                        CameraManager cameraManager) {
fakeR = new FakeR(activity);
   this.activity = activity;
   decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
       new ViewfinderResultPointCallback(activity.getViewfinderView()));
   decodeThread.start();
   state = State.SUCCESS;

   // Start ourselves capturing previews and decoding.
   this.cameraManager = cameraManager;
   cameraManager.startPreview();
   restartPreviewAndDecode();
 }
 
Example #8
Source File: CaptureActivityHandler.java    From ZXing-Orient with Apache License 2.0 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #9
Source File: CaptureActivityHandler.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #10
Source File: CaptureActivityHandler.java    From BarcodeEye with Apache License 2.0 6 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
        Collection<BarcodeFormat> decodeFormats,
        Map<DecodeHintType, ?> baseHints, String characterSet,
        CameraManager cameraManager) {
    this.activity = activity;
    decodeThread = new DecodeThread(activity, decodeFormats, baseHints,
            characterSet, new ViewfinderResultPointCallback(
                    activity.getViewfinderView()));
    decodeThread.start();
    state = State.SUCCESS;

    // Start ourselves capturing previews and decoding.
    this.cameraManager = cameraManager;
    cameraManager.startPreview();
    restartPreviewAndDecode();
}
 
Example #11
Source File: CaptureActivityHandler.java    From android-apps with MIT License 5 votes vote down vote up
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #12
Source File: ZxingScanView.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
private void openDriver(SurfaceHolder surfaceHolder) {
    notifyListenerPrepareOpen();
    if (surfaceHolder == null)
        return;// 已经销毁
    if (isOpen())
        return;// 摄像头已经打开
    if (Compat.checkSelfPermission(getContext(), Manifest.permission.CAMERA)
            == PackageManager.PERMISSION_DENIED) {
        mErrorCode = ERROR_CODE_1;
        notifyListenerError();
        return;
    }
    mCameraManager = new CameraManager(getContext());
    if (mCameraId != OpenCameraInterface.NO_REQUESTED_CAMERA)
        mCameraManager.setManualCameraId(mCameraId);
    final int width = mScanWidth == ViewGroup.LayoutParams.MATCH_PARENT ? getWidth() :
            (mScanWidth > getWidth() ? getWidth() : mScanWidth);
    final int height = mScanHeight == ViewGroup.LayoutParams.MATCH_PARENT ? getHeight() :
            (mScanHeight > getHeight() ? getHeight() : mScanHeight);
    mCameraManager.setManualFramingRect(width, height);
    try {
        mCameraManager.openDriver(surfaceHolder);
        mCameraManager.startPreview();
        mScanHandler = new ScanHandler(resultListener, mBarcodeType, mBaseHints,
                mCharacterSet, mCameraManager,
                resultPointCallback);
    } catch (Exception e) {
        mErrorCode = ERROR_CODE_0;
        notifyListenerError();
        return;
    }
    mAmbientLightManager.resume();
    notifyListenerOpened();
}
 
Example #13
Source File: AmbientLightManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
public void start(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
    SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
      sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
  }
}
 
Example #14
Source File: ScanHandler.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
public ScanHandler(OnResultListener listener,
                   int barcodeType,
                   Map<DecodeHintType, ?> baseHints,
                   String characterSet,
                   CameraManager cameraManager, ResultPointCallback resultPointCallback) {
    this.listener = listener;
    // Start ourselves capturing previews and decoding.
    this.cameraManager = cameraManager;
    decodeThread = new DecodeThread(cameraManager,
            this, barcodeType, baseHints, characterSet, resultPointCallback);
    decodeThread.start();
    state = State.SUCCESS;
    restartPreviewAndDecode();
}
 
Example #15
Source File: BarCodeScannerHandler.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
BarCodeScannerHandler(BarCodeScannerFragment fragment,
                      Collection<BarcodeFormat> decodeFormats,
                      Map<DecodeHintType,?> baseHints,
                      String characterSet,
                      CameraManager cameraManager) {
    this.fragment = fragment;
    decodeThread = new DecodeThread(fragment, decodeFormats, baseHints, characterSet,
            new ViewfinderResultPointCallback(fragment.getViewfinderView()));
    decodeThread.start();
    state = State.SUCCESS;

    this.cameraManager = cameraManager;
    cameraManager.startPreview();
    restartPreviewAndDecode();
}
 
Example #16
Source File: AmbientLightManager.java    From BarcodeEye with Apache License 2.0 5 votes vote down vote up
public void start(CameraManager cameraManager) {
    this.cameraManager = cameraManager;
    SharedPreferences sharedPrefs = PreferenceManager
            .getDefaultSharedPreferences(context);

    SensorManager sensorManager = (SensorManager) context
            .getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
        sensorManager.registerListener(this, lightSensor,
                SensorManager.SENSOR_DELAY_NORMAL);
    }
}
 
Example #17
Source File: CaptureActivity.java    From BarcodeEye with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't
    // want to open the camera driver and measure the screen size if we're going to show the help on
    // first launch. That led to bugs where the scanning rectangle was the wrong size and partially
    // off screen.
    mCameraManager = new CameraManager(getApplication());
    mViewfinderView.setCameraManager(mCameraManager);

    mHandler = null;

    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (mHasSurface) {
        // The activity was paused but not stopped, so the surface still exists. Therefore
        // surfaceCreated() won't be called, so init the camera here.
        initCamera(surfaceHolder);
    } else {
        // Install the callback and wait for surfaceCreated() to init the camera.
        surfaceHolder.addCallback(this);
    }

    mBeepManager.updatePrefs();
    mAmbientLightManager.start(mCameraManager);

    mInactivityTimer.onResume();
}
 
Example #18
Source File: AmbientLightManager.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
void start(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
    SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
      sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
  }
}
 
Example #19
Source File: AmbientLightManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
void start(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
    SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
      sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
  }
}
 
Example #20
Source File: AmbientLightManager.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
void start(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
    SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
      sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
  }
}
 
Example #21
Source File: AmbientLightManager.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
void start(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
    SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
      sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
  }
}
 
Example #22
Source File: AmbientLightManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
void start(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
    SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
      sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
  }
}
 
Example #23
Source File: CaptureActivityHandler.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
CaptureActivityHandler(AppInvCaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
Example #24
Source File: AmbientLightManager.java    From weex with Apache License 2.0 5 votes vote down vote up
void start(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
    SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (lightSensor != null) {
      sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
  }
}
 
Example #25
Source File: CaptureActivity.java    From BarcodeEye with Apache License 2.0 4 votes vote down vote up
CameraManager getCameraManager() {
    return mCameraManager;
}
 
Example #26
Source File: AppInvCaptureActivity.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
CameraManager getCameraManager() {
  return cameraManager;
}
 
Example #27
Source File: ViewfinderView.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
public void setCameraManager(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
}
 
Example #28
Source File: CaptureActivity.java    From ZXing-Orient with Apache License 2.0 4 votes vote down vote up
CameraManager getCameraManager() {
    return cameraManager;
}
 
Example #29
Source File: BarCodeScannerFragment.java    From zxingfragmentlib with Apache License 2.0 4 votes vote down vote up
CameraManager getCameraManager() {
  return cameraManager;
}
 
Example #30
Source File: ViewfinderView.java    From zxingfragmentlib with Apache License 2.0 4 votes vote down vote up
public void setCameraManager(CameraManager cameraManager) {
  this.cameraManager = cameraManager;
}