Patch 04/03/2025

This commit is contained in:
2025-03-04 12:25:02 +07:00
parent e1d129fa07
commit 123a89eec9
6 changed files with 67 additions and 18 deletions

View File

@@ -6,7 +6,7 @@ AudioFile04=
AudioFile05=null AudioFile05=null
AudioVolumeOutput=100 AudioVolumeOutput=100
Camera_Rtsp_path=/axis-media/media.amp Camera_Rtsp_path=/axis-media/media.amp
Camera_ip=192.168.10.17 Camera_ip=172.17.195.51
Camera_password=password Camera_password=password
Camera_port=80 Camera_port=80
Camera_user=root Camera_user=root

View File

@@ -20,6 +20,8 @@
<artifactId>javacv</artifactId> <artifactId>javacv</artifactId>
<version>1.5.11</version> <version>1.5.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bytedeco</groupId> <groupId>org.bytedeco</groupId>
<artifactId>opencv</artifactId> <artifactId>opencv</artifactId>
@@ -68,9 +70,9 @@
<groupId>org.bytedeco</groupId> <groupId>org.bytedeco</groupId>
<artifactId>cuda</artifactId> <artifactId>cuda</artifactId>
<version>12.6-9.5-1.5.11</version> <version>12.6-9.5-1.5.11</version>
<classifier>linux-arm64</classifier>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bytedeco</groupId> <groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId> <artifactId>javacpp</artifactId>

View File

