Files
2026-02-01 22:23:06 +08:00

336 lines
9.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--
* @Date: 2024-09-06 11:59:14
* @LastEditors: Jacky
* @LastEditTime: 2024-09-10 10:22:30
* @FilePath: /GeneralTracker/Universal/REDEME.md
-->
# 跟踪器框架
为实现跟踪器的通用框架,媒体业务层不涉及任何与平台相关调用。只负责维护模块之间的绑定关系及数据传递,达到与平台解耦。通过调用统一的接口来与硬件进行交互。
## 1、模块划分
应用软件可分为管理模块和业务模块其中管理模块包括通信模块、配置管理模块、日志模块、buffer模块、web服务模块业务模块指各图像处理模块主要定义了采集输入、输出、图像处理、编码、解码、信息叠加、录像和算法8个模块。结构如下图
![框架结构图](./general.png)
### 1.1 管理模块
- 配置管理模块: 主要负责各级配置文件的解析。
- buffer模块定义一个通用的图像数据模版由系统决定内存的申请方式。并管理图像所携带的附加信息如算法结果等
- 通信模块负责跟踪器对外协议以及转换内部协议。内部协议定为json格式需要将其他协议转换成内部json格式并下发给业务模块。
### 1.2 业务模块
业务模块定义了主框架中的几个模块,各个模块调用模块统一的接口。以采集输入举例描述平台适配:
1、定义图像采集的统一接口各个平台实现该接口如PCIE等。
2、在编译选项中指定当前平台编译规则添加该平台的采集实现接口进行编译。
3、采集模块中调用通用采集接口获取图像并推送到下一级。
## 2、配置说明
### 2.1 配置文件
* 1、所有json配置文件均为小写。
##### 1、模块配置
**media.json**
在框架中定义了8个模块模块定义如下
| 模块名 | 功能 |
| :---- | :----|
| vi | 采集输入主要是硬件输入pcie、sensor等 |
| vdec | 解码输入: 可以是网络流、文件 |
| vpss | 图像处理:裁剪、缩放、旋转等(优先使用硬件进行处理) |
| vo | 图像输出主要只硬件输出mipi、bt1120等 |
| arith | 算法模块:跟踪算法在主框架中,其他算法不往后推流 |
| venc | 编码模块:视频编码输出 |
| osd | 图像叠加:叠跟踪、识别框,叠文字 |
| record | 录像模块:视频存储 |
各个变量的定义如下:
| 变量名 | 变量说明 |
| :---- | :----|
| enable | 模块使能 |
| name | 模块名称 |
| message | 是否处理消息 |
| bind | 下级绑定 |
```json
{
"vi": [
{
"enable": false,
"message" : true,
"name" : "vi1",
"bind" : [
"vpss"
]
},
{
"enable": false,
"message" : true,
"name" : "vi2",
"bind" : [
"venc2"
]
}
],
"vdec":{
"enable": true,
"message" : true,
"name" : "vi3",
"bind" : [
"vpss"
]
},
"vpss" : {
"enable": true,
"name" : "vpss",
"message" : true,
"bind" : [
"arith"
]
},
"vo": {
"enable": true,
"name" : "vo",
"message" : true
},
"osd": {
"enable": true,
"name" : "osd",
"message" : true,
"bind" : [
"venc1",
"vo"
]
},
"venc": [
{
"enable": true,
"name" : "venc1",
"message" : true,
"bind" : [
"record"
]
},
{
"enable": true,
"name" : "venc2",
"message" : true,
"bind" : [
]
},
{
"enable": false,
"name" : "venc3",
"message" : true,
"bind" : [
]
}
],
"arith": [
{
"enable": true,
"name" : "track",
"message" : true,
"bind" : [
"osd"
]
},
{
"enable": false,
"name" : "detect",
"message" : true
}
],
"record": {
"enable": true,
"name" : "record1",
"message" : true
}
}
```
```shell
#上面配置文件的具体绑定关系如下:
create: track, 0x555f93d0cea0
create: detect, 0x555f93d0d0e0
create: osd, 0x555f93d0d650
create: vi3, 0x555f93d0db60
create: venc1, 0x555f93d0e400
create: venc2, 0x555f93d0eb60
create: vo, 0x555f93d0f400
create: vpss, 0x555f93d0f800
linkV: osd ---> venc1 (0x555f93d0d650 ---> 0x555f93d0e400)
linkV: osd ---> vo (0x555f93d0d650 ---> 0x555f93d0f400)
linkV: track ---> osd (0x555f93d0cea0 ---> 0x555f93d0d650)
linkV: vi3 ---> vpss (0x555f93d0db60 ---> 0x555f93d0f800)
linkV: vpss ---> detect (0x555f93d0f800 ---> 0x555f93d0d0e0)
linkV: vpss ---> track (0x555f93d0f800 ---> 0x555f93d0cea0)
```
提示bind列表如果是上述8个模块的名字则表示绑定模块下所有子模块。特指算法模块
##### 2、采集配置
模块配置中定义了输入模块,根据输入模块的名字,匹配对应的采集配置
**capture.json**定义了所有采集通道的信息
各个变量的定义如下:
| 变量名 | 变量说明 |
| :---- | :----|
| chn | 显示通道:框架层次的通道定义,**不能相同** |
| vi_chn | 采集通道:适配层的通道定义,是硬件层的采集通道 |
| width | 采集宽度 |
| height | 采集高度 |
| in_frame | 采集帧率 |
| out_frame | 输出帧率(是否抽帧处理) |
| url | 采集url(主要是解码模块使用) |
```json
{
"vi2" :{
"chn" : 0,
"vi_chn": 1,
"type" : "y16y8",
"width" :1280,
"height":1024,
"in_frame": 50
},
"vi1" :{
"chn" : 1,
"vi_chn": 0,
"type" : "y16y8",
"width" :1280,
"height":1024,
"in_frame": 50
},
"vi3" :{
"chn" : 2,
"type" : "yuv",
"width" :1920,
"height":1080,
"out_frame":50,
"url" : "./car_around.avi"
}
}
```
根据上述采集配置结合模块配置知道当前输入模块是v13是解码输入。
##### 3、编码输出配置
编码配置流与模块配置中的venc进行匹配
各个变量的定义如下:
| 变量名 | 变量说明 |
| :---- | :----|
| width | 编码宽度 |
| height | 编码高度 |
| fps | 编码帧率 |
| bitrate | 比特率 |
|||
| ts | ts打包数据流 |
| rtsp | rtsp数据流 |
| websocket| ws数据流(web使用) |
| udp | 私有组播流 |
| record | 录像流 |
|||
| enable | 使能 |
| dst | 目的地址 |
| port | 端口 |
```json
{
"venc1" :{
"width" : 1280,
"height" :1024,
"fps" : 25,
"bitrate" : 2048000,
"ts":{
"enable" : true,
"dst" : "udp://127.0.0.1:50003"
},
"rtsp" : {
"enable" : true,
"port": 8550,
"dst" : "streanchn0"
},
"websocket":{
"enable": true,
"port" : 8081
}
},
"venc2":{
"rtsp" : {
"enable" : true,
"port": 8550,
"dst" : "streanchn1"
},
"websocket":{
"enable": true,
"port" : 8082
}
}
}
```
## 3、类图
框架类结构图:
```mermaid
classDiagram
CMediaManager *-- DataProcessBase
DataProcessBase <|-- CModuleVi
DataProcessBase <|-- CModuleVdec
DataProcessBase <|-- CModuleVo
DataProcessBase <|-- CModuleVpss
DataProcessBase <|-- CModuleVenc
DataProcessBase <|-- CModuleOsd
DataProcessBase <|-- CModuleArith
DataProcessBase <|-- CModuleRecord
CModuleVenc *-- IStreamConfig
CMediaManager *-- IConfiguration
CModuleVi *-- ICaptureConfig
DataProcessBase *-- IMemoryQueue
DataProcessBase: +create()*
DataProcessBase: +set_data()*
DataProcessBase: +get_data()*
DataProcessBase: +start()*
DataProcessBase: +stop()*
DataProcessBase: +linkV()*
DataProcessBase: +unLinkV()*
DataProcessBase: +push_input_pipe()
DataProcessBase: +notify()
CModuleArith o-- ArithService
ArithService <|-- ArithTracker
ArithService <|-- ArithDetect
class ArithService{
+arithInit()*
+arithDeinit()*
+arithRun()*
}
CModuleVenc o-- CStreamOut
CStreamOut <|-- IStreamRtsp
CStreamOut <|-- IStreamTs
CStreamOut <|-- IStreamWebsocket
CStreamOut <|-- IStreamUdp
class CStreamOut{
+start()*
+stop()*
+sendData()*
}
IMemoryPool o-- IMemoryBlock
IMemoryPool : +dequeue()
IMemoryPool : +queue()
IMemoryQueue o-- IMemoryBlock
IMemoryQueue : +getFrame()
IMemoryQueue : +sendFrame()
IMemoryQueue : +releaseFrame()
class AdditionalImp{
+additionParam()
+data()
+ptr()
}
IMemoryBlock o-- AdditionalImp
```