新增模型
This commit is contained in:
27
ruoyi-video/src/main/java/com/ruoyi/video/utils/Overlay.java
Normal file
27
ruoyi-video/src/main/java/com/ruoyi/video/utils/Overlay.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.video.utils;
|
||||
|
||||
import com.ruoyi.video.domain.Detection;
|
||||
import org.bytedeco.opencv.opencv_core.*;
|
||||
import static org.bytedeco.opencv.global.opencv_imgproc.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class Overlay {
|
||||
private Overlay(){}
|
||||
|
||||
public static void draw(List<Detection> dets, Mat frame) {
|
||||
for (Detection d : dets) {
|
||||
Rect r = d.box();
|
||||
int bgr = d.colorBGR();
|
||||
Scalar c = new Scalar(bgr & 0xFF, (bgr >> 8) & 0xFF, (bgr >> 16) & 0xFF, 0);
|
||||
rectangle(frame, r, c, 2, LINE_8, 0);
|
||||
String label = d.cls()+" "+String.format("%.2f", d.conf());
|
||||
int[] baseline = new int[1];
|
||||
Size t = getTextSize(label, FONT_HERSHEY_SIMPLEX, 0.5, 1, baseline);
|
||||
int x = Math.max(0, r.x());
|
||||
int y = Math.max(t.height(), r.y()-4);
|
||||
rectangle(frame, new Rect(x, y-t.height()-4, t.width()+6, t.height()+6), c, FILLED, 0, 0);
|
||||
putText(frame, label, new Point(x+3, y), FONT_HERSHEY_SIMPLEX, 0.5, new Scalar(0,0,0,0), 1, LINE_AA, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user