private static boolean checkInBounds( ImageBase b , int c_x , int c_y , int dx , int dy , float c , float s ) { float x = c_x + c*dx - s*dy; float y = c_y + s*dx + c*dy; return b.isInBounds((int) x, (int) y); }
/** * Specifies the initial target location so that it can learn its description * @param image Image * @param initial Initial target location and the mean-shift bandwidth */ public void initialize( T image , RectangleLength2D_I32 initial ) { if( !image.isInBounds(initial.x0,initial.y0) ) throw new IllegalArgumentException("Initial rectangle is out of bounds!"); if( !image.isInBounds(initial.x0+initial.width,initial.y0+initial.height) ) throw new IllegalArgumentException("Initial rectangle is out of bounds!"); pdf.reshape(image.width,image.height); ImageMiscOps.fill(pdf,-1); location.set(initial); // massage the rectangle so that it has an odd width and height // otherwise it could experience a bias when localizing location.width += 1-location.width%2; location.height += 1-location.height%2; failed = false; // compute the initial sum of the likelihood so that it can detect when the target is no longer visible minimumSum = 0; targetModel.setImage(image); for( int y = 0; y < initial.height; y++ ) { for( int x = 0; x < initial.width; x++ ) { minimumSum += targetModel.compute(x+initial.x0,y+initial.y0); } } minimumSum *= minFractionDrop; }
@Override public void mouseClicked(MouseEvent e) { GeoLL_F32 geo = new GeoLL_F32(); double scale = panelEqui.scale; int x = (int)(e.getX()/scale); int y = (int)(e.getY()/scale); if( !equi.isInBounds(x,y)) return; panelPinhole.grabFocus(); synchronized (imageLock) { distorter.getTools().equiToLatLonFV(x,y,geo); distorter.setDirection(geo.lon,geo.lat,0); // pinhole has a canonical view along +z // equirectangular lon-lat uses +x // this compensates for that // roll rotation is to make the view appear "up" FMatrixRMaj A = ConvertRotation3D_F32.eulerToMatrix(EulerType.YZX, GrlConstants.F_PI/2,0,GrlConstants.F_PI/2,null); FMatrixRMaj tmp = distorter.getRotation().copy(); CommonOps_FDRM.mult(tmp,A,distorter.getRotation()); distortImage.setModel(distorter); // let it know the transform has changed if (inputMethod == InputMethod.IMAGE) { rerenderPinhole(); } } }
private void changeFocus(MouseEvent e) { double scale = panelFisheye.scale; double omniX = e.getX()/scale; double omniY = e.getY()/scale; if( !fisheye.isInBounds((int)omniX,(int)omniY)) return; panelPinhole.grabFocus(); synchronized (imageLock) { Point3D_F32 norm = new Point3D_F32(); fisheyeDistort.undistortPtoS_F32().compute((float)omniX, (float)omniY, norm); Rodrigues_F32 rotation = new Rodrigues_F32(); Vector3D_F32 canonical = new Vector3D_F32(0,0,1); rotation.theta = UtilVector3D_F32.acute(new Vector3D_F32(norm),canonical); GeometryMath_F32.cross(canonical,norm,rotation.unitAxisRotation); rotation.unitAxisRotation.normalize(); FMatrixRMaj R = ConvertRotation3D_F32.rodriguesToMatrix(rotation,null); distorter.setRotationWideToNarrow(R); distortImage.setModel(new PointToPixelTransform_F32(distorter)); if (inputMethod == InputMethod.IMAGE) { rerenderPinhole(); } } }