An exercise in frustration

The code that I have used for portrait view:

        @Override
        public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

            Imgproc.cvtColor(inputFrame.rgba(), rgb, Imgproc.COLOR_RGBA2RGB);
             /*
             --- Your logic
                // Do your processing before rotating the image so that the corner/pose estimations are not affected
             */
             Mat localRGB;
             // Ref: https://stackoverflow.com/a/28601634
            Core.rotate(rgb, localRGB, Core.ROTATE_90_CLOCKWISE);
            //ref: https://stackoverflow.com/a/37972813
            Imgproc.resize(localRGB, rgb, rgb.size());
            return rgb;
        }