GithubHelp home page GithubHelp logo

ezod / aistweet Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 3.0 119 KB

Twitter snapshot bot for a Raspberry Pi RTL-SDR AIS ship tracking station.

License: GNU General Public License v3.0

Python 100.00%
ais picamera python raspberry-pi twitter sdr rtl-sdr

aistweet's Introduction

aistweet, a Twitter photo bot for Raspberry Pi AIS tracking stations

aistweet tracks ships via AIS and takes their picture with a Raspberry Pi camera as they pass by.

Written for and powering the Detroit River Boat Tracker. Read about how it was made!

How To Build It

Things you will need:

Build and install rtl-ais, and configure it to stream UDP data to the host and port defined by the aistweet command line.

If you want to also upload your AIS data to other services online and have a locally-hosted interactive map, you can use AIS Dispatcher for Linux.

It is important to set the latitude, longitude, and direction of your camera accurately in order for the snapshot timing to work. The direction is measured in degrees clockwise from north of the camera's center axis.

Command Line

usage: aistweet.py [-h] [--host HOST] [--port PORT] [--db DB]
                   [--hashtags HASHTAGS [HASHTAGS ...]] [--tts]
                   latitude longitude

Raspberry Pi AIS tracker/camera Twitter bot

positional arguments:
  latitude              AIS station latitude
  longitude             AIS station longitude
  direction             bearing of camera (degrees clockwise from north)

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           host for receiving UDP AIS messages
  --port PORT           port for receiving UDP AIS messages
  --db DB               database file for static ship data
  --hashtags HASHTAGS [HASHTAGS ...]
                        hashtags to add to tweets
  --tts                 announce ship name via text-to-speech
  --light               disable night snapshots via light sensor

required environment variables:
  TWITTER_CONSUMER_API_KEY
  TWITTER_CONSUMER_API_KEY_SECRET
  TWITTER_ACCESS_TOKEN
  TWITTER_ACCESS_TOKEN_SECRET
  TWITTER_CLIENT_ID
  TWITTER_CLIENT_SECRET
  TWITTER_CALLBACK_URI

How To Authenticate With Twitter

Follow the instructions on the tweeter-basic repository to:

  • create a Twitter v2 API project
  • generate the required keys to be set as environment variables
  • generate the required token by doing a 1-time self-hosted browser authentication
    • note: the token is auto-refreshed with every tweet. However, if the token isn't refreshed in 6 months it will require user intervention to be re-generated.

Dependencies

aistweet's People

Contributors

ezod avatar mikebusuttil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aistweet's Issues

Some vessels generate multiple tweets

Occasionally, a vessel will generate multiple tweets (usually 2-3), with one "correct" photo and the others off-center or empty frame. The scheduler event is keyed by MMSI, and should be unique until 60 seconds after the tweet.

Improve night photos

Currently the auto settings on the Pi camera are used for both day and night captures. Night photos are difficult to make out as a result. Use the sunset time based on latitude via astral to switch the camera to better settings for night photos.

Choose image crop based on vessel size in camera FOV

The current crop criterion is based only on vessel length and does not account for proximity to the camera, projection onto the camera plane, or the actual camera field of view. This often results in inappropriately cropped images.

Retry tweet on error

Currently, if an error is generated when tweeting, it is simply logged. These errors are almost always intermittent issues (e.g. over capacity). Add limited retry logic to avoid missing tweets.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.