Skip to content

Chaance Graves Project 3

Chaance Graves edited this page May 4, 2016 · 10 revisions

Lunar finder App

Project Overview

This app will track the position of the Moon via a 3D rendering and would be able to update information to the User such as (Ecliptic Latitude and Longitude, Phase, and distance in km). A Javascript based program was written in conjuction with obtaining the aforementionded values. From there it will be able to allow the user to open the camera screen to get an accurate representation of the location of the moon basesd's on the calculator's results. This app would be useful for any astronomy enthusiast or anybody wanting to get a sense of where the Moon can be agorithmatically.

Features and API's used

  • Augmented Reality with Camera API and OpenGL ES2.
  • WebView application.
  • GPS location of the device.
  • Orientation sensor API.

Below is the classes used for CameraView and CameraProjectActivity. These classes in particualar were responsible for handling the the Surface view rendering of the Sphere when the camera is open.

CameraView.java

package com.test;

import java.io.IOException;

import android.content.Context;
import android.hardware.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.SurfaceHolder.Callback;

public class CameraView extends SurfaceView implements Callback {
    private Camera camera;
 
    public CameraView( Context context ) {
        super( context );
        // We're implementing the Callback interface and want to get notified
        // about certain surface events.
        getHolder().addCallback( this );
        // We're changing the surface to a PUSH surface, meaning we're receiving
        // all buffer data from another component - the camera, in this case.
        getHolder().setType( SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS );
    }
 
    public void surfaceCreated( SurfaceHolder holder ) {
        // Once the surface is created, simply open a handle to the camera hardware.
        camera = Camera.open();
    }
 
    public void surfaceChanged( SurfaceHolder holder, int format, int width, int height ) {
        // This method is called when the surface changes, e.g. when it's size is set.
        // We use the opportunity to initialize the camera preview display dimensions.
        Camera.Parameters p = camera.getParameters();
        p.setPreviewSize( width, height );
        camera.setParameters( p );
 
        // We also assign the preview display to this surface...
        try {
            camera.setPreviewDisplay( holder );
        } catch( IOException e ) {
            e.printStackTrace();
        }
        // ...and start previewing. From now on, the camera keeps pushing preview
        // images to the surface.
        camera.startPreview();
    }
 
    public void surfaceDestroyed( SurfaceHolder holder ) {
        // Once the surface gets destroyed, we stop the preview mode and release
        // the whole camera since we no longer need it.
        camera.stopPreview();
        camera.release();
        camera = null;
    }
}

Project Checklist

  • Framework for Augmented reality activity and Simple two button interface was created.
  • 3D rendered sphere model was successfully created on placed on the Surfaceview of the phone screen.
  • The Javascript application for calculating the defined Moon data was successfully utilized to return values.

Further Implementation for the app

  • 2D image wrapping of sphere indicating the phases from the calculator - 8 phases can be rendered with a switch/case statement on top of the the Sphere.
  • Save the data to a .txt file for the user to access in a later time.
  • A more defined robust method to convert ecliptic coordinates to phone orientation data parameters. (yaw, pitch, roll)

Clone this wiki locally