We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import java.io.FilenameFilter;
import jp.nyatla.nyar4psg.*;
import codeanticode.gsvideo.*;
String camPara ="C:/Users/MSR.info/Documents/Processing/libraries/nyar4psg/data/camera_para_isight2.dat";
String patternPath = "";
int arWidth = 640 ;
int arHeight = 480;
int numMarkers = 10;
GSCapture cam ;
MultiMarker nya;
float displayScale ;
color[] colors = new color [numMarkers];
float[] scaler = new float[numMarkers];
void setup(){
size(640,480,P3D);
cam = new GSCapture(this, 640, 480);
cam.start();
noStroke();
displayScale = (float) width /arWidth;
nya = new MultiMarker(this, arWidth, arHeight, camPara, NyAR4PsgConfig.CONFIG_DEFAULT);
nya.setLostDelay(1);
String[] patterns = loadPatternFilenames(patternPath);
for (int i=0; i< numMarkers ;i++){
nya.addARMarker(patternPath + "/" + patterns[i] , 80);
colors[i] = color(random(255), random(255),random(255), 160);
scaler[i] = random(0.5,1.9);
}
}
void draw (){ // pour realiser les image sur les marqueurs
if (cam.avaible){ // si le camera est en fonctionnement
cam.read();
background(0);
image(cam, 0, 0, width, height );
PImage cSmall = cam.get();
cSmall.resize(arWidth, arHeight);
nya.detect(cSmall);
drawMarker();
drawBoxes();
}
}
void drawMarker(){
textAlign(LEFT, TOP);
textSize(10);
noStroke();
scale(displayScale);
for(int i = 0 ; i < numMarkers ; i++){
if((!nya.isExistMarker(i))){continue;}
PVector[] pos2d = nya.getMarkerVertex2D(i);
for(int j = 0 ; j <= 3 ; j++){
String s= "(" + int(pos2d[j].x) + "," + int(pos2d[j].x) + ")" ;
fill(255);
rect(pos2d[j].x, pos2d[j].y, textWidth(s) + 3 , textAscent() + textDescent() +3);
fill(0);
text(s, pos2d[j].x + 2, pos2d[j].y + 2);
fill(255, 0 , 0);
ellipse(pos2d[j].x, pos2d[j].y, 5, 5);
}
}
}
void drawBoxes(){
nya.setARPerspective();
for (int i=0 ; i < numMarkers ; i++){
if ((!nya.isExistMarker(i))) { continue; }
setMatrix(nya.getMarkerMatrix(i));
scale(1,-1);
translate(0, 0, 20);
lights();
stroke(0);
fill(colors[i]);
box(40);
noLights();
translate(0, 0, 20.1);
noStroke();
}
perspective();
}
String[] loadPatternFilenames(String path){
File folder = new File(path);
FilenameFilter pattFilter = new FilenameFilter(){
public boolean accept(File dir, String name){
return name.endsWith(".path");
}
};
return folder.list(pattFilter);
}</pre>
Answers
cam.available()
thank's done :)
have any about changing this code to anroid !
Do you have a basic sketch working on Android?
I would highly suggest you read some tutorials.
You do not learn art by painting the Mona Lisa.
yes i have , but i'm new here and i want to learn how not another think :)
You misunderstood me.
The Mona Lisa is very good art.
No one would expect someone new to making art to be able to paint it.
It will a lot of effort to get good at it.
It is quite clear you are new.
You should not expect to be making very good programs right away.
You said you have a basic sketch working on Android.
Do you understand what each line means and does in it?
Please post the code for it.
brothre i think you don't understand me ! all of what you say i know it !! i mean i'm here just asking for changing this code to android no more .. i just need a Method ,and you are talking about Mona Lisa is very good art !!!
Completely Unrelated Mona Lisa is not good at art! she doesn't even exist...
Leonardo da Vinci
(who painted her) is very good at art.