Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
algwat
algwat's Profile
3
Posts
4
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Simple image viewer
[3 Replies]
16-Aug-2013 05:35 AM
Forum:
Share your Work
Here is an example of simple image viewer I have made from the info and examples on this forum.
Feel free to make it complicated. regards, Algwat.
// sweep image viewer
File[] list; // Files, not Strings
//
PImage[] imgs ; // fn matched images
int Nimg = 0;
int sframes = 0;
int eframes = 0;
int nframes = 0;
int lprate = 15 ;
//String fnmatch = "20130812_18" ; // files matched to this string
String fnmatch = "20121012_" ; // files matched to this string
String fpath = "C:\\Users\\alan\\Documents\\Processing\\StereoRotator1\\data\\HI1B" ;
//String fpath = "F:\\Documents\\DMKALLSKY1\\data\\20130812meteor" ; // filepath to images
void setup() {
size(968, 720);
frameRate(lprate);
//
File dir = new File(dataPath(fpath));
list = dir.listFiles();
//
mloop() ; // match file names
//
ldloop(); // load matched files
//
}
void draw() {
background(0);
floop(); // show image loop
text("[ "+frameCount+" / "+nframes+" ][ FPS "+lprate+" ]", 500, 10 );
frameRate(lprate);
// g.removeCache(imgs); // do not remove this line
}
void floop() {
image(imgs[abs(frameCount)], 0, 0, width, height);
if (frameCount >= nframes-1) {
frameCount = -(nframes) ;
}
if (frameCount == -1) {
frameCount = 1 ;
}
}
void mloop() {
for ( Nimg = 0; Nimg < list.length ; Nimg++) {
//
String fn = list[Nimg].getAbsolutePath();
String[] m2 = match(fn, fnmatch );
if (m2 != null) {
eframes = Nimg ;
nframes++ ;
// println(list.length+" "+sframes+" "+eframes+" "+nframes+ "Match found in '" + list[Nimg] + "'\n"+fn);
}
else {
// This will print to the console, since no match was found.
sframes = (eframes - nframes) ;
// println(sframes+" "+eframes+" "+nframes+ "No match found in '" + list[Nimg] + "'\n"+fn);
}
}
}
void ldloop() {
// load matched images
imgs = new PImage[nframes];
for (int x = 1; x < nframes; x++)
{
imgs[x] = loadImage(list[(sframes+x)].getAbsolutePath());
print( x + " images loaded\n ") ;
}
}
void keyPressed() {
//
if (key =='x') {
exit();
}
if (key =='c') {
background(0);
}
if (key =='-') {
lprate=lprate-1 ;
if (lprate <= 0) {
lprate=1 ;
}
}
if (key =='=') {
lprate=lprate+1 ;
if (lprate >= 30) {
lprate= 30 ;
}
}
//
}
Allsky tracking camera
[0 Replies]
01-May-2013 09:27 PM
Forum:
Share your Work
I used the examples to make this brightness tracking meteor camera, really like what processing can do.
A link to my code is at the blog....
Meteor camera - DIY
(
http://cometal-comets.blogspot.com.au/2013/04/meteor-camera-diy.html
)
Question, has anyone thought of combining processing with ImageJ ( used mainly for medical imaging) but good for pixelmath.?
Hope you like it, feel free to make it better,
kind regards, Alan
OpenGl inner solar system
[0 Replies]
16-Dec-2012 02:28 AM
Forum:
Share your Work
Gidday , First time here.
I just wanted to share this example of a solar system with planets and comets.
While it uses some real world data, its not accurate....may be later. Regards Alan.
// new orbit example
// nplanets and ncomets
import processing.opengl.*;
//
float timestep = 200.0 ;
float theta = 0.0;
int scl = 1;
// array of orbital info
String[] pname = {"SUN", "MER", "VEN", "STA", "EAR", "STB", "MAR", "P/2012 A3\nSOHO", "C/2012 S1\nISON", "C/2011 W3\nLovejoy"};
float[] pnum = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
float[] ecc = {0, 0.206, 0.007, 0.009562656, 0.017, 0.004440, 0.093, 0.776, 0.995, 0.995}; // eccenticity
float[] au = {0, 0.39, 0.72, 0.95539896, 1.0, 1.051887, 1.52, 2.568, 10.0, 78.68 }; // mean distance 1au
float[] rot = {0, 0.24, 0.62, 0.93326171, 1, 1.078152, 1.88, 4.12, 10.0, 10.0}; // period of rotation 1yr
float[] eqtr = {3.0, 0.382, 0.949, 0.1, 1, 0.1, 0.532, 0.1, 0.1, 0.1}; // 1 earth diam
float[] angl = {0.0, 29.124, 55.186, 259.41452171, 114.20783, 18.37796930629710, 286.537, 217.6673, 295.7576, 332.02321}; // perri
//
PFont fontA = createFont("SanSerif", 12);
PFont fontB = createFont("SanSerif", 16);
//
//
void setup() {
size(1024, 1024, OPENGL);
}
void draw()
{
background(0);
// Translate the origin point to the center of the screen
translate(width/2, height/2) ;
ellipseMode(RADIUS);
nplanets(); // draw planets
ncomets() ; // draw comets
theta +=(0.00004109*(1+timestep));
}
void keyReleased() {
//
if (key =='x') { exit(); }
if (key =='c') { background(0); }
if (key =='[') { scl-=1 ; if (scl <= 0) {scl = 1;}}
if (key ==']') { scl+=1 ; if (scl >= 100) { scl = 100;}}
if (key =='-') { timestep-=100 ; if (timestep <= -1000) {timestep = -1000;}}
if (key =='=') { timestep+=100 ; if (timestep >= 1000) { timestep = 1000;}}
}
void nplanets() {
// draw planets
for ( int np = 6 ; np > -1 ; np-=1 ) {
float e1 = ecc[np];
float a1 = (au[np]*300 );
float b1 = a1*sqrt(1-(e1*e1)) ;
float c1 = a1*e1 ;
float l1 = (b1*b1)/a1 ;
float r1 = l1/(1.0+(e1*cos(angl[np]+theta/rot[np])));
float x1 = r1*cos(angl[np]+theta/rot[np]);
float y1 = -r1*sin(angl[np]+theta/rot[np]);
//draw orbit
stroke(32); fill(255/(np+1),255/(np+1),16/(np+1),16);strokeWeight(2); // transparent orbit plane
ellipse(0, 0, r1/scl, r1/scl);
// draw planet at orbit angle
stroke(200, 200, 200); fill(36*(np+1),36*(np+1),16*(np+1),255);
ellipse(int(x1)/scl, int(y1)/scl, (3*eqtr[np])/scl, (3*eqtr[np])/scl);
//sphere((3*eqtr[np])/scl );
stroke(255); fill(255);
textFont(fontA, 12); textAlign(LEFT);
text( np+" "+pname[np], (1+int(x1)/scl), (-1+int(y1)/scl));
}
}
void ncomets() {
// draw comets
for ( int nc = 9 ; nc > 6 ; nc-=1 ) {
float ec = ecc[nc];
float ac = (au[nc]*300 );
float bc = (ac*sqrt(1-(ec*ec))) ;
float cc = ac*ec ;
float lc = (bc*bc)/ac ;
float rc = lc/(1.0+(ec*cos(angl[nc]+theta/rot[nc])));
float xc = (rc*cos(angl[nc]+theta/rot[nc]))+(2*cc);
float yc = (-rc*sin(angl[nc]+theta/rot[nc]));
// draw at orbit angles
stroke(200, 200, 200); fill(200, 200, 200);
ellipse(int(xc)/scl, int(yc)/scl, (3*eqtr[nc]), (3*eqtr[nc]));
stroke(255); fill(255);
textFont(fontA, 12); textAlign(LEFT);
text( pname[nc], (1+int(xc)/scl), (-1+int(yc)/scl));
}
}
«Prev
Next »
Moderate user : algwat
Forum