From e69c9d1cde6d71928cf707d287a37464ef5bbf89 Mon Sep 17 00:00:00 2001 From: wangchongwu <759291707@qq.com> Date: Mon, 10 Nov 2025 17:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E7=93=A6=E7=89=87=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 ++++++ CMakeLists.txt | 4 ++-- stitch/src/Arith_BlendMap.cpp | 4 ++-- stitch/src/Arith_UnderStitch.cpp | 13 +++++++++++-- stitch/src/GoogleTile.cpp | 5 +++-- stitch/src/Version.h | 2 +- tests/stitch_Genaral.cpp | 21 +++++++++++++++------ tests/stitch_S732.cpp | 20 ++++++++++++-------- 8 files changed, 52 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 595a6ee..4febf8d 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,9 @@ install *.png *.kml + + + +# 保留 3rdparty 整个文件夹内容 +!/3rdparty/ +!/3rdparty/** \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ff5eeb6..7bbbf82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) IF(WIN32) # ======== OpenCV 配置 ======== - set(OpenCV_DIR "C:/opencv/build/x64/vc14/lib") + set(OpenCV_DIR "C:/lib/opencv455/build/x64/vc14/lib") find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) link_libraries(${OpenCV_LIBS}) @@ -79,7 +79,7 @@ IF(WIN32) # ======== FFMPEG配置 ======== set(FFMPEG_DIR "C:/Lib/ffmpeg4") set(FFMPEG_INCLUDE_DIRS ${FFMPEG_DIR}/include) - set(FFMPEG_LIBS_DIR ${FFMPEG_DIR}/lib/x64) + set(FFMPEG_LIBS_DIR ${FFMPEG_DIR}/lib/) include_directories(${FFMPEG_DIR}) include_directories(${FFMPEG_INCLUDE_DIRS}) diff --git a/stitch/src/Arith_BlendMap.cpp b/stitch/src/Arith_BlendMap.cpp index 15b23eb..7627735 100644 --- a/stitch/src/Arith_BlendMap.cpp +++ b/stitch/src/Arith_BlendMap.cpp @@ -90,7 +90,7 @@ void MapBlend::FrameMap(cv::Mat src, cv::Mat H_Geo, cv::Mat mapH, BLEND_TYPE ble - cv::Mat mask = cv::Mat::ones(cv::Size(src.cols, src.rows), CV_8UC1); + cv::Mat mask = cv::Mat::ones(cv::Size(src.cols, src.rows), CV_8UC1) * 255; // 设置上下左右边缘区域为 0 int margin = 5; // 可根据实际需求调整,5 像素作为边缘区域 @@ -101,7 +101,7 @@ void MapBlend::FrameMap(cv::Mat src, cv::Mat H_Geo, cv::Mat mapH, BLEND_TYPE ble // 当前帧的mask - warpPerspectiveROI(mask, mask, H); + warpPerspectiveROI(mask, _panMask, H); //cv::warpPerspective(mask, mask, H, _panImage.size()); diff --git a/stitch/src/Arith_UnderStitch.cpp b/stitch/src/Arith_UnderStitch.cpp index 3d1fce8..054b5f1 100644 --- a/stitch/src/Arith_UnderStitch.cpp +++ b/stitch/src/Arith_UnderStitch.cpp @@ -7,7 +7,7 @@ #include #include #include "utils/Arith_ThreadPool.h" -#include "utils/Arith_Timer.h" +#include "utils/Arith_timer.h" #ifdef _WIN32 #include @@ -335,7 +335,16 @@ SINT32 UnderStitch::Run(GD_VIDEO_FRAME_S frame, FrameInfo para) // 输出当前所有瓦片,再不输出就会丢失当前全景中的瓦片 LOG_INFO("Start ExportTileSet"); - _googleProduct.ExportTileSet(panImage, panMask, _taskTilesVec, _outDir, _filename + std::to_string(_lastFrameKey)); + auto todoTiles = _taskTilesVec; + + + // 切图放入线程池中后台处理 + _threadPool.commit([this, mat_pan = panImage.clone(), mat_mask = panMask.clone(), tilesvec = todoTiles, outdirpath = _outDir, filename = _filename + std::to_string(_lastFrameKey)]() { + _googleProduct.ExportTileSet(mat_pan, mat_mask, tilesvec, outdirpath, filename); + }, "ExportTileSet"); + + + // _googleProduct.ExportTileSet(panImage, panMask, _taskTilesVec, _outDir, _filename + std::to_string(_lastFrameKey)); // 重新初始化投影参数 diff --git a/stitch/src/GoogleTile.cpp b/stitch/src/GoogleTile.cpp index 6c3f926..db5ac2a 100644 --- a/stitch/src/GoogleTile.cpp +++ b/stitch/src/GoogleTile.cpp @@ -45,7 +45,7 @@ void googleTile::ExportGeoPng(cv::Mat _pan, TileInfo info, std::string dir) WriteKml(taskTiles, kml_path); } - +#include "Log/Logger.h" void googleTile::ExportTileSet(cv::Mat _pan, cv::Mat _panMask, vector taskTilesVec, std::string dir,std::string fileString) { @@ -57,6 +57,7 @@ void googleTile::ExportTileSet(cv::Mat _pan, cv::Mat _panMask, vector // 过滤掉无效瓦片 vector vaildTilesVec; + for (size_t i = 0; i < taskTilesVec.size(); i++) { TileInfo tile = taskTilesVec[i]; @@ -119,7 +120,7 @@ void googleTile::ExportTileSet(cv::Mat _pan, cv::Mat _panMask, vector } - + LOG_INFO("taskTilesVec : {},{}", fileString, taskTilesVec.size()); // 输出KML WriteKml(vaildTilesVec,dir + "/" + fileString + "_z" + std::to_string(zoom) + ".kml"); diff --git a/stitch/src/Version.h b/stitch/src/Version.h index 8793639..de1cb5a 100644 --- a/stitch/src/Version.h +++ b/stitch/src/Version.h @@ -2,5 +2,5 @@ #pragma once #include -std::string BUILD_TIME = "BUILD_TIME 2025_11_07-14.24.17"; +std::string BUILD_TIME = "BUILD_TIME 2025_11_10-17.19.53"; std::string VERSION = "BUILD_VERSION 1.0.1"; diff --git a/tests/stitch_Genaral.cpp b/tests/stitch_Genaral.cpp index 52e7e16..8a3fad5 100644 --- a/tests/stitch_Genaral.cpp +++ b/tests/stitch_Genaral.cpp @@ -34,10 +34,15 @@ void Run_FrontStitch(std::string picFloder) stitcher->Init(para, ScanRange{-30,30}, ScanRange{-15,-1}); - cv::VideoWriter writer("pan.mp4", cv::VideoWriter::fourcc('M', 'P', '4', 'V'), 5, cv::Size(pan.u32Width, pan.u32Height)); pan = stitcher->ExportPanAddr(); + cv::VideoWriter writer("pan.mp4", cv::VideoWriter::fourcc('M', 'P', '4', 'V'), 50, cv::Size(pan.u32Width, pan.u32Height)); + if (!writer.isOpened()) { + std::cout << "Error: Failed to create video writer!" << std::endl; + return; + } + cv::Mat mat_pan = cv::Mat(pan.u32Height, pan.u32Width, CV_8UC3, pan.u64VirAddr[0]); frame.enPixelFormat = GD_PIXEL_FORMAT_RGB_PACKED; @@ -79,12 +84,16 @@ void Run_FrontStitch(std::string picFloder) cv::Mat res; cv::resize(mat_pan, res, cv::Size(pan.u32Width / 2, pan.u32Height / 2)); imshow("pan", res); - cv::waitKey(1); - cv::cvtColor(mat_pan, mat_pan, cv::COLOR_GRAY2BGR); - cv::Mat rgb(pan.u32Height, pan.u32Width, CV_8UC3); - writer.write(rgb); + if(cv::waitKey(1) == 27) + { + break; + } + + + + writer.write(mat_pan); } writer.release(); } @@ -179,6 +188,6 @@ int main(int argc, char** argv) - Run_UnderStitch("F:/DJI_20250418152649_0005_W_output"); + Run_FrontStitch("/media/wang/think/包头/20250928_145957066_9前视扫描_output"); return 0; } \ No newline at end of file diff --git a/tests/stitch_S732.cpp b/tests/stitch_S732.cpp index cf84268..9cc0517 100644 --- a/tests/stitch_S732.cpp +++ b/tests/stitch_S732.cpp @@ -13,7 +13,7 @@ using namespace std; void ProcessVL(string filePath) { - auto stitcher = API_UnderStitch::Create(); + auto stitcher = API_UnderStitch::Create("F:/cache"); stitcher->SetOutput("BT", "google_tiles"); @@ -42,6 +42,8 @@ void ProcessVL(string filePath) std::deque MatBuffer; const int matdelayFrames = 2; // 假设延迟3帧 + fseek(file, nVLFrameSize * 80, SEEK_SET); + while (!feof(file)) { fread(pFrameVL, 1, nVLFrameSize, file); @@ -89,9 +91,9 @@ void ProcessVL(string filePath) cv::cvtColor(bright, bright, cv::COLOR_GRAY2BGR); - cv::Mat IMG_show; - cv::resize(IMG, IMG_show, cv::Size(IMG.cols / 4, IMG.rows / 4)); - imshow("IMG_show", IMG_show); + + cv::namedWindow("IMG_show", cv::WINDOW_NORMAL); + imshow("IMG_show", IMG); @@ -123,17 +125,17 @@ void ProcessVL(string filePath) UPanConfig cfg = { 0 }; cfg.bOutGoogleTile = 1; cfg.bOutFrameTile = 0; - cfg.bUseBA = 1; + cfg.bUseBA = 0; stitcher->SetConfig(cfg); - stitcher->SetOutput("baotou","E:/google_tiles"); + stitcher->SetOutput("baotou","F:/google_tiles"); pan = stitcher->ExportPanAddr(); mat_pan = cv::Mat(pan.u32Height, pan.u32Width, CV_8UC4, pan.u64VirAddr[0]); - output.open("E:/output.mp4", VideoWriter::fourcc('M', 'P', '4', 'V'), 25, Size(pan.u32Width / 8, pan.u32Height / 8), true); + output.open("output.mp4", VideoWriter::fourcc('M', 'P', '4', 'V'), 50, Size(pan.u32Width / 8, pan.u32Height / 8), true); if (!output.isOpened()) { cout << "打开视频失败" << endl; @@ -176,6 +178,8 @@ void ProcessVL(string filePath) } i = i + 1; + + } //cv::TickMeter tm; @@ -200,6 +204,6 @@ void ProcessVL(string filePath) int main() { - ProcessVL("D:/S732挂飞1101/20251101_092143724_3.yuv"); + ProcessVL("F:/包头/20251101/20251101_091550742_2.yuv"); return 0; } \ No newline at end of file