feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
95
3rdparty/opencv-4.5.4/samples/gpu/video_reader.cpp
vendored
Normal file
95
3rdparty/opencv-4.5.4/samples/gpu/video_reader.cpp
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_CUDACODEC)
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/core/opengl.hpp>
|
||||
#include <opencv2/cudacodec.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
return -1;
|
||||
|
||||
const std::string fname(argv[1]);
|
||||
|
||||
cv::namedWindow("CPU", cv::WINDOW_NORMAL);
|
||||
cv::namedWindow("GPU", cv::WINDOW_OPENGL);
|
||||
cv::cuda::setGlDevice();
|
||||
|
||||
cv::Mat frame;
|
||||
cv::VideoCapture reader(fname);
|
||||
|
||||
cv::cuda::GpuMat d_frame;
|
||||
cv::Ptr<cv::cudacodec::VideoReader> d_reader = cv::cudacodec::createVideoReader(fname);
|
||||
|
||||
cv::TickMeter tm;
|
||||
std::vector<double> cpu_times;
|
||||
std::vector<double> gpu_times;
|
||||
|
||||
int gpu_frame_count=0, cpu_frame_count=0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
tm.reset(); tm.start();
|
||||
if (!reader.read(frame))
|
||||
break;
|
||||
tm.stop();
|
||||
cpu_times.push_back(tm.getTimeMilli());
|
||||
cpu_frame_count++;
|
||||
|
||||
cv::imshow("CPU", frame);
|
||||
|
||||
if (cv::waitKey(3) > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
tm.reset(); tm.start();
|
||||
if (!d_reader->nextFrame(d_frame))
|
||||
break;
|
||||
tm.stop();
|
||||
gpu_times.push_back(tm.getTimeMilli());
|
||||
gpu_frame_count++;
|
||||
|
||||
cv::imshow("GPU", d_frame);
|
||||
|
||||
if (cv::waitKey(3) > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!cpu_times.empty() && !gpu_times.empty())
|
||||
{
|
||||
std::cout << std::endl << "Results:" << std::endl;
|
||||
|
||||
std::sort(cpu_times.begin(), cpu_times.end());
|
||||
std::sort(gpu_times.begin(), gpu_times.end());
|
||||
|
||||
double cpu_avg = std::accumulate(cpu_times.begin(), cpu_times.end(), 0.0) / cpu_times.size();
|
||||
double gpu_avg = std::accumulate(gpu_times.begin(), gpu_times.end(), 0.0) / gpu_times.size();
|
||||
|
||||
std::cout << "CPU : Avg : " << cpu_avg << " ms FPS : " << 1000.0 / cpu_avg << " Frames " << cpu_frame_count << std::endl;
|
||||
std::cout << "GPU : Avg : " << gpu_avg << " ms FPS : " << 1000.0 / gpu_avg << " Frames " << gpu_frame_count << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "OpenCV was built without CUDA Video decoding support\n" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user