Change SBC to Jetson Orin

This commit is contained in:
2025-02-25 07:35:38 +07:00
parent 21e8ab1e82
commit ce5c8d5946
16 changed files with 1057 additions and 80 deletions

View File

@@ -9,6 +9,7 @@ import lombok.Getter;
import lombok.Setter;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.opencv.opencv_core.Mat;
import org.tinylog.Logger;
public class GrabbingTask implements Runnable {
@@ -23,6 +24,8 @@ public class GrabbingTask implements Runnable {
@Setter private Consumer<Frame> onLQFrameUpdate;
@Setter private Consumer<String> onHQBase64Update;
@Setter private Consumer<String> onLQBase64Update;
@Setter private Consumer<Frame> onYoloUpdate;
@Setter private Consumer<String> onYoloBase64Update;
// status of capture fps
@Getter private int CaptureFPS = 0;
@@ -33,6 +36,8 @@ public class GrabbingTask implements Runnable {
// for FPS calculation
private int intendedFps = 10;
private final YoloDetector yolo;
@SuppressWarnings("SameParameterValue")
private void updateMessage(String message) {
if (onMessageUpdate != null) {
@@ -40,9 +45,17 @@ public class GrabbingTask implements Runnable {
}
}
private void updateYoloBase64(String base64) {
if (onYoloBase64Update != null) {
onYoloBase64Update.accept(base64);
}
}
private void updateYoloFrame(Frame frame) {
if (onYoloUpdate != null) {
onYoloUpdate.accept(frame);
}
}
private void updateHQBase64(String base64) {
if (onHQBase64Update != null) {
@@ -77,6 +90,7 @@ public class GrabbingTask implements Runnable {
this.isGrabbing = isGrabbing;
this.grabber = grabber;
if (fps>0) intendedFps = fps;
yolo = new YoloDetector();
}
@@ -94,6 +108,23 @@ public class GrabbingTask implements Runnable {
} else updateMessage("processFrame have null frame");
}
//TODO masih trouble di sini
private void DetectYolo(Frame frame){
if (frame!=null){
try{
Mat processed = yolo.Detect(frame);
Frame yoloFrame = SomeCodes.CoreMatConverter.convert(processed);
updateYoloFrame(yoloFrame);
updateYoloBase64(SomeCodes.FrameToBase64(yoloFrame));
} catch (Exception e){
System.out.println("error processing YOLO, Message : "+e.getMessage());
updateYoloFrame(null);
updateYoloBase64("");
}
}
}
private void flush_grabber(){
try {
if (grabber!=null) grabber.flush();
@@ -117,9 +148,13 @@ public class GrabbingTask implements Runnable {
Thread.yield();
Frame frame = grabber.grab();
if (framecount<Integer.MAX_VALUE) framecount++; else framecount = 0;
if (framecount % skippedframes == 0) processFrame(frame);
if (framecount % skippedframes == 0) {
processFrame(frame);
DetectYolo(frame);
}
} catch (Exception e){
Logger.error("Error grabbing frame: "+e.getMessage());
}
long elapsed = System.currentTimeMillis() - starttick;