Exemplo n.º 1
0
 /**
  * Sets the desired width and height of the camera frames in pixels. If the exact desired values
  * are not available options, the best matching available options are selected. Also, we try to
  * select a preview size which corresponds to the aspect ratio of an associated full picture
  * size, if applicable. Default: 1024x768.
  */
 public Builder setRequestedPreviewSize(int width, int height) {
   // Restrict the requested range to something within the realm of possibility.  The
   // choice of 1000000 is a bit arbitrary -- intended to be well beyond resolutions that
   // devices can support.  We bound this to avoid int overflow in the code later.
   final int MAX = 1000000;
   if ((width <= 0) || (width > MAX) || (height <= 0) || (height > MAX)) {
     throw new IllegalArgumentException(
         mCameraSource.mContext.getString(R.string.invalid_preview_size)
             + width
             + mCameraSource.mContext.getString(R.string.x)
             + height);
   }
   mCameraSource.mRequestedPreviewWidth = width;
   mCameraSource.mRequestedPreviewHeight = height;
   return this;
 }
Exemplo n.º 2
0
 /**
  * Sets the camera to use (either {@link #CAMERA_FACING_BACK} or {@link #CAMERA_FACING_FRONT}).
  * Default: back facing.
  */
 public Builder setFacing(int facing) {
   if ((facing != CAMERA_FACING_BACK) && (facing != CAMERA_FACING_FRONT)) {
     throw new IllegalArgumentException(
         mCameraSource.mContext.getString(R.string.invalid_camera) + facing);
   }
   mCameraSource.mFacing = facing;
   return this;
 }
Exemplo n.º 3
0
 /**
  * Sets the requested frame rate in frames per second. If the exact requested value is not not
  * available, the best matching available value is selected. Default: 30.
  */
 public Builder setRequestedFps(float fps) {
   if (fps <= 0) {
     throw new IllegalArgumentException(
         mCameraSource.mContext.getString(R.string.invalid_fps) + fps);
   }
   mCameraSource.mRequestedFps = fps;
   return this;
 }
Exemplo n.º 4
0
    /**
     * Creates a camera source builder with the supplied context and detector. Camera preview images
     * will be streamed to the associated detector upon starting the camera source.
     */
    public Builder(Context context, Detector<?> detector) {
      if (context == null) {
        throw new IllegalArgumentException(
            "No context supplied."); // can't put it in string when context is null
      }
      if (detector == null) {
        throw new IllegalArgumentException("No detector supplied.");
      }

      mDetector = detector;
      mCameraSource.mContext = context;
    }
Exemplo n.º 5
0
 /** Creates an instance of the camera source. */
 public CameraSource build() {
   mCameraSource.mFrameProcessor = mCameraSource.new FrameProcessingRunnable(mDetector);
   return mCameraSource;
 }
Exemplo n.º 6
0
 public Builder setFlashMode(@FlashMode String mode) {
   mCameraSource.mFlashMode = mode;
   return this;
 }
Exemplo n.º 7
0
 public Builder setFocusMode(@FocusMode String mode) {
   mCameraSource.mFocusMode = mode;
   return this;
 }