From 37cfcc9eda17de3b8da8c4c725eadd4ef38d90cd Mon Sep 17 00:00:00 2001 From: xu Date: Wed, 4 Dec 2024 15:58:32 +0800 Subject: [PATCH 1/2] MultiChannelVideoDetection case --- .../MultiChannelVideoDetection/CMakeLists.txt | 3 - .../ImageResizer/ImageResizer.cpp | 14 -- contrib/MultiChannelVideoDetection/README.md | 219 +++++------------- .../YoloDetector/YoloDetector.cpp | 9 +- .../YoloDetector/YoloDetector.h | 2 +- contrib/MultiChannelVideoDetection/main.cpp | 15 +- contrib/MultiChannelVideoDetection/run.sh | 8 - 7 files changed, 67 insertions(+), 203 deletions(-) diff --git a/contrib/MultiChannelVideoDetection/CMakeLists.txt b/contrib/MultiChannelVideoDetection/CMakeLists.txt index cba6922f7..fd0a9bab3 100644 --- a/contrib/MultiChannelVideoDetection/CMakeLists.txt +++ b/contrib/MultiChannelVideoDetection/CMakeLists.txt @@ -8,7 +8,6 @@ set(OUTPUT_NAME "multiChannelVideoReasoner") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/") set(MX_SDK_HOME "$ENV{MX_SDK_HOME}") -set(FFMPEG_HOME {ffmpeg实际安装路径}) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} @@ -16,7 +15,6 @@ include_directories( ${MX_SDK_HOME}/opensource/include ${MX_SDK_HOME}/opensource/include/opencv4 ${MX_SDK_HOME}/include/MxBase/postprocess/include - ${FFMPEG_HOME}/include #该处为ascend-toolkit的实际安装位置,默认为/usr/local下指向对应架构include的软连接 /usr/local/Ascend/ascend-toolkit/latest/include ) @@ -25,7 +23,6 @@ link_directories( ${MX_SDK_HOME}/lib ${MX_SDK_HOME}/opensource/lib ${MX_SDK_HOME}/lib/modelpostprocessors - ${FFMPEG_HOME}/lib ) add_executable(${OUTPUT_NAME} main.cpp diff --git a/contrib/MultiChannelVideoDetection/ImageResizer/ImageResizer.cpp b/contrib/MultiChannelVideoDetection/ImageResizer/ImageResizer.cpp index 84c3e7219..815a010aa 100644 --- a/contrib/MultiChannelVideoDetection/ImageResizer/ImageResizer.cpp +++ b/contrib/MultiChannelVideoDetection/ImageResizer/ImageResizer.cpp @@ -30,12 +30,6 @@ APP_ERROR ImageResizer::Init(uint32_t deviceId) // init DvppWrapper vDvppWrapper = std::make_shared(); - APP_ERROR ret = vDvppWrapper->Init(); - if (ret != APP_ERR_OK) { - LogError << "DvppWrapper init failed, ret = " << ret << "."; - return ret; - } - LogInfo << "ImageResizer init successful."; return APP_ERR_OK; } @@ -46,14 +40,6 @@ APP_ERROR ImageResizer::Init(uint32_t deviceId) */ APP_ERROR ImageResizer::DeInit() { - LogInfo << "ImageResizer deinit start."; - - APP_ERROR ret = vDvppWrapper->DeInit(); - if (ret != APP_ERR_OK) { - LogError << "DvppWrapper deinit failed."; - return ret; - } - LogInfo << "ImageResizer deinit successful."; return APP_ERR_OK; } diff --git a/contrib/MultiChannelVideoDetection/README.md b/contrib/MultiChannelVideoDetection/README.md index fbe7882b7..f1fc3c04a 100644 --- a/contrib/MultiChannelVideoDetection/README.md +++ b/contrib/MultiChannelVideoDetection/README.md @@ -1,17 +1,39 @@ -# 基于MxBase的多路视频检测 +# MxBase多路视频目标检测 -## 介绍 +## 1 介绍 -多路视频检测,实现同时对两路本地视频或RTSP视频流(H264或H265)进行YOLOv3目标检测,生成可视化结果(可选)。 +### 1.1 简介 + +多路视频目标检测,实现同时对两路本地视频或RTSP视频流(H264)进行yolov3目标检测,生成可视化结果(可选)。 + +### 1.2 支持的产品 + +本项目支持昇腾Atlas 300I pro、 Atlas 300V pro + +### 1.3 支持的版本 + +本样例配套的MxVision版本、CANN版本、Driver/Firmware版本如下所示: + +| MxVision版本 | CANN版本 | Driver/Firmware版本 | +| --------- | ------------------ | -------------- | +| 6.0.RC3 | 8.0.RC3 | 24.1.RC3 | + +### 1.4 三方依赖 + +| 依赖软件 | 版本 | 说明 | 使用教程 | +| -------- | ---------- | ------------------------------ | ------------------------------------------------------------ | +| live555 | 1.10 | 实现视频转rstp进行推流 | [链接](https://gitee.com/ascend/mindxsdk-referenceapps/blob/master/docs/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/Live555%E7%A6%BB%E7%BA%BF%E8%A7%86%E9%A2%91%E8%BD%ACRTSP%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md) | +| ffmpeg | 4.2.1 | 实现mp4格式视频转为264格式视频 | [链接](https://gitee.com/ascend/mindxsdk-referenceapps/blob/master/docs/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/pc%E7%AB%AFffmpeg%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B.md#https://ffmpeg.org/download.html) | + +### 1.5 代码目录结构说明 -### 目录结构 ``` . |-------- BlockingQueue | |---- BlockingQueue.h // 阻塞队列 (视频帧缓存容器) -|-------- data -| |---- test_video_1.264 // 多路视频测试数据1 (本地测试自行准备) -| |---- test_video_2.264 // 多路视频测试数据2 (本地测试自行准备) +|-------- test // 需用户自己创建目录 +| |---- xxx1.264 // 多路视频测试数据1 (本地测试自行准备) +| |---- xxx2.264 // 多路视频测试数据2 (本地测试自行准备) |-------- ImageResizer | |---- ImageResizer.cpp // 图片缩放.cpp | |---- ImageResizer.h // 图片缩放.h @@ -21,7 +43,7 @@ |-------- MultiChannelVideoReasoner | |---- MultiChannelVideoReasoner.cpp // 多路视频推理业务逻辑封装.cpp | |---- MultiChannelVideoReasoner.h // 多路视频推理业务逻辑封装.h -|-------- result // 视频推理结果存放处 +|-------- result // 视频推理结果存放处,程序会自动生成 |-------- StreamPuller | |---- StreamPuller.cpp // 视频拉流.cpp | |---- StreamPuller.h // 视频拉流.h @@ -44,188 +66,55 @@ |-------- run.sh // 样例运行脚本 ``` -### 依赖 -ffmpeg 4.2.1 -SDK:mxVision 5.0.RC3(可通过cat SDK目录下的 version.info 查看) -Ascend-CANN-toolkit (310使用7.0.RC1, 310B使用6.2.RC1) - -**注意:** - -第三方库默认全部安装到/usr/local/下面,全部安装完成后,请设置环境变量 -```bash -export PATH=/usr/local/ffmpeg/bin:$PATH -export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH -``` - -#### FFmpeg -下载完,按以下命令进行解压和编译 +## 2 设置环境变量 ```bash -tar -xzvf n4.2.1.tar.gz -cd FFmpeg-n4.2.1 -./configure --prefix=/usr/local/ffmpeg --enable-shared -make -j -make install +. /usr/local/Ascend/ascend-toolkit/set_env.sh # toolkit默认安装路径,根据实际安装路径修改 +. ${SDK_INSTALL_PATH}/mxVision/set_env.sh # sdk安装路径,根据实际安装路径修改 ``` -### 准备工作 - -> 模型转换 +## 3 准备模型 -**步骤1** 下载YOLOv3模型 。[下载地址](https://mindx.sdk.obs.cn-north-4.myhuaweicloud.com/mindxsdk-referenceapps%20/contrib/ActionRecognition/ATC%20YOLOv3%28FP16%29%20from%20TensorFlow%20-%20Ascend310.zip) +**步骤1:** 下载YOLOv3模型 。[下载地址](https://mindx.sdk.obs.cn-north-4.myhuaweicloud.com/mindxsdk-referenceapps%20/contrib/ActionRecognition/ATC%20YOLOv3%28FP16%29%20from%20TensorFlow%20-%20Ascend310.zip) -**步骤2** 将获取到的YOLOv3模型pb文件存放至:"样例项目所在目录/model/"。 +**步骤2:** 将获取到的YOLOv3模型的pb文件存放至`样例项目所在目录/model/`。 -**步骤3** 模型转换 - -在pb文件所在目录下执行以下命令 +**步骤3:** 模型转换。在`样例项目所在目录/model/`目录下执行以下命令: +```bash +atc --model=./yolov3_tf.pb --framework=3 --output=./yolov3_tf_bs1_fp16 --soc_version=Ascend310P3 --insert_op_conf=./aipp_yolov3_416_416.aippconfig --input_shape="input:1,416,416,3" --out_nodes="yolov3/yolov3_head/Conv_6/BiasAdd:0;yolov3/yolov3_head/Conv_14/BiasAdd:0;yolov3/yolov3_head/Conv_22/BiasAdd:0" ``` -# 设置环境变量(请确认install_path路径是否正确) -# Set environment PATH (Please confirm that the install_path is correct). - -export install_path=/usr/local/Ascend/ascend-toolkit/latest -export PATH=/usr/local/python3.9.2/bin:${install_path}/atc/ccec_compiler/bin:${install_path}/atc/bin:$PATH -export PYTHONPATH=${install_path}/atc/python/site-packages:${install_path}/atc/python/site-packages/auto_tune.egg/auto_tune:${install_path}/atc/python/site-packages/schedule_search.egg -export LD_LIBRARY_PATH=${install_path}/atc/lib64:$LD_LIBRARY_PATH -export ASCEND_OPP_PATH=${install_path}/opp +执行完模型转换脚本后,会生成相应的`.om`模型文件。执行后若终端输出如下命令,则表示命令执行成功: -# 执行,转换YOLOv3模型 -# Execute, transform YOLOv3 model. +```bash +ATC start working now, please wait for a moment. -atc --model=./yolov3_tf.pb --framework=3 --output=./yolov3_tf_bs1_fp16 --soc_version=Ascend310 --insert_op_conf=./aipp_yolov3_416_416.aippconfig --input_shape="input:1,416,416,3" --out_nodes="yolov3/yolov3_head/Conv_6/BiasAdd:0;yolov3/yolov3_head/Conv_14/BiasAdd:0;yolov3/yolov3_head/Conv_22/BiasAdd:0" -# 说明:out_nodes制定了输出节点的顺序,需要与模型后处理适配。 -# 注意:若推理芯片为310B,需将atc-env脚本中模型转换atc命令中的soc_version参数设置为Ascend310B1。 +ATC run success, welcome to the next use. ``` -执行完模型转换脚本后,会生成相应的.om模型文件。 -模型转换使用了ATC工具,如需更多信息请参考: +## 4 编译与运行 - https://gitee.com/ascend/docs-openmind/blob/master/guide/mindx/sdk/tutorials/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99.md -> 相关参数修改 +**步骤1:** 准备测试视频。视频流格式为264,放入`test/`文件夹下。 -main.cpp中配置rtsp流源地址(需要自行准备可用的视频流,视频流格式为H264或H265) +**步骤2:** 在`test/`文件夹下拉起Live555服务。[Live555拉流教程](../../docs/参考资料/Live555离线视频转RTSP说明文档.md) -[Live555拉流教程](../../docs/参考资料/Live555离线视频转RTSP说明文档.md) -```c++ -rtspList.emplace_back("#{rtsp流地址1}"); -rtspList.emplace_back("#{rtsp流地址2}"); -``` +**步骤3:** 修改`main.cpp`文件中的配置: -配置config sdk路径 -```c++ -configUtil.LoadConfiguration("${MindXSDK安装路径}/config/logging.conf", configData, MxBase::ConfigMode::CONFIGFILE); -``` +①:将文件中第47、48行的`${rtsp流地址1}`、`${rtsp流地址2}`字段值替换为可用的 rtsp 流源地址(目前只支持264格式的rtsp流,例:"rtsp://xxx.xxx.xxx.xxx:xxx/xxx.264", 其中xxx.xxx.xxx.xxx:xxx为ip和端口号,端口号需同Live555服务的起流端口号一致,xxx.264为待测视频流文件名); -配置YoloDetector插件的模型加载路径`modelPath` ```c++ -reasonerConfig.yoloModelPath = "${yolov3.om模型路径}" +rtspList.emplace_back("${rtsp流地址1}"); +rtspList.emplace_back("${rtsp流地址2}"); ``` -配置YoloDetector插件的模型加载路径`labelPath` +②:将文件中第96行的`${MindXSDK安装路径}`字段值替换为实际使用的安装路径 -- eg: SDK安装路径/samples/mxVision/models/yolov3/coco.names ```c++ -reasonerConfig.yoloLabelPath = "${yolov3 coco.names路径}"; +APP_ERROR ret = configUtil.LoadConfiguration("${MX_SDK_HOME}/config/logging.conf", configData, MxBase::ConfigMode::CONFIGFILE); ``` -其他可配置项`maxDecodeFrameQueueLength` `writeDetectResultToFile` `enablePerformanceMonitorPrint` `intervalPerformanceMonitorPrint` -`intervalMainThreadControlCheck` `printDetectResult` `enableIndependentThreadForEachDetectStep` -> 开启 `enableIndependentThreadForEachDetectStep` 时请减小 `maxDecodeFrameQueueLength` 的值,建议最大值 `200` -> 同时开启 `writeDetectResultToFile`时请进一步减小 `maxDecodeFrameQueueLength` 的值,建议最大值 `100` -```c++ -reasonerConfig.maxDecodeFrameQueueLength = 400; // 多路视频时请适当减小 -reasonerConfig.writeDetectResultToFile = true; // 检测结果是否写文件, 默认为false -reasonerConfig.enablePerformanceMonitorPrint = false; // 性能可视化开关,默认为false -reasonerConfig.intervalPerformanceMonitorPrint = 5; // 性能管理输出间隔(s) -reasonerConfig.intervalMainThreadControlCheck = 2; // 流程检查间隔(ms) -reasonerConfig.printDetectResult = true; // 输出检测结果,默认为true -reasonerConfig.enableIndependentThreadForEachDetectStep = true; // 为每个检测步骤启用独立线程,默认为true -``` - -### 配置环境变量 - -```shell -. /usr/local/Ascend/ascend-toolkit/set_envv.sh # Ascend-cann-toolkit开发套件包默认安全路径,根据实际安装路径修改 -. ${MX_SDK_HOME}/mxVision/set_env.sh # ${MX_SDK_HOME}替换为用户的SDK安装路径shell -``` - -### 配置CMakeLists - -配置CMakeLists.txt文件中的`MX_SDK_HOME`与`FFMPEG_PATH`环境变量 -> Tips: 如果安装FFmpeg的过程中选择了`--enable-libx264`选项,还需要添加`X264_HOME`环境变量 -- eg: `MX_SDK_HOME ../../MindXSDK/mxVision` `FFMPEG_PATH ../../local/ffmpeg` `X264_HOME ../../local/x264` - -```cmake -set(MX_SDK_HOME {MindXSDK安装路径}) -set(FFMPEG_HOME {ffmpeg实际安装路径}) -set(X264_HOME {x264实际安装路径}) # 可选 -``` - -### 编译项目文件 - -手动编译请参照 ①,脚本编译请参照 ② - -> ① 新建build目录,进入build执行cmake ..(..代表包含CMakeLists.txt的源文件父目录),在build目录下生成了编译需要的Makefile和中间文件。执行make构建工程,构建成功后就会生成可执行文件。 - -```bash -mkdir build - -cd build - -cmake .. - --- The C compiler identification is GNU 7.5.0 --- The CXX compiler identification is GNU 7.5.0 --- Check for working C compiler: /usr/bin/cc --- Check for working C compiler: /usr/bin/cc -- works --- Detecting C compiler ABI info --- Detecting C compiler ABI info - done --- Detecting C compile features --- Detecting C compile features - done --- Check for working CXX compiler: /usr/bin/c++ --- Check for working CXX compiler: /usr/bin/c++ -- works --- Detecting CXX compiler ABI info --- Detecting CXX compiler ABI info - done --- Detecting CXX compile features --- Detecting CXX compile features - done --- Configuring done --- Generating done - -make -Scanning dependencies of target multiChannelVideoReasoner -[ 44%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/main.cpp.o -[ 44%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/VideoDecoder/VideoDecoder.cpp.o -[ 44%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/ImageResizer/ImageResizer.cpp.o -[ 44%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/YoloDetector/YoloDetector.cpp.o -[ 55%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/StreamPuller/StreamPuller.cpp.o -[ 66%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/Util/PerformanceMonitor/PerformanceMonitor.cpp.o -[ 77%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/Util/Util.cpp.o -[ 88%] Building CXX object CMakeFiles/multiChannelVideoReasoner.dir/MultiChannelVideoReasoner/MultiChannelVideoReasoner.cpp.o -[100%] Linking CXX executable ../multiChannelVideoReasoner -[100%] Built target multiChannelVideoReasoner -# sample就是CMakeLists文件中指定生成的可执行文件。 -``` - -> ② 运行项目根目录下的`build.sh` -```bash -chmod +x build.sh -bash build.sh -``` -### 执行脚本 - -执行`run.sh`脚本前请先确认可执行文件`multiChannelVideoReasoner`已生成。 - -``` -chmod +x run.sh -bash run.sh -``` - -### 查看结果 - -执行`run.sh`完毕后,如果配置了检测结果写文件,sample会将目标检测结果保存在工程目录下`result`中。 +**步骤4:** 编译。在项目根目录下,执行命令`bash build.sh`,编译成功会在根目录下生成`multiChannelVideoReasoner`可执行文件 -## 疑难解惑 -本工程中需要使用cann下dvpp的相关组件,CMake中配置为指向默认安装的/usr/local/Ascend/ascend-toolkit/latest/include,如用户有变更应该更改为实际位置。 \ No newline at end of file +**步骤5:** 运行。在项目根目录下,执行命令`bash run.sh`,会有打屏日志显示检测结果,同时会将目标检测结果保存在工程目录下`result`中。 diff --git a/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.cpp b/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.cpp index e86d7b733..f453f9937 100644 --- a/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.cpp +++ b/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.cpp @@ -221,7 +221,7 @@ APP_ERROR YoloDetector::InitModel(const YoloInitParam &initParam) APP_ERROR YoloDetector::InitPostProcess(const YoloInitParam &initParam) { LogInfo << "YoloDetector init postprocess start."; - std::map> config; + std::map config; LoadPostProcessConfig(initParam, config); postProcess = std::make_shared(); @@ -351,7 +351,7 @@ APP_ERROR YoloDetector::LoadLabels(const std::string &labelPath, std::map> &config) + std::map &config) { LogInfo << "load postprocess config start."; @@ -370,9 +370,8 @@ APP_ERROR YoloDetector::LoadPostProcessConfig(const YoloInitParam &initParam, configData.SetJsonValue("ANCHOR_DIM", std::to_string(initParam.anchorDim)); configData.SetJsonValue("CHECK_MODEL", checkTensor); - auto jsonStr = configData.GetCfgJson().serialize(); - config["postProcessConfigContent"] = std::make_shared(jsonStr); - config["labelPath"] = std::make_shared(initParam.labelPath); + config["postProcessConfigContent"] = configData.GetCfgJson(); + config["labelPath"] = initParam.labelPath; LogInfo << "load postprocess config successfully."; return APP_ERR_OK; diff --git a/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.h b/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.h index f2d05868f..eff2d169f 100644 --- a/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.h +++ b/contrib/MultiChannelVideoDetection/YoloDetector/YoloDetector.h @@ -80,7 +80,7 @@ public: protected: static APP_ERROR LoadLabels(const std::string &labelPath, std::map &labelMap); static APP_ERROR LoadPostProcessConfig(const YoloInitParam &initParam, - std::map> &config); + std::map &config); private: APP_ERROR InitModel(const YoloInitParam &initParam); diff --git a/contrib/MultiChannelVideoDetection/main.cpp b/contrib/MultiChannelVideoDetection/main.cpp index 4f3a511d5..644e446d2 100644 --- a/contrib/MultiChannelVideoDetection/main.cpp +++ b/contrib/MultiChannelVideoDetection/main.cpp @@ -64,16 +64,16 @@ static void LoadReasonerConfig(const std::vector &rtspList, Reasone reasonerConfig.baseVideoChannelId = BASE_CHANNEL_ID; reasonerConfig.rtspList = rtspList; reasonerConfig.maxTryOpenVideoStream = AscendStreamPuller::DEFAULT_RETRY_OPEN_VIDEO_TIMES; - reasonerConfig.yoloModelPath = "${yolov3.om模型路径}"; - reasonerConfig.yoloLabelPath = "${yolov3 coco.names路径}"; + reasonerConfig.yoloModelPath = "./model/yolov3_tf_bs1_fp16.om"; + reasonerConfig.yoloLabelPath = "./model/coco.names"; reasonerConfig.yoloModelWidth = AscendYoloDetector::YOLO_MODEL_INPUT_WIDTH; reasonerConfig.yoloModelHeight = AscendYoloDetector::YOLO_MODEL_INPUT_HEIGHT; - reasonerConfig.maxDecodeFrameQueueLength = DECODE_QUEUE_LENGTH_200; + reasonerConfig.maxDecodeFrameQueueLength = DECODE_QUEUE_LENGTH_100; reasonerConfig.popDecodeFrameWaitTime = DEFAULT_POP_WAIT_TIME; reasonerConfig.intervalPerformanceMonitorPrint = AscendPerformanceMonitor::DEFAULT_PRINT_INTERVAL; reasonerConfig.intervalMainThreadControlCheck = DEFAULT_CONTROL_CHECK_INTERVAL; - reasonerConfig.printDetectResult = false; - reasonerConfig.writeDetectResultToFile = false; + reasonerConfig.printDetectResult = true; + reasonerConfig.writeDetectResultToFile = true; reasonerConfig.enablePerformanceMonitorPrint = true; reasonerConfig.enableIndependentThreadForEachDetectStep = true; } @@ -93,10 +93,11 @@ int main(int argc, char *argv[]) /// === modify config === /// MxBase::ConfigData configData; MxBase::ConfigUtil configUtil; - APP_ERROR ret = configUtil.LoadConfiguration("${MindXSDK安装路径}/config/logging.conf", configData, + APP_ERROR ret = configUtil.LoadConfiguration("${MX_SDK_HOME}/config/logging.conf", configData, MxBase::ConfigMode::CONFIGFILE); if (ret == APP_ERR_OK) { - configData.SetFileValue("global_level", 1); + configData.SetFileValue("global_level", 0); + configData.SetFileValue("console_level", 0); MxBase::Log::SetLogParameters(configData); } else { LogInfo << "load log configuration failed."; diff --git a/contrib/MultiChannelVideoDetection/run.sh b/contrib/MultiChannelVideoDetection/run.sh index 00213b9d1..cf0d9f646 100644 --- a/contrib/MultiChannelVideoDetection/run.sh +++ b/contrib/MultiChannelVideoDetection/run.sh @@ -30,14 +30,6 @@ function check_env() { else echo "MX_SDK_HOME set as ${MX_SDK_HOME}, ready." fi - - # check FFmpeg env - if [ ! "${FFMPEG_HOME}" ]; then - env_ready=false - echo "please set FFMPEG_HOME path into env." - else - echo "FFMPEG_HOME set as ${FFMPEG_HOME}, ready." - fi } function export_env() { -- Gitee From 9ffd1784341d90ac5002071074a50f521aa84f44 Mon Sep 17 00:00:00 2001 From: xu Date: Wed, 4 Dec 2024 17:58:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/MultiChannelVideoDetection/CMakeLists.txt | 3 +++ contrib/MultiChannelVideoDetection/README.md | 7 ++++++- contrib/MultiChannelVideoDetection/run.sh | 8 ++++++++ contrib/YOLOX/README.md | 4 ++-- contrib/msame/README.md | 6 +++--- mxVision/InferOfflineVideo/README.md | 2 +- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/contrib/MultiChannelVideoDetection/CMakeLists.txt b/contrib/MultiChannelVideoDetection/CMakeLists.txt index fd0a9bab3..a549709a1 100644 --- a/contrib/MultiChannelVideoDetection/CMakeLists.txt +++ b/contrib/MultiChannelVideoDetection/CMakeLists.txt @@ -8,6 +8,7 @@ set(OUTPUT_NAME "multiChannelVideoReasoner") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/") set(MX_SDK_HOME "$ENV{MX_SDK_HOME}") +set(FFMPEG_HOME "$ENV{FFMPEG_HOME}") include_directories( ${CMAKE_CURRENT_SOURCE_DIR} @@ -15,6 +16,7 @@ include_directories( ${MX_SDK_HOME}/opensource/include ${MX_SDK_HOME}/opensource/include/opencv4 ${MX_SDK_HOME}/include/MxBase/postprocess/include + ${FFMPEG_HOME}/include #该处为ascend-toolkit的实际安装位置,默认为/usr/local下指向对应架构include的软连接 /usr/local/Ascend/ascend-toolkit/latest/include ) @@ -23,6 +25,7 @@ link_directories( ${MX_SDK_HOME}/lib ${MX_SDK_HOME}/opensource/lib ${MX_SDK_HOME}/lib/modelpostprocessors + ${FFMPEG_HOME}/lib ) add_executable(${OUTPUT_NAME} main.cpp diff --git a/contrib/MultiChannelVideoDetection/README.md b/contrib/MultiChannelVideoDetection/README.md index f1fc3c04a..3f9f9200f 100644 --- a/contrib/MultiChannelVideoDetection/README.md +++ b/contrib/MultiChannelVideoDetection/README.md @@ -25,6 +25,8 @@ | live555 | 1.10 | 实现视频转rstp进行推流 | [链接](https://gitee.com/ascend/mindxsdk-referenceapps/blob/master/docs/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/Live555%E7%A6%BB%E7%BA%BF%E8%A7%86%E9%A2%91%E8%BD%ACRTSP%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md) | | ffmpeg | 4.2.1 | 实现mp4格式视频转为264格式视频 | [链接](https://gitee.com/ascend/mindxsdk-referenceapps/blob/master/docs/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/pc%E7%AB%AFffmpeg%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B.md#https://ffmpeg.org/download.html) | +注:live555和ffmpeg需要用户到相关网址下载源码编译安装。 + ### 1.5 代码目录结构说明 ``` @@ -72,6 +74,7 @@ ```bash . /usr/local/Ascend/ascend-toolkit/set_env.sh # toolkit默认安装路径,根据实际安装路径修改 . ${SDK_INSTALL_PATH}/mxVision/set_env.sh # sdk安装路径,根据实际安装路径修改 +export FFMPEG_HOME=/usr/local/ffmpeg # ffmpeg默认安装路径,根据实际安装路径修改 ``` ## 3 准备模型 @@ -117,4 +120,6 @@ APP_ERROR ret = configUtil.LoadConfiguration("${MX_SDK_HOME}/config/logging.conf **步骤4:** 编译。在项目根目录下,执行命令`bash build.sh`,编译成功会在根目录下生成`multiChannelVideoReasoner`可执行文件 -**步骤5:** 运行。在项目根目录下,执行命令`bash run.sh`,会有打屏日志显示检测结果,同时会将目标检测结果保存在工程目录下`result`中。 +**步骤5:** 运行。在项目根目录下,执行命令`bash run.sh` + +**步骤6:** 查看结果。在执行`bash run.sh`后会有打屏日志显示检测结果,同时会将目标检测结果保存在工程目录下`result`中。手动执行 `ctrl + C` 结束程序 diff --git a/contrib/MultiChannelVideoDetection/run.sh b/contrib/MultiChannelVideoDetection/run.sh index cf0d9f646..00213b9d1 100644 --- a/contrib/MultiChannelVideoDetection/run.sh +++ b/contrib/MultiChannelVideoDetection/run.sh @@ -30,6 +30,14 @@ function check_env() { else echo "MX_SDK_HOME set as ${MX_SDK_HOME}, ready." fi + + # check FFmpeg env + if [ ! "${FFMPEG_HOME}" ]; then + env_ready=false + echo "please set FFMPEG_HOME path into env." + else + echo "FFMPEG_HOME set as ${FFMPEG_HOME}, ready." + fi } function export_env() { diff --git a/contrib/YOLOX/README.md b/contrib/YOLOX/README.md index 6b5b7661f..631ad1089 100644 --- a/contrib/YOLOX/README.md +++ b/contrib/YOLOX/README.md @@ -135,9 +135,9 @@ cp postprocess/build/libYoloxPostProcess.so ${MX_SDK_HOME}/lib/modelpostprocesso ``` python3 pre_post.py -``` +``` -命令执行成功后在目录``python/test_img``下生成检测结果文件 pre_post_bgr.jpg,查看结果文件验证检测结果。 +**步骤5:** 查看结果。命令执行成功后在目录``python/test_img``下生成检测结果文件 pre_post_bgr.jpg,查看结果文件验证检测结果。 ## 5 常见问题 diff --git a/contrib/msame/README.md b/contrib/msame/README.md index fa018573f..6ab0ea41c 100644 --- a/contrib/msame/README.md +++ b/contrib/msame/README.md @@ -141,10 +141,10 @@ python3 msame.py --model ./test/yolox_pre_post.om --input test/test1.npy --outpu python3 msame.py --model ./test/bert_text_classification.om --input test/test2.npy,test/test2.npy --output test --outfmt TXT --loop 2 ``` -**步骤3:** 查看执行结果。执行成功后,在test目录下生成 `.txt` 或 `.bin` 输出文件,文件类型取决于命令中的 `--outfmt`参数配置 +**步骤3:** 查看结果。执行成功后,在test目录下生成 `.txt` 或 `.bin` 输出文件,文件类型取决于命令中的 `--outfmt`参数配置 ## 5 常见问题 -### 6.1 存储为txt格式时可能会出现第六位开始的误差 +### 5.1 存储为txt格式时可能会出现第六位开始的误差 **问题描述:** @@ -159,7 +159,7 @@ python3 msame.py --model ./test/bert_text_classification.om --input test/test2.n 可以忽略此问题。 -### 6.2 模型需要的输入与提供的数据不一致 +### 5.2 模型需要的输入与提供的数据不一致 **问题描述:** diff --git a/mxVision/InferOfflineVideo/README.md b/mxVision/InferOfflineVideo/README.md index d871a7b95..e2a5b815e 100644 --- a/mxVision/InferOfflineVideo/README.md +++ b/mxVision/InferOfflineVideo/README.md @@ -102,4 +102,4 @@ console_level = 0 **步骤5:** 运行。在样例根目录下执行命令 `bash run.sh` -正常启动后,控制台会输出检测到各类目标的对应信息。手动执行 `ctrl + C` 结束程序 \ No newline at end of file +**步骤6:** 查看结果。正常启动后,控制台会输出检测到各类目标的对应信息。手动执行 `ctrl + C` 结束程序 \ No newline at end of file -- Gitee