Here’s a rough sketch of what I want to do, but don’t really know how. The image is taken with a small device called a Bris Sextant. It makes multiple images of the sun. As the sun rises or sets, different sun images will touch the horizon. To use it requires calibration, and to calibrate requires a visible horizon like a large body of water. I don’t have that, so what I want to do is use a tablet camera and a sensor to draw a horizon line and measure the angle the sun is from the horizon, then save the picture with the overlay included.
Here’s the code that shows how I want it to look in android. I have code that will read orientation from another device over USB. Save the posted image into the data directory if you try it.
PImage img; // Declare variable "a" of type PImage
PFont font8, font9, font12, font15;
int i, j; // enummerators
float horizonInstrSize=68;
int xLevelObj,yLevelObj;
float angy;
float angyLevelControl;
void setup() {
size(440, 460);
font8 = createFont("Arial bold",8,false);
font9 = createFont("Arial bold",9,false);
font12 = createFont("Arial bold",12,false);
font15 = createFont("Arial bold",15,false);
// The image file must be in the data folder of the current sketch
// to load successfully
// img = loadImage("suns.JPG"); // Load the image into the program
img = loadImage("suns2.jpg"); // Load the image into the program
}
void draw() {
background(0);
image(img, width/2 - (img.width/5)/2, height/2 - (img.height/5)/2, img.width/5, img.height/5);
stroke(0,255,0);
line(0,height/2,640,height/2);
// scale(-2);
// ---------------------------------------------------------------------------------------------
// Magnetron Combi Fly Level Control --- borrowed from Multiwii
// ---------------------------------------------------------------------------------------------
angyLevelControl=((angy<-horizonInstrSize) ? -horizonInstrSize : (angy>horizonInstrSize) ? horizonInstrSize : angy);
pushMatrix();
translate(width/2,height/2);
scale(2.5);
noStroke();
if (angy>0)
fill(124,73,31);
noStroke();
//////////////////////// triangle(0,0,x,-angyLevelControl,-x,-angyLevelControl);
// inner lines
strokeWeight(1);
for(i=0;i<8;i++) {
j=i*15;
if (angy<=(35-j) && angy>=(-65-j)) {
stroke(255,255,255); line(-30,-15-j-angy,30,-15-j-angy); // up line
fill(255,255,255);
textFont(font9);
text("+" + (i+1) + "0", 34, -12-j-angy); // up value
text("+" + (i+1) + "0", -48, -12-j-angy); // up value
}
if (angy<=(42-j) && angy>=(-58-j)) {
stroke(167,167,167); line(-20,-7-j-angy,20,-7-j-angy); // up semi-line
}
if (angy<=(65+j) && angy>=(-35+j)) {
stroke(255,255,255); line(-30,15+j-angy,30,15+j-angy); // down line
fill(255,255,255);
textFont(font9);
text("-" + (i+1) + "0", 34, 17+j-angy); // down value
text("-" + (i+1) + "0", -48, 17+j-angy); // down value
}
if (angy<=(58+j) && angy>=(-42+j)) {
stroke(127,127,127); line(-20,7+j-angy,20,7+j-angy); // down semi-line
}
}
strokeWeight(2);
stroke(255,255,255);
if (angy<=50 && angy>=-50) {
// line(-40,-angy,40,-angy); //center line
fill(255,255,255);
textFont(font9);
text("0", 34, 4-angy); // center
text("0", -39, 4-angy); // center
}
// lateral arrows
strokeWeight(1);
// down fixed triangle
fill(0);
noStroke();
translate(-width/2,-154);
rect(0,0,width,100);
translate(0,105);
rect(0,100,width,40);
popMatrix();
}