SHARE
TWEET

Python/RPi Tweetbot Example: Webcam image

w0lfiesmith Aug 29th, 2013 1,759 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import sys
  3. from twython import Twython
  4. import os
  5.  
  6. import pygame
  7. import pygame.camera
  8. from pygame.locals import *
  9.  
  10. pygame.init()
  11. pygame.camera.init()
  12. cam = pygame.camera.Camera("/dev/video0",(640,480))
  13. cam.start()
  14. image = cam.get_image()
  15. pygame.image.save(image,'webcam.jpg')
  16.  
  17. CONSUMER_KEY = 'jmyBuGoaMKS05x85qFCNRw'
  18. CONSUMER_SECRET = 'U2Ay9nv0CxdopruNk4DR9aRDyhry98ML7mYMCStdaI'
  19. ACCESS_KEY = '354540970-nMZVfXJqTbEP8ddj3jwRNs8UMXlZapZpbxiaLg0v'
  20. ACCESS_SECRET = 'L9MnMvXLROx76CT9NzjR7PFrtMcIb1U9venQwK1ygY'
  21.  
  22. photo = open('webcam.jpg','rb')
  23. api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
  24. api.update_status_with_media(media=photo, status='My RPi be tweeting images now => ')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top