@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { paintBorder.setColor(Color.BLACK); paintBorder.setStyle(Paint.Style.STROKE); paintBorder.setStrokeWidth(3*cameraToDisplayDensity); paintInside.setColor(Color.RED); paintInside.setStyle(Paint.Style.STROKE); paintInside.setStrokeWidth(2*cameraToDisplayDensity); double fov[] = cameraNominalFov(); CameraPinholeRadial intrinsic = MiscUtil.checkThenInventIntrinsic(app,imageWidth,imageHeight,fov[0],fov[1]); LensDistortionNarrowFOV distort = LensDistortionOps.narrow(intrinsic); detector.configure(distort, intrinsic.width, intrinsic.height, true); numDetected = 0; }
@Override public void initialize(int imageWidth, int imageHeight, int sensorOrientation) { // sanity check requirements if( imageWidth == 0 || imageHeight == 0 ) throw new RuntimeException("BUG! Called with zero width and height"); if( lookupIntrinsics() == null ) { Toast.makeText(FiducialSquareActivity.this, "Calibrate camera for better results!", Toast.LENGTH_LONG).show(); } // the adjustment requires knowing what the camera's resolution is. The camera // must be initialized at this point paintTextVideo.setTextSize(30*cameraToDisplayDensity); paintTextBorder.setTextSize(30*cameraToDisplayDensity); paintTextBorder.setStrokeWidth(3*cameraToDisplayDensity); paintLine0.setStrokeWidth(4f*cameraToDisplayDensity); paintLine1.setStrokeWidth(4f*cameraToDisplayDensity); paintLine2.setStrokeWidth(4f*cameraToDisplayDensity); paintLine3.setStrokeWidth(4f*cameraToDisplayDensity); double fov[] = cameraNominalFov(); intrinsic = MiscUtil.checkThenInventIntrinsic(app,imageWidth,imageHeight,fov[0],fov[1]); detector.setLensDistortion(LensDistortionOps.narrow(intrinsic),imageWidth,imageHeight); }
/** * Convert a set of associated point features from pixel coordinates into normalized image coordinates. */ public List<AssociatedPair> convertToNormalizedCoordinates() { Point2Transform2_F64 tran = LensDistortionOps.narrow(intrinsic).undistort_F64(true,false); List<AssociatedPair> calibratedFeatures = new ArrayList<>(); FastQueue<AssociatedIndex> matches = associate.getMatches(); for( AssociatedIndex a : matches.toList() ) { Point2D_F64 p1 = locationSrc.get( a.src ); Point2D_F64 p2 = locationDst.get( a.dst ); AssociatedPair c = new AssociatedPair(); tran.compute(p1.x, p1.y, c.p1); tran.compute(p2.x, p2.y, c.p2); calibratedFeatures.add(c); } return calibratedFeatures; }