public override Mat Render(CameraBridgeViewBase.ICvCameraViewFrame inputFrame) { Mat renderedFrame = new Mat(inputFrame.Rgba().Size(), inputFrame.Rgba().Type()); Imgproc.Undistort(inputFrame.Rgba(), renderedFrame, mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients()); return(renderedFrame); }
public override Mat Render(CameraBridgeViewBase.ICvCameraViewFrame inputFrame) { Mat undistortedFrame = new Mat(inputFrame.Rgba().Size(), inputFrame.Rgba().Type()); Imgproc.Undistort(inputFrame.Rgba(), undistortedFrame, mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients()); Mat comparisonFrame = inputFrame.Rgba(); undistortedFrame.ColRange(new Range(0, mWidth / 2)).CopyTo(comparisonFrame.ColRange(new Range(mWidth / 2, mWidth))); List <MatOfPoint> border = new List <MatOfPoint>(); int shift = (int)(mWidth * 0.005); border.Add(new MatOfPoint(new Point(mWidth / 2 - shift, 0), new Point(mWidth / 2 + shift, 0), new Point(mWidth / 2 + shift, mHeight), new Point(mWidth / 2 - shift, mHeight))); Imgproc.FillPoly(comparisonFrame, border, new Scalar(255, 255, 255)); Imgproc.PutText(comparisonFrame, mResources.GetString(Resource.String.original), new Point(mWidth * 0.1, mHeight * 0.1), Core.FontHersheySimplex, 1.0, new Scalar(255, 255, 0)); Imgproc.PutText(comparisonFrame, mResources.GetString(Resource.String.undistorted), new Point(mWidth * 0.6, mHeight * 0.1), Core.FontHersheySimplex, 1.0, new Scalar(255, 255, 0)); return(comparisonFrame); }