Skip to content

Commit

Permalink
Merge pull request #94 from TH3steven/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bvobart authored Jun 17, 2016
2 parents c799498 + f126bd1 commit 9e2ed9a
Show file tree
Hide file tree
Showing 49 changed files with 2,710 additions and 1,132 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: travis-pro
repo_token: nDkWAX3N8wa4Fne7hEiCxE4ilZAKCVtXB
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

[![Build Status](https://travis-ci.org/TH3steven/Context-TFP.svg?branch=master)](https://travis-ci.org/TH3steven/Context-TFP)
[![Coverage Status](https://coveralls.io/repos/github/TH3steven/Context-TFP/badge.svg?branch=master)](https://coveralls.io/github/TH3steven/Context-TFP?branch=master)

![TFP](src/main/resources/logo-TFP.png)

Expand All @@ -21,4 +22,12 @@ The software is made for the Windows operating system and might not work as inte
This software can be developed with both Eclipse and IntelliJ, though they require a different process to set up.

###Note about preset creation/editing
For now, VLC is required to make the connection to the camera or to the mocked live feed. It is important to have the same VLC version as your java version, e.g. 32bit java requires 32bit VLC, and 64bit java requires 64bit VLC. Also, other systems than Windows are untested and might not work with the current implementation.
For now, VLC is required to make the connection to the camera or to the mocked live feed. It is important to have the same VLC version as your java version, e.g. 32bit java requires 32bit VLC, and 64bit java requires 64bit VLC. Also, other systems than Windows are untested and might not work with the current implementation.

###Database
In order to allow synchronization a MySQL database with the following 3 tables is needed:
- counter(number : INT)
- preset(**id : INT**, **camera : INT**, type : TEXT, description : TEXT, imageLocation : TEXT, pan : INT, tilt : INT, zoom : INT, focus : INT)
- script(**number : INT**, shotId : INT, camera : INT, preset : INT, description : TEXT, action : TEXT)

The bold attributes represent the primary keys.
Binary file modified doc/Architecture Design.pdf
Binary file not shown.
Binary file added doc/Final Report Team Free Pizza [Draft].pdf
Binary file not shown.
Binary file not shown.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>nl.tudelft</groupId>
<artifactId>Context-TFP</artifactId>
<version>0.6</version>
<version>0.8</version>
<name>Team Free Pizza</name>
<description>TU Delft Contextproject Multi-Media 2016 from Team Free Pizza</description>

Expand Down Expand Up @@ -143,6 +143,11 @@
<artifactId>jna</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.2</version>
</dependency>
</dependencies>

<reporting>
Expand Down
72 changes: 37 additions & 35 deletions src/main/java/nl/tudelft/contextproject/ContextTFP.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,22 @@
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

import nl.tudelft.contextproject.camera.Camera;
import nl.tudelft.contextproject.camera.CameraSettings;
import nl.tudelft.contextproject.camera.CameraConnection;
import nl.tudelft.contextproject.camera.LiveCameraConnection;
import nl.tudelft.contextproject.camera.MockedCameraConnection;
import nl.tudelft.contextproject.gui.AlertDialog;
import nl.tudelft.contextproject.gui.MenuController;
import nl.tudelft.contextproject.presets.InstantPreset;
import nl.tudelft.contextproject.saveLoad.ApplicationSettings;
import nl.tudelft.contextproject.script.Script;
import nl.tudelft.contextproject.script.Shot;

import uk.co.caprica.vlcj.discovery.NativeDiscovery;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* This is the main file for the Multi-Media Contextproject of Team Free Pizza.
Expand All @@ -57,41 +54,19 @@ public void start(Stage pStage) throws Exception {
primaryStage.setTitle("TFP Camera Control");
primaryStage.minWidthProperty().set(800);
primaryStage.minHeightProperty().set(575);
primaryStage.getIcons().add(new Image(ContextTFP.class.getResourceAsStream("/icon.png")));

// Create the script to be used by the application.
script = new Script(new ArrayList<Shot>());

//TEMP
Camera a = new Camera();
Camera b = new Camera();
Camera c = new Camera();
Camera d = new Camera();
Camera e = new Camera();
Camera f = new Camera();

LiveCameraConnection live = new LiveCameraConnection("192.168.0.13");
live.setUpConnection();
a.setConnection(live);

MockedCameraConnection mocked = new MockedCameraConnection();
b.setConnection(mocked);
// Statically initialise ApplicationSettings class.
ApplicationSettings.getInstance();

MockedCameraConnection mocked2 = new MockedCameraConnection();
mocked2.setStreamLink("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8");
c.setConnection(mocked2);

List<Camera> list = new ArrayList<Camera>();
list.addAll(Arrays.asList(a, b, c, d, e, f));

for (Camera cam : list) {
cam.addPreset(new InstantPreset(new CameraSettings(), 0, "wow"));
cam.addPreset(new InstantPreset(new CameraSettings(), 1, "nice"));
cam.addPreset(new InstantPreset(new CameraSettings(), 2, "awesome"));
cam.addPreset(new InstantPreset(new CameraSettings(), 3, "wuq"));
}

initRootLayout();
Platform.runLater(() -> initVLCj());

new Thread(() -> initVLCj()).start();
new Thread(() -> initCameraConnections()).start();

MenuController.show();
}

Expand All @@ -108,6 +83,11 @@ public void initRootLayout() {
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setOnCloseRequest(e -> {
try {
ApplicationSettings.getInstance().save();
} catch (IOException ex) {
ex.printStackTrace();
}
Platform.exit();
System.exit(0);
});
Expand All @@ -116,6 +96,28 @@ public void initRootLayout() {
}
}

/**
* Initialises the camera connections for every loaded camera.
* If an IP was loaded for a camera, then it will check if it
* can make a connection to this camera. If it can, then it will
* set its connection to a LiveCameraConnection. If it cannot,
* then it sets a MockedCameraConnection.
*/
public void initCameraConnections() {
ApplicationSettings settings = ApplicationSettings.getInstance();
for (Camera cam : Camera.getAllCameras()) {
String camIp = settings.getCameraIP(cam.getNumber());
if (camIp != null && !camIp.equals("")) {
CameraConnection connect = new LiveCameraConnection(camIp);
if (connect.setUpConnection()) {
cam.setConnection(connect);
break;
}
}
cam.setConnection(new MockedCameraConnection());
}
}

/**
* Tries to load VLC using the VLC native discovery tactic.
* If it cannot find VLC installed, it will ask for the location of the
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/nl/tudelft/contextproject/camera/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@ public void tilt(int offset) {
notifyObservers();
}

/**
* Pans and Tilts the camera to a setting offset. Cannot tilt or
* pan the camera past the pan and tilt limits.
*
* @param panOffset The offset to pan the camera
* @param tiltOffset The offset to tilt the camera.
*/
public void panTilt(int panOffset, int tiltOffset) {
camSet.panTilt(panOffset, tiltOffset);

if (hasConnection()) {
connection.relPanTilt(panOffset, tiltOffset);
}

setChanged();
notifyObservers();
}

/**
* Zooms the camera a certain offset. Cannot zoom past
* the zoom limits.
Expand Down Expand Up @@ -407,6 +425,6 @@ public Collection<Preset> getAllPresets() {

@Override
public String toString() {
return "Camera: " + camId;
return this.equals(DUMMY) ? "None" : String.valueOf(camId + 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,12 @@ public abstract class CameraConnection implements Observer {
* @return True iff the operation was performed successfully.
*/
protected abstract boolean relFocus(int offset);

/**
* Takes a snapshot of the image present on a camera and stores the image
* at a chosen location.
*
* @param imageLocation The location to which the captured image is stored.
*/
public abstract void snapShot(String imageLocation);
}
11 changes: 11 additions & 0 deletions src/main/java/nl/tudelft/contextproject/camera/CameraSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ protected void tilt(int offset) {
tilt += offset;
}

/**
* Pans and Tilts the Camera Settings a certain pan and tilt offset.
*
* @param panOffset The offset to pan the camera.
* @param tiltOffset The offset to tilt the camera.
*/
protected void panTilt(int panOffset, int tiltOffset) {
pan += panOffset;
tilt += tiltOffset;
}

/**
* Zooms the camera settings a certain offset.
* @param offset The offset to zoom the camera.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package nl.tudelft.contextproject.camera;

import javafx.embed.swing.SwingFXUtils;
import javafx.scene.SnapshotParameters;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;

import nl.tudelft.contextproject.gui.LiveStreamHandler;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.Observable;
import javax.imageio.ImageIO;

/**
* Class to represent a live connection with a camera. It is
Expand Down Expand Up @@ -204,6 +213,21 @@ public boolean setAutoFocus(boolean autoFocus) {
}
}

@Override
public void snapShot(String imageLocation) {
if (isConnected()) {
LiveStreamHandler liveStreamHandler = new LiveStreamHandler();
ImageView imageView = liveStreamHandler.createImageView(getStreamLink(), 640, 360);
WritableImage image = imageView.snapshot(new SnapshotParameters(), null);
File output = new File(imageLocation);
try {
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", output);
} catch ( IOException e) {
e.printStackTrace();
}
}
}

@Override
public void update(Observable o, Object arg) {
if (!(o instanceof Camera)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package nl.tudelft.contextproject.camera;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Observable;
import javax.imageio.ImageIO;

/**
* Class to represent a mocked camera. It mimics or mocks the behavior of a specific camera
Expand All @@ -9,6 +13,7 @@
* @since 0.4
*/
public class MockedCameraConnection extends CameraConnection {

private CameraSettings camSet = new CameraSettings(30, 30, 30, 1365);
private String streamLink = "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8";

Expand Down Expand Up @@ -127,4 +132,15 @@ public void update(Observable o, Object arg) {
camSet = (CameraSettings) arg;
}
}

@Override
public void snapShot(String imageLocation) {
File output = new File("src/main/resources/error.jpg");
try {
BufferedImage image = ImageIO.read(output);
ImageIO.write(image, "jpg", new File(imageLocation));
} catch (IOException e) {
e.printStackTrace();
}
}
}
Loading

0 comments on commit 9e2ed9a

Please sign in to comment.