Java Code Examples for com.google.android.gms.vision.barcode.Barcode#getBoundingBox()
The following examples show how to use
com.google.android.gms.vision.barcode.Barcode#getBoundingBox() .
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: BarcodeGraphic.java From flutter_barcode_scanner with MIT License | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 2
Source File: BarcodeGraphic.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. //canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 3
Source File: BarcodeGraphic.java From flutter_mobile_vision with MIT License | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = this.barcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect = translateRect(rect); canvas.drawRect(rect, rectPaint); if (textPaint != null) { // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, textPaint); } }
Example 4
Source File: BarcodeGraphic.java From Barcode-Reader with Apache License 2.0 | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 5
Source File: BarcodeGraphic.java From samples-android with Apache License 2.0 | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 6
Source File: CodeGraphic.java From prebid-mobile-android with Apache License 2.0 | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 7
Source File: BarcodeGraphic.java From Barcode-Reader with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 8
Source File: BarcodeGraphic.java From fuse-qreader with MIT License | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); }
Example 9
Source File: BarcodeGraphic.java From android-vision with Apache License 2.0 | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 10
Source File: BarcodeTrackerFactory.java From android-vision with Apache License 2.0 | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 11
Source File: BarcodeCentralFilter.java From google-authenticator-android with Apache License 2.0 | 6 votes |
/** * Checking if the barcode is inside the scanner square or not. As the found barcode's dimensions * is in camera's coordinates, we must convert it to canvas' coordinates. */ public static boolean barcodeIsInsideScannerSquare(Barcode barcode) { // When the savedSquareFrame or mCameraSize is not initialized yet, which means the layout is // not drawn, return false. if (mSavedSquareFrame == null || mCameraSize == null) { return false; } Rect barcodeFrameCamera = barcode.getBoundingBox(); int left = barcodeFrameCamera.left; int top = barcodeFrameCamera.top; int right = barcodeFrameCamera.right; int bottom = barcodeFrameCamera.bottom; int cameraWidth = mCameraSize.getWidth(); int cameraHeight = mCameraSize.getHeight(); // Convert to canvas' coordinates Rect barcodeFrameCanvas = new Rect( left * mCanvasWidth / cameraWidth, top * mCanvasHeight / cameraHeight, right * mCanvasWidth / cameraWidth, bottom * mCanvasHeight / cameraHeight); return mSavedSquareFrame.contains(barcodeFrameCanvas); }
Example 12
Source File: BarcodeGraphic.java From Bluefruit_LE_Connect_Android with MIT License | 6 votes |
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */ @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. //canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); }
Example 13
Source File: BarcodeGraphic.java From flutter_mobile_vision with MIT License | 5 votes |
/** * @return RectF that represents the graphic's bounding box. */ public RectF getBoundingBox() { Barcode barcode = this.barcode; if (barcode == null) { return null; } RectF rect = new RectF(barcode.getBoundingBox()); rect = translateRect(rect); return rect; }
Example 14
Source File: BarcodeGraphic.java From MVBarcodeReader with Apache License 2.0 | 5 votes |
private RectF getViewBoundingBox(Barcode barcode) { // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); rect.top = translateY(rect.top); rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); return rect; }
Example 15
Source File: BarcodeDetectionImpl.java From 365browser with Apache License 2.0 | 4 votes |
@Override public void detect( SharedBufferHandle frameData, int width, int height, DetectResponse callback) { if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( ContextUtils.getApplicationContext()) != ConnectionResult.SUCCESS) { Log.e(TAG, "Google Play Services not available"); callback.call(new BarcodeDetectionResult[0]); return; } // The vision library will be downloaded the first time the API is used // on the device; this happens "fast", but it might have not completed, // bail in this case. Also, the API was disabled between and v.9.0 and // v.9.2, see https://developers.google.com/android/guides/releases. if (!mBarcodeDetector.isOperational()) { Log.e(TAG, "BarcodeDetector is not operational"); callback.call(new BarcodeDetectionResult[0]); return; } Frame frame = SharedBufferUtils.convertToFrame(frameData, width, height); if (frame == null) { Log.e(TAG, "Error converting SharedMemory to Frame"); callback.call(new BarcodeDetectionResult[0]); return; } final SparseArray<Barcode> barcodes = mBarcodeDetector.detect(frame); BarcodeDetectionResult[] barcodeArray = new BarcodeDetectionResult[barcodes.size()]; for (int i = 0; i < barcodes.size(); i++) { barcodeArray[i] = new BarcodeDetectionResult(); final Barcode barcode = barcodes.valueAt(i); barcodeArray[i].rawValue = barcode.rawValue; final Rect rect = barcode.getBoundingBox(); barcodeArray[i].boundingBox = new RectF(); barcodeArray[i].boundingBox.x = rect.left; barcodeArray[i].boundingBox.y = rect.top; barcodeArray[i].boundingBox.width = rect.width(); barcodeArray[i].boundingBox.height = rect.height(); final Point[] corners = barcode.cornerPoints; barcodeArray[i].cornerPoints = new PointF[corners.length]; for (int j = 0; j < corners.length; j++) { barcodeArray[i].cornerPoints[j] = new PointF(); barcodeArray[i].cornerPoints[j].x = corners[j].x; barcodeArray[i].cornerPoints[j].y = corners[j].y; } } callback.call(barcodeArray); }