From 53c7647f81575c614cd1a945555c3a37ed338e24 Mon Sep 17 00:00:00 2001 From: Alextopher Date: Thu, 19 Sep 2024 03:03:47 -0400 Subject: [PATCH] add licenses and fix formatting --- photon-client/src/App.vue | 1 - .../dashboard/tabs/ObjectDetectionTab.vue | 6 ++-- photon-client/src/types/PipelineTypes.ts | 2 +- .../NeuralNetworkModelManager.java | 11 +++---- .../photonvision/jni/RknnObjectDetector.java | 17 +++++++++++ .../vision/objects/Letterbox.java | 17 +++++++++++ .../photonvision/vision/objects/Model.java | 17 +++++++++++ .../vision/objects/NullModel.java | 17 +++++++++++ .../vision/objects/ObjectDetector.java | 30 +++++++++++++++++-- .../vision/objects/RknnModel.java | 17 +++++++++++ .../vision/pipe/impl/ObjectDetectionPipe.java | 1 - .../pipeline/ObjectDetectionPipeline.java | 5 ++-- .../ObjectDetectionPipelineSettings.java | 3 +- photon-server/build.gradle | 4 +-- .../src/main/java/org/photonvision/Main.java | 2 +- .../src/main/resources/web/index.html | 16 +--------- 16 files changed, 128 insertions(+), 38 deletions(-) diff --git a/photon-client/src/App.vue b/photon-client/src/App.vue index d98300bd7f..518ad39833 100644 --- a/photon-client/src/App.vue +++ b/photon-client/src/App.vue @@ -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) { diff --git a/photon-client/src/components/dashboard/tabs/ObjectDetectionTab.vue b/photon-client/src/components/dashboard/tabs/ObjectDetectionTab.vue index a249273cf3..5128f1db44 100644 --- a/photon-client/src/components/dashboard/tabs/ObjectDetectionTab.vue +++ b/photon-client/src/components/dashboard/tabs/ObjectDetectionTab.vue @@ -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); + } }); diff --git a/photon-client/src/types/PipelineTypes.ts b/photon-client/src/types/PipelineTypes.ts index 5f609c5005..7223f3ffcb 100644 --- a/photon-client/src/types/PipelineTypes.ts +++ b/photon-client/src/types/PipelineTypes.ts @@ -306,7 +306,7 @@ export const DefaultObjectDetectionPipelineSettings: ObjectDetectionPipelineSett confidence: 0.9, nms: 0.45, box_thresh: 0.25, - model: "", + model: "" }; export type ActivePipelineSettings = diff --git a/photon-core/src/main/java/org/photonvision/common/configuration/NeuralNetworkModelManager.java b/photon-core/src/main/java/org/photonvision/common/configuration/NeuralNetworkModelManager.java index f4de07f991..f6ba9a18f8 100644 --- a/photon-core/src/main/java/org/photonvision/common/configuration/NeuralNetworkModelManager.java +++ b/photon-core/src/main/java/org/photonvision/common/configuration/NeuralNetworkModelManager.java @@ -164,11 +164,7 @@ public Optional getModel(String modelName) { return Optional.empty(); } - /** - * The default model when no model is specified. - * - * @param model - */ + /** The default model when no model is specified. */ public Optional getDefaultModel() { if (models == null) { return Optional.empty(); @@ -210,8 +206,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; diff --git a/photon-core/src/main/java/org/photonvision/jni/RknnObjectDetector.java b/photon-core/src/main/java/org/photonvision/jni/RknnObjectDetector.java index b11699074a..34d09eb04a 100644 --- a/photon-core/src/main/java/org/photonvision/jni/RknnObjectDetector.java +++ b/photon-core/src/main/java/org/photonvision/jni/RknnObjectDetector.java @@ -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 . + */ + package org.photonvision.jni; import java.awt.Color; diff --git a/photon-core/src/main/java/org/photonvision/vision/objects/Letterbox.java b/photon-core/src/main/java/org/photonvision/vision/objects/Letterbox.java index 1ba88f883f..bbbae5269e 100644 --- a/photon-core/src/main/java/org/photonvision/vision/objects/Letterbox.java +++ b/photon-core/src/main/java/org/photonvision/vision/objects/Letterbox.java @@ -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 . + */ + package org.photonvision.vision.objects; import java.util.ArrayList; diff --git a/photon-core/src/main/java/org/photonvision/vision/objects/Model.java b/photon-core/src/main/java/org/photonvision/vision/objects/Model.java index 283aed0a44..a634898fd4 100644 --- a/photon-core/src/main/java/org/photonvision/vision/objects/Model.java +++ b/photon-core/src/main/java/org/photonvision/vision/objects/Model.java @@ -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 . + */ + package org.photonvision.vision.objects; public interface Model { diff --git a/photon-core/src/main/java/org/photonvision/vision/objects/NullModel.java b/photon-core/src/main/java/org/photonvision/vision/objects/NullModel.java index 850f218158..e3ecf42ef6 100644 --- a/photon-core/src/main/java/org/photonvision/vision/objects/NullModel.java +++ b/photon-core/src/main/java/org/photonvision/vision/objects/NullModel.java @@ -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 . + */ + package org.photonvision.vision.objects; import java.util.List; diff --git a/photon-core/src/main/java/org/photonvision/vision/objects/ObjectDetector.java b/photon-core/src/main/java/org/photonvision/vision/objects/ObjectDetector.java index cb4b6f24e3..1dacb00e77 100644 --- a/photon-core/src/main/java/org/photonvision/vision/objects/ObjectDetector.java +++ b/photon-core/src/main/java/org/photonvision/vision/objects/ObjectDetector.java @@ -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 . + */ + package org.photonvision.vision.objects; import java.util.List; @@ -7,9 +24,16 @@ 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: + * + *
    + *
  1. {@link Model}s are discovered by {@link NeuralNetworkModelManager} + *
  2. {@link Model} is selected as a parameter of {@link + * org.photonvision.vision.pipe.impl.ObjectDetectionPipe ObjectDetectionPipe} + *
  3. {@link Model#load()} is called to create a ObjectDetector instance + *
  4. {@link ObjectDetector#detect(Mat, double, double)} is called to perform object detection + *
  5. {@link ObjectDetector#release()} is called to release resources + *
*/ public interface ObjectDetector extends Releasable { /** Returns the model that created this ObjectDetector. */ diff --git a/photon-core/src/main/java/org/photonvision/vision/objects/RknnModel.java b/photon-core/src/main/java/org/photonvision/vision/objects/RknnModel.java index 160a445a15..921b507948 100644 --- a/photon-core/src/main/java/org/photonvision/vision/objects/RknnModel.java +++ b/photon-core/src/main/java/org/photonvision/vision/objects/RknnModel.java @@ -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 . + */ + package org.photonvision.vision.objects; import java.io.File; diff --git a/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ObjectDetectionPipe.java b/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ObjectDetectionPipe.java index f6ae7de602..fad36a5b8d 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ObjectDetectionPipe.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ObjectDetectionPipe.java @@ -32,7 +32,6 @@ public class ObjectDetectionPipe extends CVPipe< CVMat, List, ObjectDetectionPipe.ObjectDetectionPipeParams> implements Releasable { - private ObjectDetector detector; public ObjectDetectionPipe() { diff --git a/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipeline.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipeline.java index cac5b04827..684fdd0247 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipeline.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipeline.java @@ -59,17 +59,16 @@ protected void setPipeParamsImpl() { var params = new ObjectDetectionPipeParams(); params.confidence = settings.confidence; params.nms = settings.nms; - Optional selectedModel = NeuralNetworkModelManager.getInstance().getModel(settings.model); + Optional 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()); } diff --git a/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipelineSettings.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipelineSettings.java index 27d7daa803..ba1fcaf646 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipelineSettings.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/ObjectDetectionPipelineSettings.java @@ -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(""); } } diff --git a/photon-server/build.gradle b/photon-server/build.gradle index d84b1111bd..7c8c2ba078 100644 --- a/photon-server/build.gradle +++ b/photon-server/build.gradle @@ -62,8 +62,8 @@ run { } remotes { - home { - host = '192.168.1.220' + pi { + host = 'photonvision.local' user = 'pi' password = 'raspberry' knownHosts = allowAnyHosts diff --git a/photon-server/src/main/java/org/photonvision/Main.java b/photon-server/src/main/java/org/photonvision/Main.java index 889be73dbe..4330cefc00 100644 --- a/photon-server/src/main/java/org/photonvision/Main.java +++ b/photon-server/src/main/java/org/photonvision/Main.java @@ -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()); diff --git a/photon-server/src/main/resources/web/index.html b/photon-server/src/main/resources/web/index.html index 3d1379c9fb..988f55e6a3 100644 --- a/photon-server/src/main/resources/web/index.html +++ b/photon-server/src/main/resources/web/index.html @@ -1,15 +1 @@ - - - - - - - Photon Client - - - - -
- - - +

UI has not been copied!