Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Prepare for release.
  • Loading branch information
JakeJMattson committed Jun 23, 2018
1 parent 75906c8 commit 21f71af
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ private void start()
displayFatalError("Failed to load OpenCV!");

//Force exit
System.out.print("Program terminated.");
System.exit(0);
}

@SuppressWarnings("unused")
private void capture(boolean debugMode)
{
//Start camera
Expand All @@ -61,8 +61,7 @@ private void capture(boolean debugMode)
}

//Get camera properties
double cameraWidth = camera.getWidth();
double cameraHeight = camera.getHeight();
double cameraWidth = camera.getWidth(), cameraHeight = camera.getHeight();

//Create display
ImageFrame rawDisplay = new ImageFrame("Touch Control");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.swing.JFrame;

/**
* Frame - GUI container for components (holds ImagePanel)
* Frame - GUI container for components (holds ImagePanel).
*
* @author mattson543
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.swing.JPanel;

/**
* Panel - holds image to display in GUI
* Panel - holds image to display in GUI.
*
* @author mattson543
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.opencv.core.*;

/**
* Abstract Button - contains general (clickable) button behavior
* Abstract Button - contains general (clickable) button behavior.
*
* @author mattson543
*/
Expand All @@ -22,8 +22,8 @@ protected Button(Rect dimensions, Scalar color)

/*
* (non-Javadoc)
* @see io.github.mattson543.touchcontrol.touchables.Touchable#
* updateDetectionPoint(org.opencv.core.Mat)
* @see io.github.mattson543.touchcontrol.touchables.Touchable
* #updateDetectionPoint(org.opencv.core.Mat)
*/
@Override
public Point updateDetectionPoint(Mat filteredImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import org.opencv.core.Point;

/**
* Demo Pad - Example application of abstract pad
* Controls mouse pointer position
* Demo Pad - Example application of abstract pad.
* Controls mouse pointer position.
*
* @author mattson543
*/
Expand All @@ -28,7 +28,7 @@ public MousePad(Rect dimensions, Scalar color)
}

/**
* Initialize fields
* Initialize fields.
*/
private void init()
{
Expand Down Expand Up @@ -62,7 +62,7 @@ public void performAction()

/**
* Convert the internal detection point from a point on the Touchable to a
* point on the screen so the mouse can be moved anywhere on the display
* point on the screen so the mouse can be moved anywhere on the display.
*
* @return Adjusted point
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.opencv.core.*;

/**
* Abstract Pad - contains general pad behavior
* Abstract Pad - contains general pad behavior.
*
* @author mattson543
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.opencv.core.*;

/**
* Demo Button - Example application of abstract button
* Plays note when touched
* Demo Button - Example application of abstract button.
* Plays note when touched.
*
* @author mattson543
*/
Expand All @@ -32,7 +32,7 @@ public PianoKey(Rect dimensions, Scalar color, char note)
}

/**
* Initialize fields
* Initialize fields.
*
* @param note
* Character representation of the note
Expand All @@ -47,7 +47,7 @@ private void init(char note)
}

/**
* Determine the key of the note based on the character input
* Determine the key of the note based on the character input.
*
* @param note
* Character representation of the note
Expand All @@ -65,7 +65,7 @@ private int determineKey(char note)
}

/**
* Create the audio player
* Create the audio player.
*/
private void setupMidi()
{
Expand Down Expand Up @@ -99,7 +99,6 @@ public void performAction()
if (!hasPlayed)
{
playNote(1000);

hasPlayed = true;
}
}
Expand All @@ -108,7 +107,7 @@ public void performAction()
}

/**
* Play the note that was assigned to the key
* Play the note that was assigned to the key.
*
* @param duration
* The amount of ms that the note should be held for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.opencv.imgproc.Imgproc;

/**
* Abstract Slider - contains general slider behavior
* Abstract Slider - contains general slider behavior.
*
* @author mattson543
*/
Expand All @@ -27,8 +27,8 @@ public abstract class Slider extends Touchable
*/
private boolean shouldLabel;

private static int DEFAULT_DIVISIONS = 100;
private static boolean DEFAULT_VISIBILITY = true;
private static final int DEFAULT_DIVISIONS = 100;
private static final boolean DEFAULT_VISIBILITY = true;

protected Slider(Rect dimensions, Scalar color)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ protected boolean isLabeled()
}

/**
* Determine the size of each division sector
* Determine the size of each division sector.
*/
private void calculateDivisionSize()
{
Expand All @@ -72,7 +72,7 @@ private void calculateDivisionSize()
}

/**
* Confine number of divisions to range
* Confine number of divisions to range.
*
* @param divisions
* Attempted value
Expand All @@ -90,8 +90,8 @@ else if (divisions > 100)

/*
* (non-Javadoc)
* @see io.github.mattson543.touchcontrol.touchables.Touchable#
* updateDetectionPoint(org.opencv.core.Mat)
* @see io.github.mattson543.touchcontrol.touchables.Touchable
* #updateDetectionPoint(org.opencv.core.Mat)
*/
@Override
public Point updateDetectionPoint(Mat filteredImage)
Expand All @@ -107,8 +107,8 @@ public Point updateDetectionPoint(Mat filteredImage)

