Skip to content

Commit

Permalink
First release; Added basic stats for loaded data set.
Browse files Browse the repository at this point in the history
  • Loading branch information
aujfa committed Nov 15, 2019
1 parent 9adf18d commit b1b080b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 17 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ https://www.researchgate.net/publication/220611301_A_novel_contour_descriptor_fo

Writen in Java 12 with openCV 4 and JavaFX 12

Currently it is possible to download compiled version 0.1.0-rc1 for Windows from this link:
https://1drv.ms/u/s!ArqGpSFpdmx4m1Gv2nHY_Av-4-Rm?e=zF2RRm
Simply download .zip archive, unzip and double click RunCpdhApp.bat
14 changes: 7 additions & 7 deletions src/cpdh/CpdhController.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ public class CpdhController {
private ProgressBar progresBar;

private HostServices hostServices;

private final FileChooser fileChooser = new FileChooser();
// private File lastOpenedImageFile;

private final ExecutorService executorService = Executors.newCachedThreadPool();

Expand Down Expand Up @@ -170,6 +169,7 @@ private void initialize() {
iniDir = new File(".");
fileChooser.setInitialDirectory(iniDir);

label.setText("Load image that contains a single shape to see its CPDH.");
progresBar.setManaged(false);

// Automatic compare not implemented
Expand Down Expand Up @@ -283,14 +283,14 @@ private void handleItemHelp() {
help.setTitle("Cpdh App help");
help.setHeaderText("Cpdh App help");
help.setContentText("For best result it is recommended to use images that contain only a single object (single contour)"
+ "\nand that object is clearly distinguishable from the background."
+ "\nand that the object is clearly distinguishable from a background."
+ "\n\nA data set can easily be created from the content of a folder."
+ "\nTo construct custom data set simply put pictures in a folder and select that folder as data set in Data set settings section."
+ "\nAfter that simply click build data set button."
+ "\nFile names of pictures are important as groups of shapes are inferred from the pictures' file name."
+ "\nFile names of pictures are important as categories of shapes are inferred from the pictures' file name."
+ "\nFile name should begin with a name of a shape, followed by a dash \"-\" and the rest of the file name."
+ "\nFor example \"butterfly-01\" and \"butterfly-small\" will be part of the same group of shapes,"
+ "\nbut \"other-butterfly\" will not be placed in that group."
+ "\nFor example \"butterfly-01\" and \"butterfly-small\" will be part of the same category of shapes,"
+ "\nbut \"other-butterfly\" will not be placed in that category."
+ "\nAfter adding or removing pictures from the folder, data set needs to be rebuilt for changes to take effect."
+ "\n\nSupported file extensions are: .jpg, .jpeg and .bmp .");
help.setOnShown(e -> {
Expand All @@ -306,7 +306,7 @@ private void handleItemAbout() {
Alert info = new Alert(Alert.AlertType.INFORMATION);
info.setTitle("Cpdh App About");
info.setHeaderText("Cpdh App\n"
+ "ver. 0.1.0-rc1");
+ "ver. 0.1.0");
StringBuilder contentBuilder = new StringBuilder("This app constructs CPDH descriptor and shows steps made during the construction.")
.append("\nThis CPDH descriptor then can be run through a data set to find the most similar match.")
.append("\nMPEG-7 shape dataset is provided as default, but for the best results, constructing custom data set is recommended.")
Expand Down
4 changes: 4 additions & 0 deletions src/cpdh/CpdhDataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ public interface CpdhDataSet {
boolean isEmpty();

boolean containsCpdhInGroup(Cpdh cpdh, String groupName);

int numOfCategories();

int numOfCpdhs();
}
13 changes: 13 additions & 0 deletions src/cpdh/CpdhDataSetImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,18 @@ private StringBuilder dataToLines() {
public boolean isEmpty() {
return groups.isEmpty();
}

@Override
public int numOfCategories() {
return groups.size();
}

@Override
public int numOfCpdhs() {
int num = 0;
for (var group : groups.values())
num += group.size();
return num;
}

}
4 changes: 2 additions & 2 deletions src/cpdh/CpdhUI.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<BorderPane fx:id="borderPane" focusTraversable="true" maxHeight="680.0" maxWidth="950.0" minHeight="680.0" minWidth="950.0" prefHeight="680.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cpdh.CpdhController">
<BorderPane fx:id="borderPane" focusTraversable="true" maxHeight="680.0" maxWidth="1000.0" minHeight="680.0" minWidth="920.0" prefHeight="680.0" prefWidth="920.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cpdh.CpdhController">
<top>
<MenuBar BorderPane.alignment="TOP_LEFT">
<menus>
Expand Down Expand Up @@ -99,7 +99,7 @@
<children>
<VBox alignment="BOTTOM_CENTER" maxWidth="637.0" prefHeight="90.0">
<children>
<TextArea fx:id="textArea" editable="false" focusTraversable="false" minHeight="80.0" minWidth="535.0" prefRowCount="3" promptText="CPDH for loaded image will be shown here.">
<TextArea fx:id="textArea" editable="false" focusTraversable="false" minHeight="80.0" minWidth="525.0" prefRowCount="3" promptText="CPDH for loaded image will be shown here.">
<VBox.margin>
<Insets bottom="5.0" left="7.0" right="7.0" top="5.0" />
</VBox.margin>
Expand Down
15 changes: 12 additions & 3 deletions src/cpdh/DataSetController.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void onShow() {

if (dataSetsAreLoaded) {
infoLabel.setText("Data set: \"" + currentDataSetDirectory.getName() + "\" is successfully loaded.");
infoLabel2.setText("");
infoLabel2.setText(dataSetInfo());
}
else {
infoLabel.setText("No data found for selected folder!");
Expand Down Expand Up @@ -142,7 +142,7 @@ private void handleBtnBrowse() {
}
dataSetsAreLoaded = true;
infoLabel.setText("Data set: \"" + dir.getName() + "\" is successfully loaded.");
infoLabel2.setText("");
infoLabel2.setText(dataSetInfo());
if (dir.equals(defaultDataSetDirectory.getAbsoluteFile())) {
dataSetsAreDefault = true;
hyperlinkMakeDefault.setVisible(false);
Expand Down Expand Up @@ -194,7 +194,7 @@ private void handleConstructDataSet() {
progressBar.progressProperty().unbind();
progressBar.setVisible(false);
progressBar.setManaged(false);
infoLabel2.setText("");
infoLabel2.setText(dataSetInfo());
infoLabel2.setVisible(true);
btnConstructDataSets.setDisable(false);
});
Expand Down Expand Up @@ -224,6 +224,15 @@ CpdhDataSet getDataSet(Integer key) {
return dataSets.get(key);
}

private String dataSetInfo() {

if (dataSets.isEmpty())
return "";

return String.format("There are %d categories and total of %d shapes in the data set.",
dataSets.get(50).numOfCategories(), dataSets.get(50).numOfCpdhs() );
}

@FXML
void handleBtnClose() {
onClose();
Expand Down
4 changes: 2 additions & 2 deletions src/cpdh/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public void start(Stage primaryStage) {
BorderPane root = (BorderPane) loader.load();
controler = (CpdhController) loader.getController();
controler.setHostServices(getHostServices());
Scene scene = new Scene(root,950,680);
Scene scene = new Scene(root,925,720);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setMinWidth(965);
primaryStage.setMinWidth(925);
primaryStage.setMinHeight(720);
primaryStage.setTitle("CPDH App");
primaryStage.show();
Expand Down
2 changes: 1 addition & 1 deletion src/cpdh/Tasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected Map<Integer, CpdhDataSet> call() {

updateMessage("Getting files");
File[] files = dir.listFiles((directory, name) -> {
return name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".png") || name.endsWith(".bmp");
return name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".bmp");
});
if (files.length == 0) {
updateMessage("Canceled. No picture files with supported extensions found.");
Expand Down

0 comments on commit b1b080b

Please # to comment.