Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
!*/
!*.*

# 忽略任意位置的 vp_data 目录
**/vp_data/
key/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -158,3 +162,4 @@ cmake-build-debug-remote/
cmake-build-debug/
build/*
!build/build.sh
.vscode/launch.json
79 changes: 77 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,35 @@
"name": "debug samples for videopipe", // debug for samples in videopipe
"type": "cppdbg",
"request": "launch",
// "program": "${workspaceFolder}/build/bin/${fileBasenameNoExtension}",
"program": "${workspaceFolder}/build/bin/${fileBasenameNoExtension}",
"args": [""],
"args": ["./vp_data/test_video/face.mp4"], // change this value to the path of your vp_data
"stopAtEntry": false,
"cwd": "${workspaceFolder}/..", // change this value to the path of your vp_data
// "cwd": "${workspaceFolder}/..", // change this value to the path of your vp_data
"cwd": "${workspaceFolder}/", // change this value to the path of your vp_data
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": ""
},
{
"name": "debug videopipe ex samples", // debug for ex samples in videopipe
"type": "cppdbg",
"request": "launch",
// "program": "${workspaceFolder}/build/bin/${fileBasenameNoExtension}",
"program": "${workspaceFolder}/build/bin/${fileBasenameNoExtension}",
"args": ["./vp_data/test_video/test1.mp4"], // change this value to the path of your vp_data
"stopAtEntry": false,
// "cwd": "${workspaceFolder}/..", // change this value to the path of your vp_data
"cwd": "${workspaceFolder}/", // change this value to the path of your vp_data
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
Expand Down Expand Up @@ -46,6 +71,56 @@
],
"preLaunchTask": ""
},
{
"name": "debug cpp_llmlib samples", // debug for trt samples at third_party/trt_yolov8
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/third_party/cpp_llmlib/build/${fileBasenameNoExtension}",
"args": [""],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/", // change this value to the path of your vp_data
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": ""
},
{
"name": "debug cpp_analyzerlib samples", // debug for trt samples at third_party/trt_yolov8
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/third_party/cpp_analyzelib/build/doubao_analyzer_app",
"args": [
"--api-key",
"9337f332-cfd4-43f2-a862-0dc320934c7c",
"--folder",
"./vp_data/test_video",
"--max-files",
"6"

],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/", // change this value to the path of your vp_data
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": ""
},
{
"name": "debug trt_yolov8 samples", // debug for trt samples at third_party/trt_yolov8
"type": "cppdbg",
Expand Down
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.associations": {
"*.yaml": "yaml",
"memory": "cpp",
"cmath": "cpp",
"cstddef": "cpp",
Expand Down Expand Up @@ -88,7 +89,14 @@
"cinttypes": "cpp",
"__nullptr": "cpp",
"__locale": "cpp",
"regex": "cpp"
"regex": "cpp",
"csignal": "cpp",
"forward_list": "cpp",
"ranges": "cpp",
"shared_mutex": "cpp",
"typeindex": "cpp",
"valarray": "cpp",
"variant": "cpp"
},
"C_Cpp.errorSquiggles": "Disabled"
}
48 changes: 48 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ 生成活动文件",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always", //彩色输出
"-g", //调试信息
"${file}", //编译当前文件
"-o", //指定输出
"${fileDirname}/${fileBasenameNoExtension}", //输出可执行文件路径
"-I${workspaceFolder}", //项目头文件路径
"-I${workspaceFolder}/third_party/cpp_llmlib", //llmlib头文件路径
// "-I/home/whj00/VideoPipe/nodes/mllm", //mllm节点头文件路径
"-I${workspaceFolder}/nodes", //nodes节点头文件路径
"-I${workspaceFolder}/nodes/infers", //infers节点头文件路径
"-I${workspaceFolder}/nodes/track", //track节点头文件路径
"-I${workspaceFolder}/nodes/osd", //osd节点头文件路径
"-I${workspaceFolder}/utils/analysis_board", //analysis_board工具头文件路径
"-I/usr/local/cuda/include",
"-I/usr/include/x86_64-linux-gnu",
"-I/usr/local/include/opencv4", //OpenCV头文件路径
"-L${fileDirname}/../build/libs", //库文件路径
"-L/home/whj00/VideoPipe/third_party/cpp_llmlib/../build/libs", //库文件路径
"-lvideo_pipe", //链接video_pipe库
"-ltinyexpr", //链接tinyexpr库
"-Wl,-rpath,${fileDirname}/../build/libs", //运行时库文件路径
"-Wl,-rpath,/usr/local/cuda/lib64",
"-lssl",
"-lcrypto", //链接OpenSSL库
"`pkg-config", "--cflags", "--libs", "opencv4`" //链接OpenCV库
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "编译器: /usr/bin/g++"
}
]
}
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ option(VP_WITH_CUDA "prepared CUDA or not?" OFF)
option(VP_WITH_TRT "prepared TensorRT or not?" OFF)
option(VP_WITH_PADDLE "prepared PaddlePaddle or not?" OFF)
option(VP_WITH_KAFKA "prepared Kafka or not?" OFF)
option(VP_WITH_LLM "prepared LLM or not?" OFF)
option(VP_WITH_LLM "prepared LLM or not?" ON)
option(VP_WITH_FFMPEG "prepared FFMPEG or not?" OFF)
option(VP_BUILD_COMPLEX_SAMPLES "build complex samples or not? (maybe source code not provided)" OFF)

Expand Down Expand Up @@ -105,6 +105,12 @@ if(VP_WITH_LLM)
include_directories(${OPENSSL_INCLUDE_DIR})
list(APPEND VP_DEPEND_LIBS ${OPENSSL_LIBRARIES})
add_definitions(-DVP_WITH_LLM)
# #
# # 其他项目的 CMakeLists.txt
# add_subdirectory(third_party/cpp_analyzelib)

# add_executable(mllm_analyse_sample_openai_video_ex mllm_analyse_sample_openai_video_ex.cpp)
# target_link_libraries(mllm_analyse_sample_openai_video_ex doubao::doubao_analyzer)
endif()

# optional for FFmpeg
Expand Down
8 changes: 8 additions & 0 deletions Extractor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.10)
project(VideoFrameExtractor)

find_package(OpenCV REQUIRED)

add_executable(video_extractor video_extractor.cpp)
target_link_libraries(video_extractor ${OpenCV_LIBS})
target_compile_features(video_extractor PRIVATE cxx_std_11)
83 changes: 83 additions & 0 deletions Extractor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
编译说明
1. 安装OpenCV
首先需要安装OpenCV库:

Ubuntu/Debian:

bash
sudo apt-get update
sudo apt-get install libopencv-dev
Windows (使用vcpkg):

bash
vcpkg install opencv
macOS (使用Homebrew):

bash
brew install opencv
2. 编译命令
使用g++编译:

bash
g++ -std=c++11 video_extractor.cpp -o video_extractor `pkg-config --cflags --libs opencv4`
使用CMake (推荐):

创建 CMakeLists.txt 文件:

cmake
cmake_minimum_required(VERSION 3.10)
project(VideoFrameExtractor)

find_package(OpenCV REQUIRED)

add_executable(video_extractor video_extractor.cpp)
target_link_libraries(video_extractor ${OpenCV_LIBS})
target_compile_features(video_extractor PRIVATE cxx_std_11)
编译:

bash
mkdir build
cd build
cmake ..
make
使用方法
1. 提取所有帧
bash
./video_extractor input_video.mp4 ./output_frames
2. 按帧间隔提取
bash
# 每10帧提取一帧
./video_extractor input_video.mp4 ./output_frames -interval 10
3. 按时间间隔提取
bash
# 每2.5秒提取一帧
./video_extractor input_video.mp4 ./output_frames -time 2.5
代码特点
命名规则: 严格按照 0, 1, 2, 3... 的序列命名JPEG文件

格式支持: 输出标准的JPEG格式图片

灵活提取: 支持全帧提取、按帧间隔提取、按时间间隔提取

错误处理: 完善的错误检测和处理机制

信息显示: 显示视频信息和提取进度

输出示例
运行程序后,会在指定目录生成类似以下的文件:

text
output_frames/
├── 0.jpeg
├── 1.jpeg
├── 2.jpeg
├── 3.jpeg
└── ...
这个代码提供了完整的视频帧提取功能,可以根据您的具体需求进行调整和扩展。

whj00@navyai:~/VideoPipe/ExtractorVideo$ g++ -std=c++17 video_extractor.cpp -o video_extractor `pkg-config --cflags --libs opencv4`
video_extractor.cpp: In member function ‘bool VideoFrameExtractor::initialize(const string&, const string&)’:
video_extractor.cpp:33:30: error: ‘create_directories’ is not a member of ‘std::filesystem’
33 | std::filesystem::create_directories(outputDir);
中文分析处理
这个错误是因为编译器没有找到 std::filesystem 库。我来为您提供修复后的代码,包含多种解决方案。
Loading