public Mat onCameraFrame(CvCameraViewFrame inputFrame) { // input frame has RGBA format mRgba = inputFrame.rgba(); mGray = inputFrame.gray(); // Size originalSize = mRgba.size(); // Transform.flip(mRgba, Transform.FlipType.FLIP_BOTH); // Transform.flip(mGray, Transform.FlipType.FLIP_BOTH); // Transform.shrink(mRgba, new Size(480, 480), true); // Transform.shrink(mGray, new Size(480, 480), true); fpsCounter.update(); try { // Process the frame for the color blobs detectorRed.process(mRgba); detectorBlue.process(mRgba); // Get the list of contours List<Contour> contoursRed = detectorRed.getContours(); List<Contour> contoursBlue = detectorBlue.getContours(); // Get color analysis Beacon beacon = new Beacon(); Beacon.BeaconAnalysis colorAnalysis = beacon.analyzeColor(contoursRed, contoursBlue, mRgba, mGray); // Drawing.drawText(mRgba, beaconCenterX + ", " + beaconCenterY, // new Point(0, 8), 1.0f, new ColorGRAY(255), Drawing.Anchor.BOTTOMLEFT); // Transform.enlarge(mRgba, originalSize, true); // Transform.enlarge(mGray, originalSize, true); Drawing.drawText( mRgba, Double.toString(beacon.getBeaconCenter().x) + ", " + Double.toString(beacon.getBeaconCenter().y), new Point(0, 8), 1.0f, new ColorGRAY(255), Drawing.Anchor.BOTTOMLEFT); } catch (Exception e) { Drawing.drawText( mRgba, "Analysis Error", new Point(0, 8), 1.0f, new ColorRGBA("#F44336"), Drawing.Anchor.BOTTOMLEFT); e.printStackTrace(); } Drawing.drawText( mRgba, "FPS: " + fpsCounter.getFPSString(), new Point(0, 24), 1.0f, new ColorRGBA("#ffffff")); // "#2196F3" return mRgba; }