Skip to content

Instantly share code, notes, and snippets.

@rdenadai
Last active December 20, 2015 22:08
Show Gist options
  • Save rdenadai/6202299 to your computer and use it in GitHub Desktop.
Save rdenadai/6202299 to your computer and use it in GitHub Desktop.
This is a small program i made using python to get an image from my telescope, using a webcam connected to the usb port, and post that on the twitter account i made!Was a really cool saturday afternoon project! hahahahahahahahahaha!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from SimpleCV import *
from StringIO import *
from time import sleep
# I have to make a little alter on the default script api.py from tweepy since the guys didn't commit yet the update_with_media function
import tweepy
if __name__ == '__main__':
# Your consumer keys here!
consumer_key=''
consumer_secret=''
# Your access keys here!
access_token=''
access_token_secret=''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
print api.me().name
api.update_status('Lets speaking (take pictures) about the cosmos! #astronomy #amateur')
# damn you crappy webcam, if you have a better one pass a props={"width": 1024, "height": 768} to have a better resolution
cam = Camera(1)
disp = Display(title='MyTelescopeSpeaks')
while disp.isNotDone():
img = cam.getImage()
# scales the image, my webcam was a crappy one so this is a must to make the image bigger!
img = img.scale(640, 480)
# when you click with the right mouse button! POST THAT IMAGE ON TWITTER! HA!
if disp.mouseRight:
img.save('myTelescopeSpeaks.png')
img.drawText('Posting on twitter...')
with open('myTelescopeSpeaks.png', 'r') as photo:
sendPic = StringIO(photo.read()).getvalue()
api.update_with_media(sendPic, status='Check this image #astronomy #amateur => ')
img.save(disp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment