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

Commit e98730c

Browse files
committed
initial commit
0 parents  commit e98730c

File tree

12 files changed

+503
-0
lines changed

12 files changed

+503
-0
lines changed

.classpath

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
5+
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
6+
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/opencv2"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Lab7</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.7
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.7

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Object Recognition with OpenCV and JavaFX
2+
3+
*Computer Vision course - [Politecnico di Torino](http://www.polito.it) - academic year 2014-2015*
4+
5+
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.
6+
7+
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.

build.fxbuild

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<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">
3+
<deploy>
4+
<application name="Lab6"/>
5+
<info/>
6+
</deploy>
7+
<signjar/>
8+
</anttasks:AntTask>

screenshots/one-tennis-ball.png

233 KB
Loading

screenshots/two-tennis-balls.png

237 KB
Loading
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package it.polito.teaching.cv;
2+
3+
import org.opencv.core.Core;
4+
5+
import javafx.application.Application;
6+
import javafx.stage.Stage;
7+
import javafx.scene.Scene;
8+
import javafx.scene.layout.BorderPane;
9+
import javafx.fxml.FXMLLoader;
10+
11+
public class Lab7 extends Application
12+
{
13+
/**
14+
* The main class for a JavaFX application. It creates and handles the main
15+
* window with its resources (style, graphics, etc.).
16+
*
17+
* This application looks for any tennis ball in the camera video stream and
18+
* try to select them according to their HSV values. Found tennis balls are
19+
* framed with a blue line.
20+
*
21+
* @author <a href="mailto:luigi.derussis@polito.it">Luigi De Russis</a>
22+
* @since 2015-01-13
23+
*
24+
*/
25+
@Override
26+
public void start(Stage primaryStage)
27+
{
28+
try
29+
{
30+
// load the FXML resource
31+
BorderPane root = (BorderPane) FXMLLoader.load(getClass().getResource("ObjRecognition.fxml"));
32+
// set a whitesmoke background
33+
root.setStyle("-fx-background-color: whitesmoke;");
34+
// create and style a scene
35+
Scene scene = new Scene(root, 800, 600);
36+
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
37+
// create the stage with the given title and the previously created
38+
// scene
39+
primaryStage.setTitle("Lab7");
40+
primaryStage.setScene(scene);
41+
// show the GUI
42+
primaryStage.show();
43+
}
44+
catch (Exception e)
45+
{
46+
e.printStackTrace();
47+
}
48+
}
49+
50+
public static void main(String[] args)
51+
{
52+
// load the native OpenCV library
53+
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
54+
55+
launch(args);
56+
}
57+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.geometry.*?>
4+
<?import javafx.scene.control.*?>
5+
<?import javafx.scene.layout.*?>
6+
<?import javafx.scene.image.*?>
7+
<?import javafx.scene.text.*?>
8+
9+
<BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="it.polito.teaching.cv.ObjRecognitionController">
10+
<right>
11+
<VBox alignment="CENTER" spacing="10">
12+
<padding>
13+
<Insets right="10" left="10" />
14+
</padding>
15+
<Label text="Hue Start" />
16+
<Slider fx:id="hueStart" min="0" max="180" value="20" blockIncrement="1" />
17+
<Label text="Hue Stop" />
18+
<Slider fx:id="hueStop" min="0" max="180" value="50" blockIncrement="1" />
19+
<Label text="Saturation Start" />
20+
<Slider fx:id="saturationStart" min="0" max="255" value="60" blockIncrement="1" />
21+
<Label text="Saturation Stop" />
22+
<Slider fx:id="saturationStop" min="0" max="255" value="200" blockIncrement="1" />
23+
<Label text="Value Start" />
24+
<Slider fx:id="valueStart" min="0" max="255" value="50" blockIncrement="1" />
25+
<Label text="Value Stop" />
26+
<Slider fx:id="valueStop" min="0" max="255" value="255" blockIncrement="1" />
27+
</VBox>
28+
</right>
29+
<center>
30+
<HBox alignment="CENTER" spacing="5">
31+
<padding>
32+
<Insets right="10" left="10" />
33+
</padding>
34+
<ImageView fx:id="originalFrame" />
35+
<VBox alignment="CENTER" spacing="5">
36+
<ImageView fx:id="maskImage" />
37+
<ImageView fx:id="morphImage" />
38+
</VBox>
39+
</HBox>
40+
</center>
41+
<bottom>
42+
<VBox alignment="CENTER" spacing="15">
43+
<padding>
44+
<Insets top="25" right="25" bottom="25" left="25" />
45+
</padding>
46+
<Button fx:id="cameraButton" alignment="center" text="Start camera" onAction="#startCamera" />
47+
<Separator />
48+
<Label fx:id="hsvCurrentValues" />
49+
</VBox>
50+
</bottom>
51+
</BorderPane>

0 commit comments

Comments
 (0)