Hi all ,
Am making a program that change the size of 28 images according to value given by a user ,the idea of the program is , every time the program asks the user to input anew value to change the size for the current image.The thing is every time I entered a new value for each image and then save these images , then when I check the size of the images after save them I notice the size of all the images are the same according to the latest value I have entered . Please I need an idea about how to change the size of each single image according to a given value every time.
here is my code
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/** * * @author tamara */ public class MarkerImageGenerator extends PApplet {
// ArrayList<TableRecord>csvInputTableRecords= new ArrayList <TableRecord>(); ArrayList <PImage> images = new ArrayList<PImage>(); ArrayList<String> arraylistofImages= new ArrayList<String>(); ArrayList <PImage> markers = new ArrayList<PImage>(); ArrayList<String> arraylistofMarkers= new ArrayList<String>(); public int index=0;
public float cm2; public float cm; public int markerWidth; public int markerHeight; Scanner input = new Scanner(System.in);
public float pixelPerCmOfWidth; public float pixelPerCmOfHeight;
public static void main(String[] args) { PApplet.main(new String[]{"--present", "migpackage.MarkerImageGenerator"}); // ArrayList<TableRecord>csvInputTableRecords= new ArrayList <TableRecord>(); // TODO code application logic here } private StringTokenizer st; private StringTokenizer st1; private ArrayList<TableRecord> csvInputTableRecords = new ArrayList<TableRecord> (); private ArrayList<MarkerId> csvInputMarkerIds = new ArrayList<MarkerId> ();
@Override
public void setup() {
frameRate(1); loadCsv("C:\\Documents and Settings\\tamara\\My Documents\\NetBeansProjects\\MIGPackage\\src\\migpackage\\csv\\test4.txt"); String []imgs =getImageFilenames(csvInputTableRecords);
for (int i = 0 ; i < imgs.length ; i++) { images.add(loadImage("C:\\Documents and Settings\\tamara\\My Documents\\NetBeansProjects\\MIGPackage\\src\\migpackage\\images\\"+imgs[i]));
}
System.out.println("images size:"+ images.size()); loadCsv2("C:\\Documents and Settings\\tamara\\My Documents\\NetBeansProjects\\MIGPackage\\src\\migpackage\\csv2\\test7.txt"); String []marks =getMarkerImageFilenames(csvInputMarkerIds); for (int j = 0 ; j < marks.length ; j++) { markers.add(loadImage("C:\\Documents and Settings\\tamara\\My Documents\\NetBeansProjects\\MIGPackage\\src\\migpackage\\markers\\"+marks[j])); }
markerWidth = markers.get(i).width; markerHeight = markers.get(i).height; println("The size of the marker before scaling is" + markerWidth + " " + markerHeight); float pixelPerCmOfWidth = (100f / 2.54f); float pixelPerCmOfHeight = (100f / 2.54f); println("the size of the marker per cm is " + pixelPerCmOfWidth + " " + pixelPerCmOfHeight); //println("the size of the marker per cm is " + pixelPerCmOfWidth + " " + pixelPerCmOfHeight); System.out.print("Enter the size");
float size1 = input.nextFloat(); System.out.print("Enter the width");
// declare String variable and prime the read String read1 = br1.readLine( );
// System.out.println(read1);
while( read1 != null ) // end of the file? { st1 = new StringTokenizer( read1, "," ); System.out.println(st1.countTokens()); //We will check for unique items and add to the arraylist. String mk = new String(); String patt = new String(); // println(sc); while (st1.hasMoreElements()) { mk = st1.nextToken(); patt = st1.nextToken( ); } try { MarkerId trTemp1 = new MarkerId(mk,patt); csvInputMarkerIds.add(trTemp1); }
catch( NumberFormatException nfe ) { System.out.println( "Error in table record: " + read1 + "; record ignored"); } //end of catch
// read the next line
read1 = br1.readLine( ); }// release resources associated with "flights.txt"
Hi all ,
Am trying to change a scale the size of an image according to a parameter given by a user . The thing is the size of an image it seems never be changed after I input the parameter, I do not know why
, am using NetBeans with processing
here is my code , if any one can help me, Thanks
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/** * * @author tamara */ public class Main extends PApplet{ Scanner input =new Scanner(System.in); public PImage marker; public float cm; public float cm2; public int markerWidth; public int markerHeight; public static void main(String[] args) { PApplet.main(new String[]{"--present", "markerscaling.Main"}); // ArrayList<TableRecord>csvInputTableRecords= new ArrayList <TableRecord>(); // TODO code application logic here } @Override public void setup() {
marker= loadImage("25.png"); markerWidth= marker.width; markerHeight=marker.height; println("The size of the marker before scaling is"+ markerWidth+" "+ markerHeight); float pixelPerInchOfWidth=markerWidth/72; float pixelPerInchOfHight=markerHeight/72; float pixelPerCmOfWidth= (pixelPerInchOfWidth / 2.54f); float pixelPerCmOfHeight= (pixelPerInchOfHight / 2.54f);
System.out.print("Enter the size of am imaege"); float size= input.nextFloat();
cm =size*pixelPerCmOfWidth; cm2=size*pixelPerCmOfHeight; // scale(1.5f,1.5f);
println("the size of the marker after scaling is"+markerWidth+" "+ markerHeight);
Am trying to make a program of computer vision , the program should be able to track the markers within images and when it recognizes these markers, it draws a virtual object on the marker , then the program should be able to register the positions of the marker for example if the program managed to track the first marker it registers xy1 as a floating point vector and so on for the rest of the markers with changing in the value of the vector.Well I managed to get the program that can track more than one marker I used the library of ( Processing+NyARToolkit+multiple marker tracking)
http://cpbotha.net/2010/06/05/processing-nyartoolkit-multiple-marker-tracking/ .
My question is , is there any function or API Documentation that enables me to register the position of the markers ?
Hi all
I have a 27 images which is taken from a CSV file and I need to load all the images and display them in one time then save them , my problem is, when I try to display them ,they appear one image over the other . what can i do please so I can display them correctly .
here is my code that I used to load the images
PImage[] images;
int i;
Record[] records;
int recordCount;
void setup()
{ size(1000,1000);
images=new PImage[27];
frameRate(30);
String[] lines = loadStrings("test4.txt");
records = new Record[lines.length];
for (int i = 0; i < lines.length; i++)
{
String[] pieces = split(lines[i], ','); // Load data into array
if (pieces.length == 4)
{
records[recordCount] = new Record(pieces);
recordCount++;
}
}
/*for (int i = 0; i < recordCount; i++)
{
String img_name=records[i].img_name;
images[i]= loadImage("Processing\\sketch_sep07a\\"+img_name);
}
*/
}
void draw()
{
for (int i = 0; i < recordCount; i++)
{
String img_name=records[i].img_name;
images[i]= loadImage("Processing\\sketch_sep07a\\"+img_name);
Hi ,
If i have a CSV file which contains 3 columns and another CSV file which contains one column and I want to merger the two files in another file , will the out put file contain five columns ??
Thanks.
try
{
FileReader fr = new FileReader("experiment2.txt");
// FileReader ft=new FileReader("tofile.txt");
BufferedReader br = new BufferedReader( fr );
// declare String variable and prime the read
String stringRead = br.readLine( );
while( stringRead != null ) // end of the file?
{
// process the line read
StringTokenizer st = new StringTokenizer( stringRead, "," );
String scene = st.nextToken( );
String condition = st.nextToken( );
String img_name = st.nextToken( );
try
{
TableRecord frTemp = new TableRecord(scene, condition,img_name);
// add FlightRecord obj to listFlightRecords
listTableRecords.add( frTemp );
}
catch( NumberFormatException nfe )
{
System.out.println( "Error in flight record: "
+ stringRead
+ "; record ignored" );
}
// read the next line
stringRead = br.readLine( );
}
Hi ,
I have generated a CSV file with three column by Microsoft Excel and I want to add a new column with data but I do not know how to do it any help please ??
Am doing a program to generate several markers .Each marker with different ID ,
and I need to make the program ask the user to input the id ,
how can I get an input from the keyboard ??
any help please ..