Skip to content

Commit

Permalink
add licenses and fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextopher committed Sep 19, 2024
1 parent 715b24a commit 865f829
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 35 deletions.
1 change: 0 additions & 1 deletion photon-client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ if (!is_demo) {
useSettingsStore().updateGeneralSettingsFromWebsocket(data.settings);
}
if (data.cameraSettings !== undefined) {
console.log("cameras", data.cameraSettings);
useCameraSettingsStore().updateCameraSettingsFromWebsocket(data.cameraSettings);
}
if (data.ntConnectionInfo !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const interactiveCols = computed(() =>
// Filters out models that are not supported by the current backend, and returns a flattened list.
const supportedModels = computed(() => {
const { availableModels, supportedBackends } = useSettingsStore().general;
return supportedBackends.flatMap(backend => availableModels[backend] || []);
return supportedBackends.flatMap((backend) => availableModels[backend] || []);
});
const selectedModel = computed({
get: () => supportedModels.value.indexOf(currentPipelineSettings.value.model),
set: (v) => {
useCameraSettingsStore().changeCurrentPipelineSetting({ model: supportedModels.value[v] }, false)
},
useCameraSettingsStore().changeCurrentPipelineSetting({ model: supportedModels.value[v] }, false);
}
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion photon-client/src/types/PipelineTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export const DefaultObjectDetectionPipelineSettings: ObjectDetectionPipelineSett
confidence: 0.9,
nms: 0.45,
box_thresh: 0.25,
model: "",
model: ""
};

export type ActivePipelineSettings =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ public Optional<Model> getModel(String modelName) {

/**
* The default model when no model is specified.
*
* @param model
*/
public Optional<Model> getDefaultModel() {
if (models == null) {
Expand Down Expand Up @@ -210,8 +208,9 @@ private void loadModel(File model) {
try {
switch (backend.get()) {
case RKNN:
models.get(backend.get()).add(new RknnModel(model, labels));
logger.info("Loaded model " + model.getName() + " for backend " + backend.get().toString());
models.get(backend.get()).add(new RknnModel(model, labels));
logger.info(
"Loaded model " + model.getName() + " for backend " + backend.get().toString());
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.jni;

import java.awt.Color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.vision.objects;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.vision.objects;

public interface Model {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.vision.objects;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.vision.objects;

import java.util.List;
Expand All @@ -7,9 +24,14 @@
import org.photonvision.vision.pipe.impl.NeuralNetworkPipeResult;

/**
* ObjectDetector lifecycle: - {@link Model}s are discovered by {@link NeuralNetworkModelManager} -
* {@link Model} is selected as a parameter of {@link ObjectDetectionPipeline} - {@link Model.load}
* is called to create a ObjectDetector instance
* ObjectDetector lifecycle:
* <ol>
* <li> {@link Model}s are discovered by {@link NeuralNetworkModelManager} </li>
* <li> {@link Model} is selected as a parameter of {@link org.photonvision.vision.pipe.impl.ObjectDetectionPipe ObjectDetectionPipe} </li>
* <li> {@link Model#load()} is called to create a ObjectDetector instance </li>
* <li> {@link ObjectDetector#detect(Mat, double, double)} is called to perform object detection </li>
* <li> {@link ObjectDetector#release()} is called to release resources </li>
* </ol>
*/
public interface ObjectDetector extends Releasable {
/** Returns the model that created this ObjectDetector. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.photonvision.vision.objects;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class ObjectDetectionPipe
extends CVPipe<
CVMat, List<NeuralNetworkPipeResult>, ObjectDetectionPipe.ObjectDetectionPipeParams>
implements Releasable {

private ObjectDetector detector;

public ObjectDetectionPipe() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,16 @@ protected void setPipeParamsImpl() {
var params = new ObjectDetectionPipeParams();
params.confidence = settings.confidence;
params.nms = settings.nms;
Optional<Model> selectedModel = NeuralNetworkModelManager.getInstance().getModel(settings.model);
Optional<Model> selectedModel =
NeuralNetworkModelManager.getInstance().getModel(settings.model);

// If the desired model couldn't be found, log an error and try to use the default model
if (selectedModel.isEmpty()) {
// logger.error("Model not found: " + settings.model + ". Trying to use default model.");
selectedModel = NeuralNetworkModelManager.getInstance().getDefaultModel();
}

// If the model remains empty, use the NullModel
if (selectedModel.isEmpty()) {
// logger.error("Default Model not found. Using empty NullModel.");
selectedModel = Optional.of(NullModel.getInstance());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public ObjectDetectionPipelineSettings() {
ledMode = false;
confidence = .9;
nms = .45;
model = NeuralNetworkModelManager.getInstance().getDefaultModel().map(Model::getName).orElse("");
model =
NeuralNetworkModelManager.getInstance().getDefaultModel().map(Model::getName).orElse("");
}
}
4 changes: 2 additions & 2 deletions photon-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ run {
}

remotes {
home {
host = '192.168.1.220'
pi {
host = 'photonvision.local'
user = 'pi'
password = 'raspberry'
knownHosts = allowAnyHosts
Expand Down
2 changes: 1 addition & 1 deletion photon-server/src/main/java/org/photonvision/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public static void main(String[] args) {
ConfigManager.getInstance().load(); // init config manager
ConfigManager.getInstance().requestSave();

logger.info("Loading ML models");
logger.info("Loading ML models...");
var modelManager = NeuralNetworkModelManager.getInstance();
modelManager.extractModels(ConfigManager.getInstance().getModelsDirectory());
modelManager.discoverModels(ConfigManager.getInstance().getModelsDirectory());
Expand Down
16 changes: 1 addition & 15 deletions photon-server/src/main/resources/web/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="./favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Photon Client</title>
<script type="module" crossorigin src="./assets/index-206c1fe7.js"></script>
<link rel="stylesheet" href="./assets/index-69a5f457.css">
</head>
<body>
<div id="app"></div>

</body>
</html>
<p>UI has not been copied!</p>

0 comments on commit 865f829

Please sign in to comment.