GeneratePnPObservation { boolean renderMarker(List<Point3D_F64> marker, Se3_F64 BodyToCamera, List<Point2D_F64> pixels) { Point3D_F64 p3 = new Point3D_F64(); for (int indexCorner = 0; indexCorner < marker.size(); indexCorner++) { BodyToCamera.transform(marker.get(indexCorner), p3); if( p3.z <= 0 ) return false; Point2D_F64 pixel = pixels.get(indexCorner); normToPixel.compute(p3.x / p3.z, p3.y / p3.z, pixel); pixel.x += random.nextGaussian() * stdevPixel; pixel.y += random.nextGaussian() * stdevPixel; if (pixel.x < 0 || pixel.x >= imageWidth - 1) return false; if (pixel.y < 0 || pixel.y >= imageHeight - 1) return false; } return true; } GeneratePnPObservation(double hfov, int width, int height); void initialize( double stdevPixel, String path ); void targetSquare(double length); void generateUniformImageDiscreteDistances(DiscreteRange range, double maxTilt, int trialsPerSet); void generateUniformImageDiscreteAngles(DiscreteRange angles, double distance, int trialsPerSet); void saveSimulation(List<Point3D_F64> corners,
                               List<Se3_F64> BodyToCameras, List<List<Point2D_F64>> observations,
                               long randomSeed,
                               PrintStream out); double getHfov(); int getImageWidth(); int getImageHeight(); double getStdevPixel(); static void main(String[] args);  }
@Test public void renderMarker_return() { GeneratePnPObservation generator = new GeneratePnPObservation(60,640,480); generator.random = new Random(1234); generator.stdevPixel = 0; List<Point3D_F64> marker = new ArrayList<>(); Se3_F64 BodyToCamera = SpecialEuclideanOps_F64.eulerXyz(0,0,5,0,0,0,null); marker.add( new Point3D_F64(0,1,0)); marker.add( new Point3D_F64(1,1,0)); marker.add( new Point3D_F64(1,0,0)); List<Point2D_F64> pixels = new ArrayList<>(); for (int i = 0; i < marker.size(); i++) { pixels.add( new Point2D_F64() ); } assertTrue(generator.renderMarker(marker,BodyToCamera,pixels)); SpecialEuclideanOps_F64.eulerXyz(0,0,-5,Math.PI/2.0,0,0,BodyToCamera); assertFalse(generator.renderMarker(marker,BodyToCamera,pixels)); SpecialEuclideanOps_F64.eulerXyz(0,1000,0,0.1,Math.PI/2.0,0,BodyToCamera); assertFalse(generator.renderMarker(marker,BodyToCamera,pixels)); SpecialEuclideanOps_F64.eulerXyz(0,0,1000,0.1,Math.PI/2.0,0,BodyToCamera); assertFalse(generator.renderMarker(marker,BodyToCamera,pixels)); }