public void setHorizontalFieldOfView( double radians ) { camera.setFieldOfView(UtilAngle.degree(radians)); }
@Override public void onDraw(Canvas canvas, Matrix imageToView) { drawBitmap(canvas,imageToView); canvas.concat(imageToView); synchronized (lockGui) { for (EllipseRotated_F64 ellipse : ellipses.toList()) { float phi = (float) UtilAngle.degree(ellipse.phi); float cx = (float) ellipse.center.x; float cy = (float) ellipse.center.y; float w = (float) ellipse.a; float h = (float) ellipse.b; // really skinny ones are probably just a line and not what the user wants if (w <= 2 || h <= 2) return; canvas.save(); canvas.rotate(phi, cx, cy); r.set(cx - w, cy - h, cx + w + 1, cy + h + 1); canvas.drawOval(r, paint); canvas.restore(); } } }
/** * Approximates a pinhole camera using the distoriton model * @param p2n Distorted pixel to undistorted normalized image coordinates * @return */ public static CameraPinhole approximatePinhole( Point2Transform2_F64 p2n , int width , int height ) { Point2D_F64 na = new Point2D_F64(); Point2D_F64 nb = new Point2D_F64(); // determine horizontal FOV using dot product of (na.x, na.y, 1 ) and (nb.x, nb.y, 1) p2n.compute(0,height/2,na); p2n.compute(width-1,height/2,nb); double abdot = na.x*nb.x + na.y*nb.y + 1; double normA = Math.sqrt(na.x*na.x + na.y*na.y + 1); double normB = Math.sqrt(nb.x*nb.x + nb.y*nb.y + 1); double hfov = Math.acos( abdot/(normA*normB)); // vertical FOV p2n.compute(width/2,0,na); p2n.compute(width/2,height-1,nb); abdot = na.x*nb.x + na.y*nb.y + 1; normA = Math.sqrt(na.x*na.x + na.y*na.y + 1); normB = Math.sqrt(nb.x*nb.x + nb.y*nb.y + 1); double vfov = Math.acos( abdot/(normA*normB)); return createIntrinsic(width,height, UtilAngle.degree(hfov), UtilAngle.degree(vfov)); }
panelCylinder = new CylinderPanel(imgWidth,imgHeight,UtilAngle.degree(vfov),this); controlPanel.add( panelCylinder ); controlPanel.add( panelRotate );
public void setCameraToWorld( Se3_F64 cameraToWorld ) { camera.setTranslateX(cameraToWorld.T.x); camera.setTranslateY(cameraToWorld.T.y); camera.setTranslateZ(cameraToWorld.T.z); Rodrigues_F64 rod = new Rodrigues_F64(); ConvertRotation3D_F64.matrixToRodrigues(cameraToWorld.R,rod); Point3D V = new Point3D(rod.unitAxisRotation.x,rod.unitAxisRotation.y,rod.unitAxisRotation.z); camera.setRotationAxis(V); camera.setRotate(UtilAngle.degree(rod.theta)); }
imageRgb.reshape(w,h); CameraPinhole intrinsic = PerspectiveOps.createIntrinsic(w,h,UtilAngle.degree(hfov));