├── markerexample.png ├── .gitignore ├── README.md └── armarkergenerator └── armarkergenerator.pde /markerexample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ASPePeX/AR-Marker-Generator/HEAD/markerexample.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /armarkergenerator/*/*.tif 2 | /armarkergenerator/*.tif 3 | /armarkergenerator/*/*.png 4 | /armarkergenerator/*.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AR-Marker-Generator 2 | 3 | A processing sketch that generats markers for Augmented Reality applications like Vuforia. 4 | 5 | ![Marker example](https://raw.githubusercontent.com/ASPePeX/AR-Marker-Generator/master/markerexample.png) 6 | -------------------------------------------------------------------------------- /armarkergenerator/armarkergenerator.pde: -------------------------------------------------------------------------------- 1 | float triangleSize = 1; 2 | int triangleLimit; 3 | int bgColorUpperLimit; 4 | int bgColorLowerLimit; 5 | int lineColorUpperLimit; 6 | int lineColorLowerLimit; 7 | int exitAfterNumberOfMarkers; 8 | int markerCounter; 9 | int borderSize; 10 | color backgroundClearColor; 11 | 12 | String randomBatchName; 13 | 14 | void setup() { 15 | //Configure these values 16 | //actuale pixel size of the maker 17 | size(2500, 2500); 18 | 19 | //width of the lines 20 | strokeWeight(15); 21 | 22 | //triangle max size in pixel 23 | triangleSize = 1200; 24 | 25 | //Color limits to control overall color brightness 26 | bgColorUpperLimit = 255; 27 | bgColorLowerLimit = 224; 28 | lineColorUpperLimit = 255; 29 | lineColorLowerLimit = 0; 30 | 31 | //Draw number of triangles per marker 32 | triangleLimit = 250; 33 | 34 | //Exits after number of markers generated 35 | exitAfterNumberOfMarkers = 20; 36 | 37 | //Border in pixels in addition to the canvas size, borders ar blank white 38 | borderSize = 0; 39 | 40 | //Background clear color 41 | backgroundClearColor = 255; 42 | 43 | //Only madness and despair past his line ... 44 | 45 | randomBatchName = str((int)random(10000000, 99999999)); 46 | println("Bulding " + exitAfterNumberOfMarkers + " markers, batch name " + randomBatchName + "."); 47 | background(backgroundClearColor); 48 | } 49 | 50 | void draw() { 51 | 52 | for (int i = 0; i < triangleLimit; i++) 53 | { 54 | //Randoming triangle corners, in their own relative coordinate system 55 | PVector a = new PVector(random(-triangleSize/2, triangleSize/2), random(-triangleSize/2, triangleSize/2)); 56 | PVector b = new PVector(random(-triangleSize/2, triangleSize/2), random(-triangleSize/2, triangleSize/2)); 57 | PVector c = new PVector(random(-triangleSize/2, triangleSize/2), random(-triangleSize/2, triangleSize/2)); 58 | 59 | //Randoming the center position on the canvas 60 | PVector p = new PVector(random(width), random(height)); 61 | 62 | //Randoming fill color 63 | fill(random(bgColorLowerLimit, bgColorUpperLimit), random(bgColorLowerLimit, bgColorUpperLimit), random(bgColorLowerLimit, bgColorUpperLimit)); 64 | stroke(random(lineColorLowerLimit, lineColorUpperLimit), random(lineColorLowerLimit, lineColorUpperLimit), random(lineColorLowerLimit, lineColorUpperLimit)); 65 | 66 | //Drawing the triangle 67 | triangle(a.x + p.x, a.y + p.y, 68 | b.x + p.x, b.y + p.y, 69 | c.x + p.x, c.y + p.y); 70 | } 71 | 72 | SaveAndClear(); 73 | } 74 | 75 | void SaveAndClear() { 76 | markerCounter++; 77 | String filename = "marker-"+ randomBatchName + "-" + nf(markerCounter, 3) + ".png"; 78 | 79 | int newwidth = width + 2*borderSize; 80 | int newheight = height + 2*borderSize; 81 | 82 | PImage oldimg = get(); 83 | clear(); 84 | background(backgroundClearColor); 85 | 86 | PImage newimg = get(); 87 | newimg.resize(newwidth, newheight); 88 | newimg.set(borderSize, borderSize, oldimg); 89 | newimg.save(savePath(filename)); 90 | 91 | if (exitAfterNumberOfMarkers <= markerCounter) 92 | { 93 | println("All done!"); 94 | exit(); 95 | } else 96 | { 97 | println("Done with marker " + markerCounter); 98 | clear(); 99 | background(backgroundClearColor); 100 | } 101 | } 102 | --------------------------------------------------------------------------------