@@ -37,9 +37,11 @@ public class YoloDetector {
if (SomeCodes.ValidFile(onnxfile)){ if (SomeCodes.ValidFile(onnxfile)){
if (SomeCodes.ValidFile(namesfile)){ if (SomeCodes.ValidFile(namesfile)){
net = Dnn.readNetFromONNX(onnxfile); net = Dnn.readNetFromONNX(onnxfile);
net.setPreferableBackend(Dnn.DNN_BACKEND_OPENCV); net.setPreferableBackend(Dnn.DNN_BACKEND_CUDA);
net.setPreferableTarget(Dnn.DNN_TARGET_CUDA);
//net.setPreferableBackend(Dnn.DNN_BACKEND_OPENCV);
//net.setPreferableBackend(Dnn.DNN_BACKEND_INFERENCE_ENGINE); //net.setPreferableBackend(Dnn.DNN_BACKEND_INFERENCE_ENGINE);
net.setPreferableTarget(Dnn.DNN_TARGET_CPU); //net.setPreferableTarget(Dnn.DNN_TARGET_CPU);
//net.setPreferableTarget(Dnn.DNN_TARGET_NPU); //net.setPreferableTarget(Dnn.DNN_TARGET_NPU);
classes = new ArrayList<>(); classes = new ArrayList<>();

View File

@@ -1,6 +1,7 @@
package Other; package Other;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.sun.jna.Platform;
import org.bytedeco.javacpp.Loader; import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacv.Frame; import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.OpenCVFrameConverter; import org.bytedeco.javacv.OpenCVFrameConverter;
@@ -21,7 +22,14 @@ import java.util.Properties;
public class SomeCodes { public class SomeCodes {
static{ static{
Loader.load(opencv_java.class); //Loader.load(opencv_java.class);
if (Platform.isLinux()){
File ff = new File("/usr/local/lib/libopencv_java4100.so");
if (ff.isFile()){
Logger.info("Loading opencv_java 4.10.0 with cuda from /usr/local/lib");
System.load(ff.getAbsolutePath());
} else Logger.info("library opencv_java with cuda not found, loading standard opencv");
} else Logger.info("Platform is not Linux, loading standard opencv");
} }
public final static String currentDirectory = System.getProperty("user.dir"); public final static String currentDirectory = System.getProperty("user.dir");

View File

@@ -272,9 +272,11 @@ public class WebServer {
socketIOClients.forEach((key, client) -> client.disconnect()); socketIOClients.forEach((key, client) -> client.disconnect());
socketIOClients.clear(); socketIOClients.clear();
socketServer.stop(); socketServer.stop();
Logger.info("SocketIO server stopped"); Logger.info("SocketIO server stopped");
} catch (JavalinException e){ } catch (JavalinException e){
Logger.error("Web server failed to stop: {}", e.getMessage()); Logger.error("Web server failed to stop: {}", e.getMessage());
e.printStackTrace();
} }
} }

View File

@@ -32,7 +32,7 @@ public class Main {
private static WebServer webServer; private static WebServer webServer;
//change parameter ini untuk menggunakan Yolo atau tidak //change parameter ini untuk menggunakan Yolo atau tidak
private static final boolean use_Yolo = true; private static final boolean use_Yolo = false;
private static RtspGrabber rtspGrabber; private static RtspGrabber rtspGrabber;
private static PanTiltController panTiltController; private static PanTiltController panTiltController;
@@ -54,22 +54,48 @@ public class Main {
private static ExecutorService gpioExecutor = null; private static ExecutorService gpioExecutor = null;
private static PCF8574 pcf8574 = null; private static PCF8574 pcf8574 = null;
private static final String Version = "V1.0 (04/03/2025)";
// Application start from here // Application start from here
public static void main(String[] args) { public static void main(String[] args) {
System.setProperty("jna.debug_load", "false"); System.setProperty("jna.debug_load", "false");
System.out.println("BirdStrikeSoetta "+Version);
Runtime.getRuntime().addShutdownHook(new Thread(() -> { Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (use_multiusb_audio) { if (use_multiusb_audio) {
if (multiUSBAudioPlayer != null) multiUSBAudioPlayer.Unload(); if (multiUSBAudioPlayer != null) {
} else { multiUSBAudioPlayer.Unload();
if (audioPlayer != null) audioPlayer.Unload(); Logger.info("MultiUSB Audio Unloaded");
}
} else {
if (audioPlayer != null) {
audioPlayer.Unload();
Logger.info("Audio Unloaded");
}
}
if (webServer!=null) {
webServer.Stop();
Logger.info("Web Server stopped");
}
if (rtspGrabber!=null) {
rtspGrabber.Stop();
Logger.info("Rtsp Grabber stopped");
}
if (panTiltController!=null) {
panTiltController.Close();
Logger.info("Pan Tilt Controller closed");
}
if (vapixProtocol!=null) {
vapixProtocol.Close();
Logger.info("Vapix Protocol closed");
}
if (timer!=null) {
timer.cancel();
Logger.info("Timer cancelled");
}
if (gpioExecutor!=null) {
gpioExecutor.shutdown();
Logger.info("GPIO Executor shutdown");
} }
if (webServer!=null) webServer.Stop();
if (rtspGrabber!=null) rtspGrabber.Stop();
if (panTiltController!=null) panTiltController.Close();
if (vapixProtocol!=null) vapixProtocol.Close();
if (timer!=null) timer.cancel();
if (gpioExecutor!=null) gpioExecutor.shutdown();
if (AmplifierPower!=null) { if (AmplifierPower!=null) {
Logger.info("GPIO pin {} unexport : {}",AmplifierPower.pin, GPIO.UnexportPin(AmplifierPower)); Logger.info("GPIO pin {} unexport : {}",AmplifierPower.pin, GPIO.UnexportPin(AmplifierPower));
} }
@@ -87,6 +113,7 @@ public class Main {
} }
if (pcf8574!=null){ if (pcf8574!=null){
pcf8574.Close(); pcf8574.Close();
Logger.info("PCF8574 closed");
} }
Logger.info("Application Stopped"); Logger.info("Application Stopped");
@@ -467,15 +494,23 @@ public class Main {
Properties config = SomeCodes.LoadProperties("config.properties"); Properties config = SomeCodes.LoadProperties("config.properties");
String targetip = config.getProperty("Camera_ip"); String targetip = config.getProperty("Camera_ip");
String rtsppath = config.getProperty("Camera_Rtsp_path"); String rtsppath = config.getProperty("Camera_Rtsp_path");
Logger.info("Camera IP : "+targetip); int width = 1920;
Logger.info("Camera Rtsp Path : "+rtsppath); int height = 1080;
// TODO test pakai sony camera, nanti hapus
targetip = "172.17.195.51";
rtsppath = "/video1";
width = 1280;
height = 720;
Logger.info("Camera IP: {}, Rtsp Path: {}, Width: {}, Height: {}", targetip, rtsppath, width,height);
rtspGrabber = null; rtspGrabber = null;
if (ValidString(targetip)){ if (ValidString(targetip)){
if (ValidString(rtsppath)){ if (ValidString(rtsppath)){
if (IpIsReachable(targetip)){ if (IpIsReachable(targetip)){
Logger.info("Camera IP : "+targetip+" is reachable"); Logger.info("Camera IP : "+targetip+" is reachable");
rtspGrabber = new RtspGrabber(targetip, rtsppath, use_Yolo); rtspGrabber = new RtspGrabber(targetip, rtsppath, use_Yolo);
rtspGrabber.Start(true, 1920, 1080); rtspGrabber.Start(true, width, height);
} else Logger.warn("Camera IP : "+targetip+" is not reachable"); } else Logger.warn("Camera IP : "+targetip+" is not reachable");
} else Logger.warn("Camera Path : "+rtsppath+" is not valid string"); } else Logger.warn("Camera Path : "+rtsppath+" is not valid string");
} else Logger.warn("Camera IP : "+targetip+" is not valid string"); } else Logger.warn("Camera IP : "+targetip+" is not valid string");