Skip to content

Commit 1190a65

Browse files
committed
implemented output creation
created readme
1 parent b5565d9 commit 1190a65

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
# OpenCV Sample Annotator
2-
A simple tool to create positive and negative samples for cascade classifiers.
2+
A simple tool to create positive and negative samples for [cascading classifiers](http://docs.opencv.org/trunk/dc/d88/tutorial_traincascade.html).
3+
4+
**Next steps**
5+
6+
* implement rectangle selection and deletion
7+
8+
## Tool
9+
When you first start the application you have to choose the dataset (images to annotate) and also the output file.
10+
11+
Then every image is showed to you and you have to annotate all elements you want to classify in the image. With the `Clear` button it is possible to clear all rectangles on the image.
12+
13+
![Window](image/window.png)
14+
15+
After the last image is processed or you clicked `Finish` the application creates the output as a text file which can be read by the `opencv_createsamples` application.
16+
17+
Here you see an example of the `positives.txt`:
18+
19+
```
20+
10-House-Floor-Plans-962270.jpg 1.103448275862069 132.41379310344828 58.48275862068965 50.758620689655174 194.44067796610167 20.338983050847457 51.254237288135585 44.7457627118644 168.40677966101694 184.6779661016949 43.932203389830505 48.0 238.37288135593218 205.83050847457625 48.0 42.30508474576271 117.96610169491525 311.59322033898303 49.62711864406778 42.30508474576271 0.8135593220338982 309.9661016949152 59.389830508474574 48.81355932203394 134.23728813559322 396.20338983050846 65.08474576271186 44.745762711864415 212.33898305084745 397.01694915254234 65.89830508474574 45.5593220338983 280.6779661016949 310.77966101694915 43.93220338983053 49.627118644067764 458.03389830508473 349.01694915254234 43.118644067796595 42.30508474576271 501.1525423728813 347.3898305084746 41.491525423728774 43.93220338983048 445.01694915254234 445.01694915254234 49.62711864406782 44.745762711864415 453.9661016949152 525.5593220338983 47.18644067796612 49.627118644067764 501.1525423728813 524.7457627118644 46.37288135593218 50.4406779661017 941.2881355932203 310.77966101694915 59.389830508474574 49.627118644067764
21+
arapahoFloorPlanLg.JPG 389.2011494252874 109.816091954023 41.98850574712645 38.758620689655174 305.2241379310345 306.8390804597701 50.06321839080459 40.373563218390814 579.764367816092 458.64367816091954 54.90804597701151 59.75287356321837
22+
floorplan1_fs.jpg 220.30651340996167 287.35632183908046 21.07279693486592 29.693486590038276
23+
```
24+
25+
## About
26+
Developed during the bachelor thesis of Alexander Wyss & Florian Bruggisser.

image/window.png

284 KB
Loading

src/main/kotlin/ch/bildspur/annotator/ui/MainViewController.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import javafx.scene.shape.Rectangle
2121
import javafx.stage.Modality
2222
import javafx.stage.Stage
2323
import java.io.File
24+
import java.nio.file.Files
25+
import java.nio.file.Paths
2426
import kotlin.properties.Delegates
2527
import kotlin.system.exitProcess
2628

@@ -111,6 +113,8 @@ class MainViewController {
111113
}
112114

113115
fun saveAndClose() {
116+
savePolygonsAsText()
117+
114118
val alert = Alert(Alert.AlertType.INFORMATION)
115119
alert.title = "OpenCV Sample Annotator"
116120
alert.headerText = "All images annotated!"
@@ -122,6 +126,21 @@ class MainViewController {
122126
exitProcess(0)
123127
}
124128

129+
fun savePolygonsAsText() {
130+
var sb = StringBuilder()
131+
132+
for (image in annotationImages) {
133+
sb.append("${image.file.absolutePath} ")
134+
for (polygon in image.polygons) {
135+
val rect = getRectData(polygon)
136+
sb.append("${rect.x} ${rect.y} ${rect.width} ${rect.height} ")
137+
}
138+
sb.appendln()
139+
}
140+
141+
Files.write(Paths.get(positivesFile.absolutePath), sb.toString().toByteArray())
142+
}
143+
125144
fun resizeCanvas() {
126145
canvas!!.width = stage.width
127146
canvas!!.height = stage.height - 100.0

src/main/resources/view/MainView.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<Button layoutX="75.0" layoutY="7.0" mnemonicParsing="false" onAction="#nextClicked" text="Next"
1717
AnchorPane.leftAnchor="75.0"/>
1818
<Label fx:id="infoText" alignment="CENTER_RIGHT" layoutX="360.0" layoutY="12.0" prefHeight="17.0"
19-
prefWidth="130.0" text="1 of 1" AnchorPane.rightAnchor="16.0"/>
19+
prefWidth="130.0" text="0 of 0" AnchorPane.rightAnchor="16.0"/>
2020
<Button layoutX="132.0" layoutY="7.0" mnemonicParsing="false" onAction="#finishClicked" text="Finish"/>
2121
</children>
2222
</AnchorPane>

0 commit comments

Comments
 (0)