Monday, 26 March 2012

Extracting the Data from the Web-server

The application requires that the phone gets the data back from the web-server.

This data is to be a result integer which is a '1' if the shot is to be a hit or a '2' if it is to be a miss.

A method of doing this is to use JSONS (http://www.json.org/)

The JSON is built on two structures:

  1. A collection of names and Values
  2. An ordered list of values
Twitter uses JSONS in order to store a users tweets and they can then be accessed by applications

The New Boston offers tutorials on the application side of JSONS

http://thenewboston.org/watch.php?cat=6&number=150

The tutorial returns the last tweet of a twitter user.

The server then needs to store the integer as a JSON so that it can be accessed using similar code.

To make creating the JSON objects simple for amateur developers, Google have created an API which can be used to create the JSON objects. This source is found here:

http://code.google.com/p/json-simple/

After this the integer from the physics engine was returned to the phone as a string.


Sunday, 18 March 2012

User Preferences

A good application allows the user to modify some of the software properties in order to match their needs and tastes. This is where preferences are used.

For our application, our preferences would be :


  1. User Name - A string with the users name(Needed if we were to use a database)
  2. Manually Re-Take Photo, the user can choose whether the application would re-take a photo automatically or do it manually. This is a checkbox and returns a boolean.
  3. Camera Timer, user can user the length of time the camera waits before taking a photo, can range from 2-5 seconds.
The New Boston offers tutorials on how to integrate user preferences with an Application:

http://thenewboston.org/watch.php?cat=6&number=54

The finished preferences are shown below:



Chris

Tidying up the Code

Before the sections are combined, the code needs to be tidied up.  This involves removing all statements that are printed into the command box as the program is running.

As a result, the program will be able to run quicker and more efficiently

Grace

Wednesday, 14 March 2012

Cue Direction

The cue direction is taken from the Data Acquisition section and passed via the Web Server to the Physics Engine.  


It can be used to set the initial ball direction.. One of the initial assumptions is that the cue is always set up to hit the ball straight on so that it can be assumed that the cue ball will always move in the direction of the cue.

Tuesday, 13 March 2012

Updating the Physics Engine

A more Updated version of the Physics engine was ready to be placed on the Web Server.

The physics engine was being tested by using a mouse click to place a ball and create a movement vector on the ball which simulated the shot.

For the web server, this mouse click was undesirable and it was required that the mouse handlers be removed which is difficult since the mouse clicks determine the ball positions.

Instead of the mouse click determining the position of the balls, a 2-d Array which acted as a map was used, this contained a value of '2' where the balls where. The location of the twos gave the co-ordinates of the balls, and so a ball was placed at the co-ordinate.

It was tested using a perfect circle drawn on a rectangle on microsoft paint. This didn't include the scaling algorithm and so the pixel co-ordinate matched the table co-ordinate.

Chris

Tuesday, 6 March 2012

Camera Resolutions

It should be noted that throughout the development of the project, testing is an ongoing activity

The image upload process has been tested on several phones (HTC Explorer, HTC Desire and HTC Desire S) When the program is tested on HTC Explorer and HTC Desire the image has a resolution of 768x1024 but when the HTC Desire took an image, the resolution was 1952x2592. This image was too large a file for the server to accept.

IT was decided that all photos that were taken should be of the resolution 768x1024.

In order to set the resolution of the Camera, several steps must be taken by the software:


  1. Camera Hardware needs to be asked what resolutions are supported, this is returned as a list of heights and widths
  2. List is then to be scanned for right resolution
  3. Once Resolution found, list number is returned
  4. Camera Set at correct resolution by the list number
The list is also shown to the user in the instructions so that they know which resolution is suported and whether the correct resolution is available:



Sunday, 4 March 2012

Creation of the Tab Layout

The Tab layout view was created showing the 3 tabs which run in tandem with each other. The user can quickly switch between all the activites. Below is the Picture showing the Instructions to the user



Above is the Camera View which uses a surface view to take a picture
 This is the Web View which shows the web page output to the user (Note: Server was off at Time of Writing)


This is the Splash screen which was initially displayed to the user

Wednesday, 29 February 2012

Corner Detection



As the hough transform uses polar co-ordinates, the corners of the table if filtered correctly can be discovered by finding hough line 90 degrees apart. Using matrices the co-ordinates of the intersection of the two lines can be discovered.








To account for filtering errors the degrees between each line will be checked 5 degrees either side of 90 so range from 85 to 95 degrees of separation between each line.

Different Directions

One of the aims for the project was for the program to test a variety of different directions.  In order to do this I ran a loop for the program to test 10 different angles (adding pi/5) each time.


There is a delay of 1 second while the program sends the ball in each direction.

Creation of the User Interface

The Application requires user interface to link them between the functions.

The first screen displayed would be a 'splash screen' which would be loaded for a few seconds with the application name.

The Android developer page has several layouts pre-defined that can be used by any developer.

http://developer.android.com/resources/tutorials/views/index.html

The best looking with the functionality required was the Tab-Layout view, it would be made with 3 Tabs

1st Tab would be displayed after the splash screen and would contain the Instructions

2nd Tab - Contains Image Capture and File Sending Algorithm

3rd Tab - Basic Web View to View Web Output, this would be very basic so that the user can only view one web page. All other options would be disabled to the user

Chris

Monday, 27 February 2012

Passing between Image Analysis and Physics Engine

2-D arrays need to be passed between the Image Processing and Physics engine. Functions were placed in both parts to allow the passing of the 2-D arrays.

Chris