Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Capture 2 pictures of users and display both of the picture on screen

$
0
0


hello,

hm....

you have
  1.   if (key==1){
in keyPressed()
and
  1.   if (key=='7'){
in draw()

I would recommend to have it all in keyPressed() -
better use keyReleased instead of keyPressed()

Since you want to have two images you need
  • image1 and
  • image2
and copy the image from the cam into it



ok, let me see....


we can use count to determine how many pictures have been shot.....
and how the program must behave with each step:
  • 0 images: count = 0: wait for 1st image (taken when user presses "1")
  • 1 images: count = 1: show 1st image on the left and wait for 2nd image (taken when user presses "1" again)
  • 2 images: count = 2: show 1st image on the left and show 2nd image on the right (when user presses "1" again, you might want to delete both images and reset count to 0)




so draw() looks like this:

  1. void draw() {
  2. switch (count) {
  3. case 0:
  4. // do nothing
  5. break;
  6. case 1:
  7. image (image1, 100, 100);
  8. break;
  9. case 2:
  10. image (image1, 100, 100);
  11. image (image2, 400, 100);
  12. break;
  13. } // switch
  14. } // func


have a similar switch also in keyReleased():

  1. void keyReleased () {
  2. if (key == '1') {
  3. switch (count) {

  4. case 0:
  5. // get image1 from cam - I dunno how
  6. // image1=cam;
  7. count = 1;
  8. break;
  9. case 1:
  10. // get image2 from cam - I dunno how
  11. // image2=cam;
  12. count=2;
  13. break;
  14. case 2:
  15. // reset
  16. image1=null;
  17. image2=null;
  18. count = 0;
  19. break;

  20. } // switch
  21. } // if
  22. } // func


Greetings, Chrisir    


Viewing all articles
Browse latest Browse all 1768

Trending Articles