Advertisement
rabirajkhadka

SimpleCapture

Feb 6th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import gohai.glvideo.*;
  2. GLCapture video;
  3.  
  4. void setup() {
  5. size(320, 240, P2D); // Important to note the renderer
  6.  
  7. // Get the list of cameras connected to the Pi
  8. String[] devices = GLCapture.list();
  9. println("Devices:");
  10. printArray(devices);
  11.  
  12. // Get the resolutions and framerates supported by the first camera
  13. if (0 < devices.length) {
  14. String[] configs = GLCapture.configs(devices[0]);
  15. println("Configs:");
  16. printArray(configs);
  17. }
  18.  
  19. // this will use the first recognized camera by default
  20. video = new GLCapture(this);
  21.  
  22. // you could be more specific also, e.g.
  23. //video = new GLCapture(this, devices[0]);
  24. //video = new GLCapture(this, devices[0], 640, 480, 25);
  25. //video = new GLCapture(this, devices[0], configs[0]);
  26.  
  27. video.start();
  28. }
  29.  
  30. void draw() {
  31. background(0);
  32. // If the camera is sending new data, capture that data
  33. if (video.available()) {
  34. video.read();
  35. }
  36. // Copy pixels into a PImage object and show on the screen
  37. image(video, 0, 0, width, height);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement