Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
luigidr committed Jan 29, 2015
0 parents commit e98730c
Show file tree
Hide file tree
Showing 12 changed files with 503 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/opencv2"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Lab7</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Object Recognition with OpenCV and JavaFX

*Computer Vision course - [Politecnico di Torino](http://www.polito.it) - academic year 2014-2015*

A project, made in Eclipse (Luna), for identify and track one or more tennis balls. It performs the detection of the tennis balls upon a webcam video stream by using the color range of the balls, erosion and dilation, and the `findContours` method. Some screenshots of the running project are available in the `screenshots` folder.

Please, note that the project is an Eclipse project, made for teaching purposes. Before using it, you need to install the OpenCV library (version 2.4.9) and JavaFX (version 2 or superior) and create a `User Library` named `opencv2` that links to the OpenCV jar and native libraries.
8 changes: 8 additions & 0 deletions build.fxbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ASCII"?>
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
<deploy>
<application name="Lab6"/>
<info/>
</deploy>
<signjar/>
</anttasks:AntTask>
Binary file added screenshots/one-tennis-ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/two-tennis-balls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions src/it/polito/teaching/cv/Lab7.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package it.polito.teaching.cv;

import org.opencv.core.Core;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.fxml.FXMLLoader;

public class Lab7 extends Application
{
/**
* The main class for a JavaFX application. It creates and handles the main
* window with its resources (style, graphics, etc.).
*
* This application looks for any tennis ball in the camera video stream and
* try to select them according to their HSV values. Found tennis balls are
* framed with a blue line.
*
* @author <a href="mailto:[email protected]">Luigi De Russis</a>
* @since 2015-01-13
*
*/
@Override
public void start(Stage primaryStage)
{
try
{
// load the FXML resource
BorderPane root = (BorderPane) FXMLLoader.load(getClass().getResource("ObjRecognition.fxml"));
// set a whitesmoke background
root.setStyle("-fx-background-color: whitesmoke;");
// create and style a scene
Scene scene = new Scene(root, 800, 600);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
// create the stage with the given title and the previously created
// scene
primaryStage.setTitle("Lab7");
primaryStage.setScene(scene);
// show the GUI
primaryStage.show();
}
catch (Exception e)
{
e.printStackTrace();
}
}

public static void main(String[] args)
{
// load the native OpenCV library
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

launch(args);
}
}
51 changes: 51 additions & 0 deletions src/it/polito/teaching/cv/ObjRecognition.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.text.*?>

<BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="it.polito.teaching.cv.ObjRecognitionController">
<right>
<VBox alignment="CENTER" spacing="10">
<padding>
<Insets right="10" left="10" />
</padding>
<Label text="Hue Start" />
<Slider fx:id="hueStart" min="0" max="180" value="20" blockIncrement="1" />
<Label text="Hue Stop" />
<Slider fx:id="hueStop" min="0" max="180" value="50" blockIncrement="1" />
<Label text="Saturation Start" />
<Slider fx:id="saturationStart" min="0" max="255" value="60" blockIncrement="1" />
<Label text="Saturation Stop" />
<Slider fx:id="saturationStop" min="0" max="255" value="200" blockIncrement="1" />
<Label text="Value Start" />
<Slider fx:id="valueStart" min="0" max="255" value="50" blockIncrement="1" />
<Label text="Value Stop" />
<Slider fx:id="valueStop" min="0" max="255" value="255" blockIncrement="1" />
</VBox>
</right>
<center>
<HBox alignment="CENTER" spacing="5">
<padding>
<Insets right="10" left="10" />
</padding>
<ImageView fx:id="originalFrame" />
<VBox alignment="CENTER" spacing="5">
<ImageView fx:id="maskImage" />
<ImageView fx:id="morphImage" />
</VBox>
</HBox>
</center>
<bottom>
<VBox alignment="CENTER" spacing="15">
<padding>
<Insets top="25" right="25" bottom="25" left="25" />
</padding>
<Button fx:id="cameraButton" alignment="center" text="Start camera" onAction="#startCamera" />
<Separator />
<Label fx:id="hsvCurrentValues" />
</VBox>
</bottom>
</BorderPane>
Loading

0 comments on commit e98730c

Please sign in to comment.