Thanks here is the whole thing. please excuse some bad code practice in my position location etc;-) and i have lots of comments of code that i was testing that didnt work. its nearly finished and then when it does what i ant ill tidy it up
As you can see a live feed is occuring due to the call in the draw and then when keypressed it basically saves the gridded image plus the individual image to the hdisk (for recall later f flickr or whatever) and it swaps grid position.
I really want that when you press a key, that it begins the live footage and over the top it says 5,4,3,2,1 (going in actually time of seconds) then it stores the frame and stops live footage. so when no key is pressed you just have 16 gridded pictures. at the minute when no key is pressed you obviously have via the draw just the live video feed appearing in the space where the next picture will be saved.
maybe i should have it all within the draw function rather than calling separate voids.....
Plug in your camera and have a look - also youll need just any background image to substitute for OMG-big.
- PFont font;
- import processing.video.*;
- Capture myCapture;
- // starts the capture input
- int PicNumber;
- PImage a; // Declare variable "a" of type PImage
- PImage b,c,d,e,f,g,h,i,j,k,l,m,n,o,p; // the 15 other images
- String[] ImageID; // so string 0 is a string 1 is b
- String LastTaken;
- int xPos, yPos;
- PImage[] imgs = new PImage[16];
- int xWidth = 200;
- int secs;
- int mins;
- int hours;
- int startTime;
- int EndCounter;
- int BeginCounter;
- int Day, Month;
- int XRES, YRES;
- //=-=-=-=-=-=-=-=-=-=SETUP-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- void setup() {
-
- font = loadFont("tweet72.vlw");
- textFont(font,72);
-
- // setup screen size
-
- XRES = 2560; //1280
- YRES = 2048; // 1024
-
-
-
-
- size(800, 800);
-
- Day = day();
- Month = month();
-
-
- secs=second();
- mins=minute();
- hours=hour();
- println(hours + ":" + mins +" . " + secs);
-
- startTime = millis();
- EndCounter =millis();
- BeginCounter =millis();
-
-
- myCapture = new Capture(this, XRES, YRES);
-
- // image position setup and filename number
- xPos=0;
- yPos=0;
- PicNumber=1;
-
-
- String[] ImageID = new String[16];
-
-
-
- // init grids
-
- for (int z=0; z <16; z++){
- ImageID[z] = ("OMG_BIG.jpg");
- a = loadImage(ImageID[z]); // Load the image into the program
- println(ImageID[z] + z);
- }
-
- // use pink or the big one
- LastTaken = "OMG_BIG.jpg";
-
-
-
- InitPics(); // call the init screen
- // use this f one big image
- // c = loadImage("OMG_Pink.jpg");
- // image(c,0,0,800,800);
-
- //bear in mind now that a has been called via the loadImage
- }
- //---------------------------------------
- void Draw1() {
- text("BLAH",xPos,yPos,200,200);
- }
- //-----------------------------------------------------------------------------draw------------------------------------------------------------
- void draw() {
- // nothing as the drawimage function is taken by the press key
-
- if (myCapture.available() == true) {
- myCapture.read();
- }//endif
-
-
-
-
-
-
-
-
- // if (KeySwitch == true) {
- // myCapture.read();
- // image(myCapture,xPos,yPos,200,200);
- // }
-
-
- // to constantly have the video running in the current frame
-
- //in the draw method this will show the live stream - however it causes
- // problems with the saving of the photos cos it shows double squares.
- myCapture.read();
- image(myCapture,xPos,yPos,200,200);
-
-
-
- // if (keyPressed == true) {
-
- // Draw1();
- // DrawMe();
-
- // }
-
-
-
- }
- //--------------------------------------------------------------------------press key to take pic--------------------------------------------------
- void keyPressed() {
-
- DrawMe();
-
-
-
-
- // random assignment
- float y = random(0,16); //random numnber between 0 and 15
- int choice = int(y); // convert it to whole number
- println("saving in space :" +choice);
-
- if(choice==0) { // image 1
- xPos =0;
- yPos=0;
- } else
- if(choice==1) { // image 2
- xPos = 200;
- yPos = 0;
- } else
- if(choice==2) { // image 3
- xPos = 400;
- yPos = 0;
- } else
- if(choice==3) { // image 4
- xPos = 600;
- yPos = 0;
- } else
- if(choice==4) { // image 5
- xPos = 0;
- yPos = 200;
- } else
- if(choice==5) { // image 6
- xPos = 200;
- yPos = 200;
- } else
- if(choice==6) { // image 7
- xPos = 400;
- yPos = 200;
- } else
- if(choice==7) { // image 8
- xPos = 600;
- yPos = 200;
- } else
- if(choice==8) { // image 9
- xPos = 0;
- yPos = 400;
- } else
- if(choice==9) { // image 10
- xPos = 200;
- yPos = 400;
- } else
- if(choice==10) { // image 11
- xPos = 400;
- yPos = 400;
- } else
- if(choice==11) { // image 12
- xPos = 600;
- yPos = 400;
- } else
- if(choice==12) { // image 13
- xPos = 0;
- yPos = 600;
- } else
- if(choice==13) { // image 14
- xPos = 200;
- yPos = 600;
- } else
- if(choice==14) { // image 15
- xPos = 400;
- yPos = 600;
- } else {
- xPos = 600;
- yPos = 600;
- }//endif
-
- }
- //---------------------------------store the images to the hard drive-----------------------------------------------------
- void DrawMe(){
- // capture frame and put it to screen and save grid copy and individual copy
- myCapture.read();
- image(myCapture,xPos,yPos,200,200);
- //displays it in the box
- // if true display the camera in the 1st grid
- println("capture complete");
-
- String image_path = ("C:/OMG/" + str(day())+ "_" + str(month())+ "_" + str(year()) +"/");
- // String image_date = (str(Day) + "_" +str(Month));
-
- // String fullpath = (image_path + image_date);
-
-
- saveFrame(image_path + "Grid" + PicNumber + ".jpg");
- //full grid pic saved
-
-
-
-
- LastTaken = (image_path + "OMG_whoareyou" +PicNumber + ".jpg");
- PicNumber++;
- //save individual image of captured frame as well
- b = createImage(XRES,YRES,RGB);
- b.loadPixels();
- for (int t = 0; t < b.pixels.length; t++) {
- // set the pixels in the image to those from the video frame
- b.pixels[t] = myCapture.pixels[t];
- }
- b.updatePixels();
- b.save(LastTaken);
-
-
-
- }
- //------------------------------------------------------------------beginning---------------------------------------------------------------------------------
- void InitPics() {
- // Displays the image at its actual size at point (0,0)
- image(a, 0, 0, xWidth, xWidth);
- image(a, 200, 0, xWidth, xWidth);
- image(a, 400, 0, xWidth, xWidth);
- image(a, 600, 0, xWidth, xWidth);
-
- image(a, 0, 200, xWidth, xWidth);
- image(a, 200, 200, xWidth, xWidth);
- image(a, 400, 200, xWidth, xWidth);
- image(a, 600, 200, xWidth, xWidth);
-
- image(a, 0, 400, xWidth, xWidth);
- image(a, 200, 400, xWidth, xWidth);
- image(a, 400, 400, xWidth, xWidth);
- image(a, 600, 400, xWidth, xWidth);
-
- image(a, 0, 600, xWidth, xWidth);
- image(a, 200, 600, xWidth, xWidth);
- image(a, 400, 600, xWidth, xWidth);
- image(a, 600, 600, xWidth, xWidth);
- }