Compare commits

...

2 Commits

Author SHA1 Message Date
7527017070 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	ruoyi-video/pom.xml
#	ruoyi-video/src/main/java/com/ruoyi/video/thread/MediaTransferFlvByJavacv.java
2025-09-27 18:59:35 +08:00
3c3f2fe25b feat(video): 添加视频分析配置和RTSP服务器启动脚本
- 在application.yml中添加视频分析相关配置项,包括AI检测开关、RTSP连接参数
- 新增detection-config.json模型配置文件,支持YOLO目标检测模型
- 优化RTSP流媒体传输配置,添加TCP/UDP传输协议支持和超时重试机制
-修复模型配置文件路径问题,从/resources/models/调整为/libs/models/
- 更新JavaCV和OpenCV依赖版本,提升视频处理性能
- 添加Windows和Linux平台的RTSP测试服务器启动脚本
- 默认关闭AI检测功能,避免启动时出现错误- 增强RTSP连接稳定性,添加更多兼容性选项
2025-09-27 18:52:40 +08:00
7 changed files with 95 additions and 5 deletions

20
bin/start-rtsp-server.bat Normal file
View File

@@ -0,0 +1,20 @@
@echo off
echo 启动RTSP测试服务器...
echo.
echo 请确保已安装FFmpeg
echo.
REM 使用FFmpeg创建一个简单的RTSP服务器
REM 这里使用测试视频文件,你可以替换为实际的视频文件路径
set VIDEO_FILE=test.mp4
REM 如果没有测试视频,创建一个测试模式
if not exist "%VIDEO_FILE%" (
echo 创建测试视频流...
ffmpeg -f lavfi -i testsrc=duration=3600:size=640x480:rate=25 -f rtsp rtsp://localhost:8554/11
) else (
echo 使用视频文件: %VIDEO_FILE%
ffmpeg -re -i "%VIDEO_FILE%" -c copy -f rtsp rtsp://localhost:8554/11
)
pause

24
bin/start-rtsp-server.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
echo "启动RTSP测试服务器..."
echo
# 检查FFmpeg是否安装
if ! command -v ffmpeg &> /dev/null; then
echo "错误: FFmpeg未安装请先安装FFmpeg"
echo "Ubuntu/Debian: sudo apt install ffmpeg"
echo "CentOS/RHEL: sudo yum install ffmpeg"
exit 1
fi
# 视频文件路径
VIDEO_FILE="test.mp4"
# 如果没有测试视频,创建一个测试模式
if [ ! -f "$VIDEO_FILE" ]; then
echo "创建测试视频流..."
ffmpeg -f lavfi -i testsrc=duration=3600:size=640x480:rate=25 -c:v libx264 -preset ultrafast -f rtsp rtsp://localhost:8554/11
else
echo "使用视频文件: $VIDEO_FILE"
ffmpeg -re -i "$VIDEO_FILE" -c copy -f rtsp rtsp://localhost:8554/11
fi

View File

@@ -42,7 +42,7 @@
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.9</version> <!-- 版本号需与项目兼容 -->
<version>1.5.10</version> <!-- 版本号需与项目兼容 -->
</dependency>
<!-- SpringBoot的依赖配置-->
<dependency>

View File

@@ -63,9 +63,8 @@
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.9</version> <!-- 版本号需与项目兼容 -->
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>

View File

@@ -152,3 +152,17 @@ mediasServer:
arcFace:
appId: '替换成你的appId'
sdkKey: '替换成你的sdkKey'
# 视频分析配置
video:
# 是否启用AI检测功能
detection:
enabled: false
# RTSP配置
rtsp:
# 连接超时时间(微秒)
timeout: 10000000
# 传输协议 tcp/udp
transport: tcp
# 重试次数
retryCount: 3

View File

@@ -181,7 +181,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
// 初始化模型管理器
if (modelManager == null) {
modelManager = new ModelManager();
URL json = getClass().getResource("/models/models.json");
URL json = getClass().getResource("/libs/models/models.json");
if (json != null) {
modelManager.load(json);
}

View File

@@ -0,0 +1,33 @@
{
"models": [
{
"name": "yolo",
"type": "object_detection",
"modelPath": "models/yolo.onnx",
"configPath": "models/yolo.cfg",
"weightsPath": "models/yolo.weights",
"classNames": [
"person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck",
"boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench",
"bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra",
"giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove",
"skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup",
"fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange",
"broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "sofa",
"pottedplant", "bed", "diningtable", "toilet", "tvmonitor", "laptop", "mouse",
"remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink",
"refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier",
"toothbrush"
],
"inputSize": {
"width": 640,
"height": 640
},
"threshold": 0.5,
"nmsThreshold": 0.4
}
],
"enabled": true,
"defaultModel": "yolo"
}