Never Enough Spacetime

Tales of an astronomer trapped in a programmer's body.

NexStar AutoGuider & MJPG Video Streaming for Android

Great News!

I have an alpha build of NexStar AutoGuider, a native Android app which consumes an MJPG video stream and calculates optical flow to detect movement of celestial objects due to the rotation of the earth. It will automatically translate the optical flow x and y values to send slew commands to a NexStar telescope. In this post, I will go over configuring mjpg_streamer to provide the MJPG stream, and connecting the NexStar AutoGuider to the stream. Prerequisites for this app:

  • NexStar compatible telescope
  • WiFi enabled telescope via
  • An Mjpeg stream of your telescope (instructions below for RPi based mjpeg_streamer)
  • An Smartphone running at least Android 4.0.

Check out the latest build from the 0.2 version on my build server!

Configuring mjpg_streamer

I'm using a Raspberry Pi v1 Model B with a Raspberry Pi 5MP Camera Board Module, but I expect this configuration to work with the Raspberry Pi v2 boards. I'll be upgrading shortly, but feel free to reach out and let me know.

Install cmake to build the raspicam input plugin.

sudo apt-get install cmake

Get jackonliam's mjpg-streamer fork:

cd mjpg-streamer-master/mjpg-streamer-experimental/
make mjpg_streamer

Then run the application.

LD_LIBRARY_PATH=. ./mjpg_streamer -o " -w /usr/local/www" -i " -rot 90 -hf -q 10"

NexStar AutoGuider

Pull down version 0.2.x (or later) from my build server. Since this isn't in the Google Play store yet, you'll need to allow unknown sources when you attempt to install. Also - sorry no graphics or icons yet... this is seriously alpha. I'll be tuning the slew algorithm for a little while before this hits the Play store.

Once installed, open the app and visit the settings page. Configure the host and port for your telescope, the URL for your mjpeg stream, and the slew factor. A note about the slew factor: this factor is multiplied by the x & y velocities (shown as an overlay on the mjpeg feed) to send a variable slew in arcseconds/second. I'm not yet sure if this slew factor will be necessary in the final release, but it is now while I calibrate!


Once you have everything configured, head back to the video screen. Note: for now you may have to restart the app to get the video feed started after you change settings. From the application menu, select the 'Start' option. This will start the slew feature of the app (the image below is a transmission tower near my home, I'll replace this with a sky image soon).

Video Feed

Known issues

  • You can't start, stop, then start the app. The stream never starts again.
  • If you rotate your screen or minimize the app, the stream stops permanently.
  • It would be awfully nice to start/stop the video feed separately from the telescope slew.
  • The Camera URL on the settings screen forces capital letters -- you'll have to use shift to get them to lowercase
  • The optical flow to slew algorithm is nowhere near bulletproof. I'm working on this first and foremost.
  • UX is barebones... give me some time here!

Let me know if you run into further issues, this works well for you, or you think it's junk. I welcome all feedback at this stage; there are some pretty complicated algorithms at play here so I don't expect this to work perfectly right off the bat for all scopes and configurations.