/*
* (non-Javadoc)
* @see io.github.mattson543.touchcontrol.touchables.Touchable#drawOnto(org.
* opencv.core.Mat)
* @see io.github.mattson543.touchcontrol.touchables.Touchable
* #drawOnto(org.opencv.core.Mat)
*/
@Override
public void drawOnto(Mat image)
Expand All @@ -119,7 +119,7 @@ public void drawOnto(Mat image)
}

/**
* Draw status line and label
* Draw status line and label.
*
* @param image
* Matrix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.opencv.core.*;

/**
* Abstract Button - contains general (toggle) button behavior
* Abstract Button - contains general (toggle) button behavior.
*
* @author mattson543
*/
Expand All @@ -28,8 +28,8 @@ protected ToggleButton(Rect dimensions, Scalar color)
/*
* (non-Javadoc)
* @see
* io.github.mattson543.touchcontrol.touchables.Button#updateDetectionPoint(
* org.opencv.core.Mat)
* io.github.mattson543.touchcontrol.touchables.Button
* #updateDetectionPoint(org.opencv.core.Mat)
*/
@Override
public Point updateDetectionPoint(Mat filteredImage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.opencv.imgproc.Imgproc;

/**
* Contains fundamental functions for a Touchable object of any kind
* Contains fundamental functions for a Touchable object of any kind.
*
* @author mattson543
*/
Expand Down Expand Up @@ -52,7 +52,7 @@ public Scalar getColor()

/**
* Search through the range of the Touchable and find the first occurrence
* of a non-background pixel
* of a non-background pixel.
*
* @param filteredImage
* Binary image
Expand Down Expand Up @@ -95,7 +95,7 @@ public Point updateDetectionPoint(Mat filteredImage)
}

/**
* Determine whether or not the current detection point is null
* Determine whether or not the current detection point is null.
*
* @return Detection status
*/
Expand All @@ -105,7 +105,7 @@ protected boolean hasDetection()
}

/**
* Draw Touchable onto image
* Draw Touchable onto image.
*
* @param image
* Matrix to draw the Touchable object onto
Expand All @@ -124,12 +124,12 @@ public void drawOnto(Mat image)
}

/**
* Enforce method requirement on subclasses
* Abstract action that each Touchable subclass will perform.
*/
public abstract void performAction();

/**
* Formatter to create a uniform toString() for all Touchable objects
* Formatter to create a uniform toString() for all Touchable objects.
*
* @param name
* Name of field being formatted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.opencv.core.*;

/**
* Demo Slider - Example application of abstract slider
* Controls system volume
* Demo Slider - Example application of abstract slider.
* Controls system volume.
*
* @author mattson543
*/
Expand Down Expand Up @@ -42,16 +42,15 @@ public void performAction()
}

/**
* Set system volume
* Set system volume.
*
* @param volume
* New target system volume
*/
private void setVolume(int volume)
{
//Nircmd allows volume changing
File nircmd = new File("./nircmd/nircmd.exe");
String nircmdPath = nircmd.getAbsolutePath();
String nircmdPath = new File("nircmd/nircmd.exe").getAbsolutePath();

//Convert volume to nircmd standard
double nircmdVolume = 655.35 * volume;
Expand All @@ -68,7 +67,7 @@ private void setVolume(int volume)
}

/**
* Execute a system command (Calls nircmd from command line)
* Execute a system command (Call nircmd from command line).
*
* @param command
* System command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
public class Camera
{
/**
* OpenCV VideoCapture to access physical camera.
* OpenCV VideoCapture to access physical camera
*/
private final VideoCapture camera;
/**
* How each frame will be flipped upon reading.
* How each frame will be flipped upon reading
*/
private final Integer rotation;

/**
* When no index is specified, '0' can be used to request
* the default camera available to the operating system.
* the default camera available to the operating system
*/
private static final int DEFAULT_CAMERA = 0;

Expand Down Expand Up @@ -81,7 +81,6 @@ public Mat getFrame()

/**
* Whether or not the camera was successfully initialized.
* Returns false if no camera is plugged in.
*
* @return Open status
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,12 @@ public Mat filterImage(Mat image)
public BufferedImage convertMatToImage(Mat matrix)
{
//Get image dimensions
int width = matrix.width();
int height = matrix.height();
int width = matrix.width(), height = matrix.height();

//Determine image type
int type;
int type = matrix.channels() != 1 ? BufferedImage.TYPE_3BYTE_BGR : BufferedImage.TYPE_BYTE_GRAY;

if (matrix.channels() != 1)
{
type = BufferedImage.TYPE_3BYTE_BGR;
if (type == BufferedImage.TYPE_3BYTE_BGR)
Imgproc.cvtColor(matrix, matrix, Imgproc.COLOR_BGR2RGB);
}
else
type = BufferedImage.TYPE_BYTE_GRAY;

//Get matrix data
byte[] data = new byte[width * height * (int) matrix.elemSize()];
Expand Down

0 comments on commit 21f71af

Please sign in to comment.