1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #1299 from jet47:gpu-cuda-rename

This commit is contained in:
Alexander Smorkalov
2013-09-23 10:31:46 +04:00
committed by OpenCV Buildbot
601 changed files with 8873 additions and 9711 deletions
+10 -10
View File
@@ -16,17 +16,17 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp
ocv_include_modules(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
if(HAVE_opencv_gpuoptflow)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpuoptflow/include")
if(HAVE_opencv_cudaoptflow)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaoptflow/include")
endif()
if(HAVE_opencv_gpuimgproc)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpuimgproc/include")
if(HAVE_opencv_cudaimgproc)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaimgproc/include")
endif()
if(HAVE_opencv_gpuarithm)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpuarithm/include")
if(HAVE_opencv_cudaarithm)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaarithm/include")
endif()
if(HAVE_opencv_gpufilters)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpufilters/include")
if(HAVE_opencv_cudafilters)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudafilters/include")
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
@@ -53,7 +53,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
if("${srcs}" MATCHES "gpu/")
target_link_libraries(${the_target} opencv_gpuarithm opencv_gpufilters)
target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters)
endif()
set_target_properties(${the_target} PROPERTIES
@@ -79,7 +79,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
ocv_list_filterout(cpp_samples Qt_sample)
endif()
if(NOT HAVE_opencv_gpuarithm OR NOT HAVE_opencv_gpufilters)
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
ocv_list_filterout(cpp_samples "/gpu/")
endif()
+7 -7
View File
@@ -357,7 +357,7 @@ int main(int argc, char* argv[])
if (features_type == "surf")
{
#ifdef HAVE_OPENCV_NONFREE
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
finder = makePtr<SurfFeaturesFinderGpu>();
else
#endif
@@ -552,8 +552,8 @@ int main(int argc, char* argv[])
// Warp images and their masks
Ptr<WarperCreator> warper_creator;
#ifdef HAVE_OPENCV_GPUWARPING
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
#ifdef HAVE_OPENCV_CUDAWARPING
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
{
if (warp_type == "plane")
warper_creator = makePtr<cv::PlaneWarperGpu>();
@@ -635,8 +635,8 @@ int main(int argc, char* argv[])
seam_finder = makePtr<detail::VoronoiSeamFinder>();
else if (seam_find_type == "gc_color")
{
#ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
#ifdef HAVE_OPENCV_CUDA
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
seam_finder = makePtr<detail::GraphCutSeamFinderGpu>(GraphCutSeamFinderBase::COST_COLOR);
else
#endif
@@ -644,8 +644,8 @@ int main(int argc, char* argv[])
}
else if (seam_find_type == "gc_colorgrad")
{
#ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
#ifdef HAVE_OPENCV_CUDA
if (try_gpu && cuda::getCudaEnabledDeviceCount() > 0)
seam_finder = makePtr<detail::GraphCutSeamFinderGpu>(GraphCutSeamFinderBase::COST_COLOR_GRAD);
else
#endif
@@ -6,9 +6,9 @@
#include <opencv2/imgproc.hpp>// Image processing methods for the CPU
#include <opencv2/highgui.hpp>// Read images
// GPU structures and methods
#include <opencv2/gpuarithm.hpp>
#include <opencv2/gpufilters.hpp>
// CUDA structures and methods
#include <opencv2/cudaarithm.hpp>
#include <opencv2/cudafilters.hpp>
using namespace std;
using namespace cv;
@@ -16,41 +16,41 @@ using namespace cv;
double getPSNR(const Mat& I1, const Mat& I2); // CPU versions
Scalar getMSSIM( const Mat& I1, const Mat& I2);
double getPSNR_GPU(const Mat& I1, const Mat& I2); // Basic GPU versions
Scalar getMSSIM_GPU( const Mat& I1, const Mat& I2);
double getPSNR_CUDA(const Mat& I1, const Mat& I2); // Basic CUDA versions
Scalar getMSSIM_CUDA( const Mat& I1, const Mat& I2);
struct BufferPSNR // Optimized GPU versions
{ // Data allocations are very expensive on GPU. Use a buffer to solve: allocate once reuse later.
gpu::GpuMat gI1, gI2, gs, t1,t2;
struct BufferPSNR // Optimized CUDA versions
{ // Data allocations are very expensive on CUDA. Use a buffer to solve: allocate once reuse later.
cuda::GpuMat gI1, gI2, gs, t1,t2;
gpu::GpuMat buf;
cuda::GpuMat buf;
};
double getPSNR_GPU_optimized(const Mat& I1, const Mat& I2, BufferPSNR& b);
double getPSNR_CUDA_optimized(const Mat& I1, const Mat& I2, BufferPSNR& b);
struct BufferMSSIM // Optimized GPU versions
{ // Data allocations are very expensive on GPU. Use a buffer to solve: allocate once reuse later.
gpu::GpuMat gI1, gI2, gs, t1,t2;
struct BufferMSSIM // Optimized CUDA versions
{ // Data allocations are very expensive on CUDA. Use a buffer to solve: allocate once reuse later.
cuda::GpuMat gI1, gI2, gs, t1,t2;
gpu::GpuMat I1_2, I2_2, I1_I2;
vector<gpu::GpuMat> vI1, vI2;
cuda::GpuMat I1_2, I2_2, I1_I2;
vector<cuda::GpuMat> vI1, vI2;
gpu::GpuMat mu1, mu2;
gpu::GpuMat mu1_2, mu2_2, mu1_mu2;
cuda::GpuMat mu1, mu2;
cuda::GpuMat mu1_2, mu2_2, mu1_mu2;
gpu::GpuMat sigma1_2, sigma2_2, sigma12;
gpu::GpuMat t3;
cuda::GpuMat sigma1_2, sigma2_2, sigma12;
cuda::GpuMat t3;
gpu::GpuMat ssim_map;
cuda::GpuMat ssim_map;
gpu::GpuMat buf;
cuda::GpuMat buf;
};
Scalar getMSSIM_GPU_optimized( const Mat& i1, const Mat& i2, BufferMSSIM& b);
Scalar getMSSIM_CUDA_optimized( const Mat& i1, const Mat& i2, BufferMSSIM& b);
static void help()
{
cout
<< "\n--------------------------------------------------------------------------" << endl
<< "This program shows how to port your CPU code to GPU or write that from scratch." << endl
<< "This program shows how to port your CPU code to CUDA or write that from scratch." << endl
<< "You can see the performance improvement for the similarity check methods (PSNR and SSIM)." << endl
<< "Usage:" << endl
<< "./gpu-basics-similarity referenceImage comparedImage numberOfTimesToRunTest(like 10)." << endl
@@ -90,33 +90,33 @@ int main(int, char *argv[])
cout << "Time of PSNR CPU (averaged for " << TIMES << " runs): " << time << " milliseconds."
<< " With result of: " << result << endl;
//------------------------------- PSNR GPU ----------------------------------------------------
//------------------------------- PSNR CUDA ----------------------------------------------------
time = (double)getTickCount();
for (int i = 0; i < TIMES; ++i)
result = getPSNR_GPU(I1,I2);
result = getPSNR_CUDA(I1,I2);
time = 1000*((double)getTickCount() - time)/getTickFrequency();
time /= TIMES;
cout << "Time of PSNR GPU (averaged for " << TIMES << " runs): " << time << " milliseconds."
cout << "Time of PSNR CUDA (averaged for " << TIMES << " runs): " << time << " milliseconds."
<< " With result of: " << result << endl;
//------------------------------- PSNR GPU Optimized--------------------------------------------
//------------------------------- PSNR CUDA Optimized--------------------------------------------
time = (double)getTickCount(); // Initial call
result = getPSNR_GPU_optimized(I1, I2, bufferPSNR);
result = getPSNR_CUDA_optimized(I1, I2, bufferPSNR);
time = 1000*((double)getTickCount() - time)/getTickFrequency();
cout << "Initial call GPU optimized: " << time <<" milliseconds."
cout << "Initial call CUDA optimized: " << time <<" milliseconds."
<< " With result of: " << result << endl;
time = (double)getTickCount();
for (int i = 0; i < TIMES; ++i)
result = getPSNR_GPU_optimized(I1, I2, bufferPSNR);
result = getPSNR_CUDA_optimized(I1, I2, bufferPSNR);
time = 1000*((double)getTickCount() - time)/getTickFrequency();
time /= TIMES;
cout << "Time of PSNR GPU OPTIMIZED ( / " << TIMES << " runs): " << time
cout << "Time of PSNR CUDA OPTIMIZED ( / " << TIMES << " runs): " << time
<< " milliseconds." << " With result of: " << result << endl << endl;
@@ -133,34 +133,34 @@ int main(int, char *argv[])
cout << "Time of MSSIM CPU (averaged for " << TIMES << " runs): " << time << " milliseconds."
<< " With result of B" << x.val[0] << " G" << x.val[1] << " R" << x.val[2] << endl;
//------------------------------- SSIM GPU -----------------------------------------------------
//------------------------------- SSIM CUDA -----------------------------------------------------
time = (double)getTickCount();
for (int i = 0; i < TIMES; ++i)
x = getMSSIM_GPU(I1,I2);
x = getMSSIM_CUDA(I1,I2);
time = 1000*((double)getTickCount() - time)/getTickFrequency();
time /= TIMES;
cout << "Time of MSSIM GPU (averaged for " << TIMES << " runs): " << time << " milliseconds."
cout << "Time of MSSIM CUDA (averaged for " << TIMES << " runs): " << time << " milliseconds."
<< " With result of B" << x.val[0] << " G" << x.val[1] << " R" << x.val[2] << endl;
//------------------------------- SSIM GPU Optimized--------------------------------------------
//------------------------------- SSIM CUDA Optimized--------------------------------------------
time = (double)getTickCount();
x = getMSSIM_GPU_optimized(I1,I2, bufferMSSIM);
x = getMSSIM_CUDA_optimized(I1,I2, bufferMSSIM);
time = 1000*((double)getTickCount() - time)/getTickFrequency();
cout << "Time of MSSIM GPU Initial Call " << time << " milliseconds."
cout << "Time of MSSIM CUDA Initial Call " << time << " milliseconds."
<< " With result of B" << x.val[0] << " G" << x.val[1] << " R" << x.val[2] << endl;
time = (double)getTickCount();
for (int i = 0; i < TIMES; ++i)
x = getMSSIM_GPU_optimized(I1,I2, bufferMSSIM);
x = getMSSIM_CUDA_optimized(I1,I2, bufferMSSIM);
time = 1000*((double)getTickCount() - time)/getTickFrequency();
time /= TIMES;
cout << "Time of MSSIM GPU OPTIMIZED ( / " << TIMES << " runs): " << time << " milliseconds."
cout << "Time of MSSIM CUDA OPTIMIZED ( / " << TIMES << " runs): " << time << " milliseconds."
<< " With result of B" << x.val[0] << " G" << x.val[1] << " R" << x.val[2] << endl << endl;
return 0;
}
@@ -189,7 +189,7 @@ double getPSNR(const Mat& I1, const Mat& I2)
double getPSNR_GPU_optimized(const Mat& I1, const Mat& I2, BufferPSNR& b)
double getPSNR_CUDA_optimized(const Mat& I1, const Mat& I2, BufferPSNR& b)
{
b.gI1.upload(I1);
b.gI2.upload(I2);
@@ -197,10 +197,10 @@ double getPSNR_GPU_optimized(const Mat& I1, const Mat& I2, BufferPSNR& b)
b.gI1.convertTo(b.t1, CV_32F);
b.gI2.convertTo(b.t2, CV_32F);
gpu::absdiff(b.t1.reshape(1), b.t2.reshape(1), b.gs);
gpu::multiply(b.gs, b.gs, b.gs);
cuda::absdiff(b.t1.reshape(1), b.t2.reshape(1), b.gs);
cuda::multiply(b.gs, b.gs, b.gs);
double sse = gpu::sum(b.gs, b.buf)[0];
double sse = cuda::sum(b.gs, b.buf)[0];
if( sse <= 1e-10) // for small values return zero
return 0;
@@ -212,9 +212,9 @@ double getPSNR_GPU_optimized(const Mat& I1, const Mat& I2, BufferPSNR& b)
}
}
double getPSNR_GPU(const Mat& I1, const Mat& I2)
double getPSNR_CUDA(const Mat& I1, const Mat& I2)
{
gpu::GpuMat gI1, gI2, gs, t1,t2;
cuda::GpuMat gI1, gI2, gs, t1,t2;
gI1.upload(I1);
gI2.upload(I2);
@@ -222,10 +222,10 @@ double getPSNR_GPU(const Mat& I1, const Mat& I2)
gI1.convertTo(t1, CV_32F);
gI2.convertTo(t2, CV_32F);
gpu::absdiff(t1.reshape(1), t2.reshape(1), gs);
gpu::multiply(gs, gs, gs);
cuda::absdiff(t1.reshape(1), t2.reshape(1), gs);
cuda::multiply(gs, gs, gs);
Scalar s = gpu::sum(gs);
Scalar s = cuda::sum(gs);
double sse = s.val[0] + s.val[1] + s.val[2];
if( sse <= 1e-10) // for small values return zero
@@ -291,11 +291,11 @@ Scalar getMSSIM( const Mat& i1, const Mat& i2)
return mssim;
}
Scalar getMSSIM_GPU( const Mat& i1, const Mat& i2)
Scalar getMSSIM_CUDA( const Mat& i1, const Mat& i2)
{
const float C1 = 6.5025f, C2 = 58.5225f;
/***************************** INITS **********************************/
gpu::GpuMat gI1, gI2, gs1, tmp1,tmp2;
cuda::GpuMat gI1, gI2, gs1, tmp1,tmp2;
gI1.upload(i1);
gI2.upload(i2);
@@ -303,64 +303,64 @@ Scalar getMSSIM_GPU( const Mat& i1, const Mat& i2)
gI1.convertTo(tmp1, CV_MAKE_TYPE(CV_32F, gI1.channels()));
gI2.convertTo(tmp2, CV_MAKE_TYPE(CV_32F, gI2.channels()));
vector<gpu::GpuMat> vI1, vI2;
gpu::split(tmp1, vI1);
gpu::split(tmp2, vI2);
vector<cuda::GpuMat> vI1, vI2;
cuda::split(tmp1, vI1);
cuda::split(tmp2, vI2);
Scalar mssim;
Ptr<gpu::Filter> gauss = gpu::createGaussianFilter(vI2[0].type(), -1, Size(11, 11), 1.5);
Ptr<cuda::Filter> gauss = cuda::createGaussianFilter(vI2[0].type(), -1, Size(11, 11), 1.5);
for( int i = 0; i < gI1.channels(); ++i )
{
gpu::GpuMat I2_2, I1_2, I1_I2;
cuda::GpuMat I2_2, I1_2, I1_I2;
gpu::multiply(vI2[i], vI2[i], I2_2); // I2^2
gpu::multiply(vI1[i], vI1[i], I1_2); // I1^2
gpu::multiply(vI1[i], vI2[i], I1_I2); // I1 * I2
cuda::multiply(vI2[i], vI2[i], I2_2); // I2^2
cuda::multiply(vI1[i], vI1[i], I1_2); // I1^2
cuda::multiply(vI1[i], vI2[i], I1_I2); // I1 * I2
/*************************** END INITS **********************************/
gpu::GpuMat mu1, mu2; // PRELIMINARY COMPUTING
cuda::GpuMat mu1, mu2; // PRELIMINARY COMPUTING
gauss->apply(vI1[i], mu1);
gauss->apply(vI2[i], mu2);
gpu::GpuMat mu1_2, mu2_2, mu1_mu2;
gpu::multiply(mu1, mu1, mu1_2);
gpu::multiply(mu2, mu2, mu2_2);
gpu::multiply(mu1, mu2, mu1_mu2);
cuda::GpuMat mu1_2, mu2_2, mu1_mu2;
cuda::multiply(mu1, mu1, mu1_2);
cuda::multiply(mu2, mu2, mu2_2);
cuda::multiply(mu1, mu2, mu1_mu2);
gpu::GpuMat sigma1_2, sigma2_2, sigma12;
cuda::GpuMat sigma1_2, sigma2_2, sigma12;
gauss->apply(I1_2, sigma1_2);
gpu::subtract(sigma1_2, mu1_2, sigma1_2); // sigma1_2 -= mu1_2;
cuda::subtract(sigma1_2, mu1_2, sigma1_2); // sigma1_2 -= mu1_2;
gauss->apply(I2_2, sigma2_2);
gpu::subtract(sigma2_2, mu2_2, sigma2_2); // sigma2_2 -= mu2_2;
cuda::subtract(sigma2_2, mu2_2, sigma2_2); // sigma2_2 -= mu2_2;
gauss->apply(I1_I2, sigma12);
gpu::subtract(sigma12, mu1_mu2, sigma12); // sigma12 -= mu1_mu2;
cuda::subtract(sigma12, mu1_mu2, sigma12); // sigma12 -= mu1_mu2;
///////////////////////////////// FORMULA ////////////////////////////////
gpu::GpuMat t1, t2, t3;
cuda::GpuMat t1, t2, t3;
mu1_mu2.convertTo(t1, -1, 2, C1); // t1 = 2 * mu1_mu2 + C1;
sigma12.convertTo(t2, -1, 2, C2); // t2 = 2 * sigma12 + C2;
gpu::multiply(t1, t2, t3); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))
cuda::multiply(t1, t2, t3); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))
gpu::addWeighted(mu1_2, 1.0, mu2_2, 1.0, C1, t1); // t1 = mu1_2 + mu2_2 + C1;
gpu::addWeighted(sigma1_2, 1.0, sigma2_2, 1.0, C2, t2); // t2 = sigma1_2 + sigma2_2 + C2;
gpu::multiply(t1, t2, t1); // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2))
cuda::addWeighted(mu1_2, 1.0, mu2_2, 1.0, C1, t1); // t1 = mu1_2 + mu2_2 + C1;
cuda::addWeighted(sigma1_2, 1.0, sigma2_2, 1.0, C2, t2); // t2 = sigma1_2 + sigma2_2 + C2;
cuda::multiply(t1, t2, t1); // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2))
gpu::GpuMat ssim_map;
gpu::divide(t3, t1, ssim_map); // ssim_map = t3./t1;
cuda::GpuMat ssim_map;
cuda::divide(t3, t1, ssim_map); // ssim_map = t3./t1;
Scalar s = gpu::sum(ssim_map);
Scalar s = cuda::sum(ssim_map);
mssim.val[i] = s.val[0] / (ssim_map.rows * ssim_map.cols);
}
return mssim;
}
Scalar getMSSIM_GPU_optimized( const Mat& i1, const Mat& i2, BufferMSSIM& b)
Scalar getMSSIM_CUDA_optimized( const Mat& i1, const Mat& i2, BufferMSSIM& b)
{
const float C1 = 6.5025f, C2 = 58.5225f;
/***************************** INITS **********************************/
@@ -368,63 +368,63 @@ Scalar getMSSIM_GPU_optimized( const Mat& i1, const Mat& i2, BufferMSSIM& b)
b.gI1.upload(i1);
b.gI2.upload(i2);
gpu::Stream stream;
cuda::Stream stream;
b.gI1.convertTo(b.t1, CV_32F, stream);
b.gI2.convertTo(b.t2, CV_32F, stream);
gpu::split(b.t1, b.vI1, stream);
gpu::split(b.t2, b.vI2, stream);
cuda::split(b.t1, b.vI1, stream);
cuda::split(b.t2, b.vI2, stream);
Scalar mssim;
Ptr<gpu::Filter> gauss = gpu::createGaussianFilter(b.vI1[0].type(), -1, Size(11, 11), 1.5);
Ptr<cuda::Filter> gauss = cuda::createGaussianFilter(b.vI1[0].type(), -1, Size(11, 11), 1.5);
for( int i = 0; i < b.gI1.channels(); ++i )
{
gpu::multiply(b.vI2[i], b.vI2[i], b.I2_2, 1, -1, stream); // I2^2
gpu::multiply(b.vI1[i], b.vI1[i], b.I1_2, 1, -1, stream); // I1^2
gpu::multiply(b.vI1[i], b.vI2[i], b.I1_I2, 1, -1, stream); // I1 * I2
cuda::multiply(b.vI2[i], b.vI2[i], b.I2_2, 1, -1, stream); // I2^2
cuda::multiply(b.vI1[i], b.vI1[i], b.I1_2, 1, -1, stream); // I1^2
cuda::multiply(b.vI1[i], b.vI2[i], b.I1_I2, 1, -1, stream); // I1 * I2
gauss->apply(b.vI1[i], b.mu1, stream);
gauss->apply(b.vI2[i], b.mu2, stream);
gpu::multiply(b.mu1, b.mu1, b.mu1_2, 1, -1, stream);
gpu::multiply(b.mu2, b.mu2, b.mu2_2, 1, -1, stream);
gpu::multiply(b.mu1, b.mu2, b.mu1_mu2, 1, -1, stream);
cuda::multiply(b.mu1, b.mu1, b.mu1_2, 1, -1, stream);
cuda::multiply(b.mu2, b.mu2, b.mu2_2, 1, -1, stream);
cuda::multiply(b.mu1, b.mu2, b.mu1_mu2, 1, -1, stream);
gauss->apply(b.I1_2, b.sigma1_2, stream);
gpu::subtract(b.sigma1_2, b.mu1_2, b.sigma1_2, gpu::GpuMat(), -1, stream);
cuda::subtract(b.sigma1_2, b.mu1_2, b.sigma1_2, cuda::GpuMat(), -1, stream);
//b.sigma1_2 -= b.mu1_2; - This would result in an extra data transfer operation
gauss->apply(b.I2_2, b.sigma2_2, stream);
gpu::subtract(b.sigma2_2, b.mu2_2, b.sigma2_2, gpu::GpuMat(), -1, stream);
cuda::subtract(b.sigma2_2, b.mu2_2, b.sigma2_2, cuda::GpuMat(), -1, stream);
//b.sigma2_2 -= b.mu2_2;
gauss->apply(b.I1_I2, b.sigma12, stream);
gpu::subtract(b.sigma12, b.mu1_mu2, b.sigma12, gpu::GpuMat(), -1, stream);
cuda::subtract(b.sigma12, b.mu1_mu2, b.sigma12, cuda::GpuMat(), -1, stream);
//b.sigma12 -= b.mu1_mu2;
//here too it would be an extra data transfer due to call of operator*(Scalar, Mat)
gpu::multiply(b.mu1_mu2, 2, b.t1, 1, -1, stream); //b.t1 = 2 * b.mu1_mu2 + C1;
gpu::add(b.t1, C1, b.t1, gpu::GpuMat(), -1, stream);
gpu::multiply(b.sigma12, 2, b.t2, 1, -1, stream); //b.t2 = 2 * b.sigma12 + C2;
gpu::add(b.t2, C2, b.t2, gpu::GpuMat(), -12, stream);
cuda::multiply(b.mu1_mu2, 2, b.t1, 1, -1, stream); //b.t1 = 2 * b.mu1_mu2 + C1;
cuda::add(b.t1, C1, b.t1, cuda::GpuMat(), -1, stream);
cuda::multiply(b.sigma12, 2, b.t2, 1, -1, stream); //b.t2 = 2 * b.sigma12 + C2;
cuda::add(b.t2, C2, b.t2, cuda::GpuMat(), -12, stream);
gpu::multiply(b.t1, b.t2, b.t3, 1, -1, stream); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))
cuda::multiply(b.t1, b.t2, b.t3, 1, -1, stream); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))
gpu::add(b.mu1_2, b.mu2_2, b.t1, gpu::GpuMat(), -1, stream);
gpu::add(b.t1, C1, b.t1, gpu::GpuMat(), -1, stream);
cuda::add(b.mu1_2, b.mu2_2, b.t1, cuda::GpuMat(), -1, stream);
cuda::add(b.t1, C1, b.t1, cuda::GpuMat(), -1, stream);
gpu::add(b.sigma1_2, b.sigma2_2, b.t2, gpu::GpuMat(), -1, stream);
gpu::add(b.t2, C2, b.t2, gpu::GpuMat(), -1, stream);
cuda::add(b.sigma1_2, b.sigma2_2, b.t2, cuda::GpuMat(), -1, stream);
cuda::add(b.t2, C2, b.t2, cuda::GpuMat(), -1, stream);
gpu::multiply(b.t1, b.t2, b.t1, 1, -1, stream); // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2))
gpu::divide(b.t3, b.t1, b.ssim_map, 1, -1, stream); // ssim_map = t3./t1;
cuda::multiply(b.t1, b.t2, b.t1, 1, -1, stream); // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2))
cuda::divide(b.t3, b.t1, b.ssim_map, 1, -1, stream); // ssim_map = t3./t1;
stream.waitForCompletion();
Scalar s = gpu::sum(b.ssim_map, b.buf);
Scalar s = cuda::sum(b.ssim_map, b.buf);
mssim.val[i] = s.val[0] / (b.ssim_map.rows * b.ssim_map.cols);
}
+8 -8
View File
@@ -126,7 +126,7 @@ void printHelp()
" --mosaic-stdev=<float_number>\n"
" Consistent mosaicing stdev threshold. The default is 10.0.\n\n"
" -mi, --motion-inpaint=(yes|no)\n"
" Do motion inpainting (requires GPU support). The default is no.\n"
" Do motion inpainting (requires CUDA support). The default is no.\n"
" --mi-dist-thresh=<float_number>\n"
" Estimated flow distance threshold for motion inpainting. The default is 5.0.\n\n"
" -ci, --color-inpaint=(no|average|ns|telea)\n"
@@ -160,7 +160,7 @@ void printHelp()
" -lm2, --load-motions2=(<file_path>|no)\n"
" Load motions for wobble suppression from file. The default is no.\n\n"
" -gpu=(yes|no)\n"
" Use GPU optimization whenever possible. The default is no.\n\n"
" Use CUDA optimization whenever possible. The default is no.\n\n"
" -o, --output=(no|<file_path>)\n"
" Set output file path explicitely. The default is stabilized.avi.\n"
" --fps=(<float_number>|auto)\n"
@@ -216,7 +216,7 @@ public:
outlierRejector = tblor;
}
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
#if defined(HAVE_OPENCV_CUDAIMGPROC) && defined(HAVE_OPENCV_CUDA) && defined(HAVE_OPENCV_CUDAOPTFLOW)
if (gpu)
{
Ptr<KeypointBasedMotionEstimatorGpu> kbest = makePtr<KeypointBasedMotionEstimatorGpu>(est);
@@ -257,7 +257,7 @@ public:
outlierRejector = tblor;
}
#if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW)
#if defined(HAVE_OPENCV_CUDAIMGPROC) && defined(HAVE_OPENCV_CUDA) && defined(HAVE_OPENCV_CUDAOPTFLOW)
if (gpu)
{
Ptr<KeypointBasedMotionEstimatorGpu> kbest = makePtr<KeypointBasedMotionEstimatorGpu>(est);
@@ -342,12 +342,12 @@ int main(int argc, const char **argv)
return 0;
}
#ifdef HAVE_OPENCV_GPU
#ifdef HAVE_OPENCV_CUDA
if (arg("gpu") == "yes")
{
cout << "initializing GPU..."; cout.flush();
Mat hostTmp = Mat::zeros(1, 1, CV_32F);
gpu::GpuMat deviceTmp;
cuda::GpuMat deviceTmp;
deviceTmp.upload(hostTmp);
cout << endl;
}
@@ -420,10 +420,10 @@ int main(int argc, const char **argv)
{
Ptr<MoreAccurateMotionWobbleSuppressorBase> ws = makePtr<MoreAccurateMotionWobbleSuppressor>();
if (arg("gpu") == "yes")
#ifdef HAVE_OPENCV_GPU
#ifdef HAVE_OPENCV_CUDA
ws = makePtr<MoreAccurateMotionWobbleSuppressorGpu>();
#else
throw runtime_error("OpenCV is built without GPU support");
throw runtime_error("OpenCV is built without CUDA support");
#endif
ws->setMotionEstimator(wsMotionEstBuilder->build());
+15 -14
View File
@@ -1,11 +1,12 @@
SET(OPENCV_GPU_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui
SET(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_gpu
opencv_calib3d opencv_legacy opencv_contrib opencv_cuda
opencv_nonfree opencv_softcascade opencv_superres
opencv_gpuarithm opencv_gpufilters opencv_gpuwarping opencv_gpuimgproc
opencv_gpufeatures2d opencv_gpuoptflow opencv_gpubgsegm
opencv_gpustereo opencv_gpulegacy)
ocv_check_dependencies(${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc
opencv_cudafeatures2d opencv_cudaoptflow opencv_cudabgsegm
opencv_cudastereo opencv_cudalegacy)
ocv_check_dependencies(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
set(project "gpu")
@@ -13,7 +14,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
project("${project}_samples")
ocv_include_modules(${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
ocv_include_modules(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
ocv_include_directories(
"${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia"
"${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/core"
@@ -23,8 +24,8 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/nonfree/include")
endif()
if(HAVE_opencv_gpucodec)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpucodec/include")
if(HAVE_opencv_cudacodec)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudacodec/include")
endif()
if(HAVE_CUDA)
@@ -42,11 +43,11 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
MACRO(OPENCV_DEFINE_GPU_EXAMPLE name srcs)
MACRO(OPENCV_DEFINE_CUDA_EXAMPLE name srcs)
set(the_target "example_${project}_${name}")
add_executable(${the_target} ${srcs})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
if(HAVE_CUDA)
target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY})
@@ -55,8 +56,8 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
if(HAVE_opencv_nonfree)
target_link_libraries(${the_target} opencv_nonfree)
endif()
if(HAVE_opencv_gpucodec)
target_link_libraries(${the_target} opencv_gpucodec)
if(HAVE_opencv_cudacodec)
target_link_libraries(${the_target} opencv_cudacodec)
endif()
if(HAVE_OPENCL)
@@ -84,7 +85,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
foreach(sample_filename ${all_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
OPENCV_DEFINE_GPU_EXAMPLE(${sample} ${sample_srcs})
OPENCV_DEFINE_CUDA_EXAMPLE(${sample} ${sample_srcs})
endforeach()
include("performance/CMakeLists.txt")
+2 -2
View File
@@ -2,11 +2,11 @@
#include "opencv2/core/opengl.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/cudaimgproc.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
int main()
{
+7 -12
View File
@@ -3,18 +3,13 @@
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/gpu.hpp"
#include "opencv2/cudabgsegm.hpp"
#include "opencv2/video.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_NONFREE
# include "opencv2/nonfree/gpu.hpp"
#endif
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
enum Method
{
@@ -75,10 +70,10 @@ int main(int argc, const char** argv)
GpuMat d_frame(frame);
Ptr<BackgroundSubtractor> mog = gpu::createBackgroundSubtractorMOG();
Ptr<BackgroundSubtractor> mog2 = gpu::createBackgroundSubtractorMOG2();
Ptr<BackgroundSubtractor> gmg = gpu::createBackgroundSubtractorGMG(40);
Ptr<BackgroundSubtractor> fgd = gpu::createBackgroundSubtractorFGD();
Ptr<BackgroundSubtractor> mog = cuda::createBackgroundSubtractorMOG();
Ptr<BackgroundSubtractor> mog2 = cuda::createBackgroundSubtractorMOG2();
Ptr<BackgroundSubtractor> gmg = cuda::createBackgroundSubtractorGMG(40);
Ptr<BackgroundSubtractor> fgd = cuda::createBackgroundSubtractorFGD();
GpuMat d_fgmask;
GpuMat d_fgimg;
+6 -4
View File
@@ -6,11 +6,13 @@
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/gpu.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/cudaoptflow.hpp"
#include "opencv2/cudaarithm.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
void getFlowField(const Mat& u, const Mat& v, Mat& flowField);
@@ -64,7 +66,7 @@ int main(int argc, const char* argv[])
return -1;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
cout << "OpenCV / NVIDIA Computer Vision" << endl;
cout << "Optical Flow Demo: Frame Interpolation" << endl;
@@ -161,7 +163,7 @@ int main(int argc, const char* argv[])
interpolateFrames(d_r, d_rt, d_fu, d_fv, d_bu, d_bv, timePos, d_rNew, d_buf);
GpuMat channels3[] = {d_bNew, d_gNew, d_rNew};
merge(channels3, 3, d_newFrame);
cuda::merge(channels3, 3, d_newFrame);
frames.push_back(Mat(d_newFrame));
+9 -7
View File
@@ -10,11 +10,13 @@
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/cuda.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudawarping.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
static void help()
@@ -51,7 +53,7 @@ static void convertAndResize(const GpuMat& src, GpuMat& gray, GpuMat& resized, d
{
if (src.channels() == 3)
{
cv::gpu::cvtColor( src, gray, COLOR_BGR2GRAY );
cv::cuda::cvtColor( src, gray, COLOR_BGR2GRAY );
}
else
{
@@ -62,7 +64,7 @@ static void convertAndResize(const GpuMat& src, GpuMat& gray, GpuMat& resized, d
if (scale != 1)
{
cv::gpu::resize(gray, resized, sz);
cv::cuda::resize(gray, resized, sz);
}
else
{
@@ -128,10 +130,10 @@ int main(int argc, const char *argv[])
if (getCudaEnabledDeviceCount() == 0)
{
return cerr << "No GPU found or the library is compiled without GPU support" << endl, -1;
return cerr << "No GPU found or the library is compiled without CUDA support" << endl, -1;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
string cascadeName;
string inputName;
@@ -170,7 +172,7 @@ int main(int argc, const char *argv[])
}
}
CascadeClassifier_GPU cascade_gpu;
CascadeClassifier_CUDA cascade_gpu;
if (!cascade_gpu.load(cascadeName))
{
return cerr << "ERROR: Could not load cascade classifier \"" << cascadeName << "\"" << endl, help(), -1;
+7 -9
View File
@@ -6,15 +6,13 @@
#include <iostream>
#include <iomanip>
#include <cstdio>
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/cudalegacy.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/objdetect/objdetect_c.h"
#ifdef HAVE_CUDA
#include "opencv2/gpulegacy.hpp"
#endif
using namespace std;
using namespace cv;
@@ -162,10 +160,10 @@ int main(int argc, const char** argv)
cout << "Syntax: exename <cascade_file> <image_or_video_or_cameraid>" << endl;
cout << "=========================================" << endl;
ncvAssertPrintReturn(cv::gpu::getCudaEnabledDeviceCount() != 0, "No GPU found or the library is compiled without GPU support", -1);
ncvAssertPrintReturn(cv::cuda::getCudaEnabledDeviceCount() != 0, "No GPU found or the library is compiled without CUDA support", -1);
ncvAssertPrintReturn(argc == 3, "Invalid number of arguments", -1);
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
string cascadeName = argv[1];
string inputName = argv[2];
+5 -5
View File
@@ -9,7 +9,7 @@
#include <iostream>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/cudaarithm.hpp"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
@@ -49,7 +49,7 @@ int main()
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
struct Worker { void operator()(int device_id) const; };
void destroyContexts();
@@ -80,12 +80,12 @@ int main()
for (int i = 0; i < num_devices; ++i)
{
cv::gpu::printShortCudaDeviceInfo(i);
cv::cuda::printShortCudaDeviceInfo(i);
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{
std::cout << "GPU module isn't built for GPU #" << i << " ("
std::cout << "CUDA module isn't built for GPU #" << i << " ("
<< dev_info.name() << ", CC " << dev_info.majorVersion()
<< dev_info.minorVersion() << "\n";
return -1;
@@ -135,7 +135,7 @@ void Worker::operator()(int device_id) const
// GPU works
GpuMat d_src(src);
GpuMat d_dst;
gpu::transpose(d_src, d_dst);
cuda::transpose(d_src, d_dst);
// Check results
bool passed = cv::norm(dst - Mat(d_dst), NORM_INF) < 1e-3;
+6 -6
View File
@@ -11,7 +11,7 @@
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/cudastereo.hpp"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
@@ -51,7 +51,7 @@ int main()
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
struct Worker { void operator()(int device_id) const; };
void destroyContexts();
@@ -85,7 +85,7 @@ void inline contextOff()
// GPUs data
GpuMat d_left[2];
GpuMat d_right[2];
Ptr<gpu::StereoBM> bm[2];
Ptr<cuda::StereoBM> bm[2];
GpuMat d_result[2];
static void printHelp()
@@ -110,7 +110,7 @@ int main(int argc, char** argv)
for (int i = 0; i < num_devices; ++i)
{
cv::gpu::printShortCudaDeviceInfo(i);
cv::cuda::printShortCudaDeviceInfo(i);
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
@@ -162,14 +162,14 @@ int main(int argc, char** argv)
contextOn(0);
d_left[0].upload(left.rowRange(0, left.rows / 2));
d_right[0].upload(right.rowRange(0, right.rows / 2));
bm[0] = gpu::createStereoBM();
bm[0] = cuda::createStereoBM();
contextOff();
// Split source images for processing on the GPU #1
contextOn(1);
d_left[1].upload(left.rowRange(left.rows / 2, left.rows));
d_right[1].upload(right.rowRange(right.rows / 2, right.rows));
bm[1] = gpu::createStereoBM();
bm[1] = cuda::createStereoBM();
contextOff();
// Execute calculation in two threads using two GPUs
+2 -2
View File
@@ -6,11 +6,11 @@
#include "opencv2/core/utility.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/video.hpp"
#include "opencv2/gpu.hpp"
#include "opencv2/cudaoptflow.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
template <typename T>
inline T mapVal(T x, T a, T b, T c, T d)
+6 -6
View File
@@ -5,7 +5,7 @@
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/gpuimgproc.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/contrib.hpp"
@@ -87,7 +87,7 @@ int main(int argc, const char* argv[])
if (!full)
{
Ptr<GeneralizedHoughBallard> ballard = useGpu ? gpu::createGeneralizedHoughBallard() : createGeneralizedHoughBallard();
Ptr<GeneralizedHoughBallard> ballard = useGpu ? cuda::createGeneralizedHoughBallard() : createGeneralizedHoughBallard();
ballard->setMinDist(minDist);
ballard->setLevels(levels);
@@ -99,7 +99,7 @@ int main(int argc, const char* argv[])
}
else
{
Ptr<GeneralizedHoughGuil> guil = useGpu ? gpu::createGeneralizedHoughGuil() : createGeneralizedHoughGuil();
Ptr<GeneralizedHoughGuil> guil = useGpu ? cuda::createGeneralizedHoughGuil() : createGeneralizedHoughGuil();
guil->setMinDist(minDist);
guil->setLevels(levels);
@@ -126,9 +126,9 @@ int main(int argc, const char* argv[])
if (useGpu)
{
gpu::GpuMat d_templ(templ);
gpu::GpuMat d_image(image);
gpu::GpuMat d_position;
cuda::GpuMat d_templ(templ);
cuda::GpuMat d_image(image);
cuda::GpuMat d_position;
alg->setTemplate(d_templ);
+9 -8
View File
@@ -5,9 +5,10 @@
#include <iomanip>
#include <stdexcept>
#include <opencv2/core/utility.hpp>
#include "opencv2/gpu.hpp"
#include "opencv2/cuda.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/imgproc.hpp"
using namespace std;
using namespace cv;
@@ -194,7 +195,7 @@ Args Args::read(int argc, char** argv)
App::App(const Args& s)
{
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
args = s;
cout << "\nControls:\n"
@@ -246,13 +247,13 @@ void App::run()
// Create HOG descriptors and detectors here
vector<float> detector;
if (win_size == Size(64, 128))
detector = cv::gpu::HOGDescriptor::getPeopleDetector64x128();
detector = cv::cuda::HOGDescriptor::getPeopleDetector64x128();
else
detector = cv::gpu::HOGDescriptor::getPeopleDetector48x96();
detector = cv::cuda::HOGDescriptor::getPeopleDetector48x96();
cv::gpu::HOGDescriptor gpu_hog(win_size, Size(16, 16), Size(8, 8), Size(8, 8), 9,
cv::gpu::HOGDescriptor::DEFAULT_WIN_SIGMA, 0.2, gamma_corr,
cv::gpu::HOGDescriptor::DEFAULT_NLEVELS);
cv::cuda::HOGDescriptor gpu_hog(win_size, Size(16, 16), Size(8, 8), Size(8, 8), 9,
cv::cuda::HOGDescriptor::DEFAULT_WIN_SIGMA, 0.2, gamma_corr,
cv::cuda::HOGDescriptor::DEFAULT_NLEVELS);
cv::HOGDescriptor cpu_hog(win_size, Size(16, 16), Size(8, 8), Size(8, 8), 9, 1, -1,
HOGDescriptor::L2Hys, 0.2, gamma_corr, cv::HOGDescriptor::DEFAULT_NLEVELS);
gpu_hog.setSVMDetector(detector);
@@ -289,7 +290,7 @@ void App::run()
}
Mat img_aux, img, img_to_show;
gpu::GpuMat gpu_img;
cuda::GpuMat gpu_img;
// Iterate over all frames
while (running && !frame.empty())
+3 -3
View File
@@ -5,11 +5,11 @@
#include <opencv2/core/utility.hpp>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/gpu.hpp"
#include "opencv2/cudaimgproc.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
static void help()
{
@@ -59,7 +59,7 @@ int main(int argc, const char* argv[])
{
const int64 start = getTickCount();
Ptr<gpu::HoughSegmentDetector> hough = gpu::createHoughSegmentDetector(1.0f, (float) (CV_PI / 180.0f), 50, 5);
Ptr<cuda::HoughSegmentDetector> hough = cuda::createHoughSegmentDetector(1.0f, (float) (CV_PI / 180.0f), 50, 5);
hough->detect(d_src, d_lines);
+10 -10
View File
@@ -2,8 +2,8 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/gpufilters.hpp"
#include "opencv2/gpuimgproc.hpp"
#include "opencv2/cudafilters.hpp"
#include "opencv2/cudaimgproc.hpp"
using namespace std;
using namespace cv;
@@ -24,7 +24,7 @@ private:
static void OpenCloseCallback(int, void*);
static void ErodeDilateCallback(int, void*);
gpu::GpuMat src, dst;
cuda::GpuMat src, dst;
int element_shape;
@@ -57,14 +57,14 @@ App::App(int argc, const char* argv[])
if (src.channels() == 3)
{
// gpu support only 4th channel images
gpu::GpuMat src4ch;
gpu::cvtColor(src, src4ch, COLOR_BGR2BGRA);
cuda::GpuMat src4ch;
cuda::cvtColor(src, src4ch, COLOR_BGR2BGRA);
src = src4ch;
}
help();
gpu::printShortCudaDeviceInfo(gpu::getDevice());
cuda::printShortCudaDeviceInfo(cuda::getDevice());
}
int App::run()
@@ -132,12 +132,12 @@ void App::OpenClose()
if (n < 0)
{
Ptr<gpu::Filter> openFilter = gpu::createMorphologyFilter(MORPH_OPEN, src.type(), element);
Ptr<cuda::Filter> openFilter = cuda::createMorphologyFilter(MORPH_OPEN, src.type(), element);
openFilter->apply(src, dst);
}
else
{
Ptr<gpu::Filter> closeFilter = gpu::createMorphologyFilter(MORPH_CLOSE, src.type(), element);
Ptr<cuda::Filter> closeFilter = cuda::createMorphologyFilter(MORPH_CLOSE, src.type(), element);
closeFilter->apply(src, dst);
}
@@ -154,12 +154,12 @@ void App::ErodeDilate()
if (n < 0)
{
Ptr<gpu::Filter> erodeFilter = gpu::createMorphologyFilter(MORPH_ERODE, src.type(), element);
Ptr<cuda::Filter> erodeFilter = cuda::createMorphologyFilter(MORPH_ERODE, src.type(), element);
erodeFilter->apply(src, dst);
}
else
{
Ptr<gpu::Filter> dilateFilter = gpu::createMorphologyFilter(MORPH_DILATE, src.type(), element);
Ptr<cuda::Filter> dilateFilter = cuda::createMorphologyFilter(MORPH_DILATE, src.type(), element);
dilateFilter->apply(src, dst);
}
+5 -5
View File
@@ -9,7 +9,7 @@
#include <iostream>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/cudaarithm.hpp"
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
@@ -42,7 +42,7 @@ int main()
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
struct Worker { void operator()(int device_id) const; };
@@ -56,12 +56,12 @@ int main()
}
for (int i = 0; i < num_devices; ++i)
{
cv::gpu::printShortCudaDeviceInfo(i);
cv::cuda::printShortCudaDeviceInfo(i);
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{
std::cout << "GPU module isn't built for GPU #" << i << " ("
std::cout << "CUDA module isn't built for GPU #" << i << " ("
<< dev_info.name() << ", CC " << dev_info.majorVersion()
<< dev_info.minorVersion() << "\n";
return -1;
@@ -92,7 +92,7 @@ void Worker::operator()(int device_id) const
// GPU works
GpuMat d_src(src);
GpuMat d_dst;
gpu::transpose(d_src, d_dst);
cuda::transpose(d_src, d_dst);
// Check results
bool passed = cv::norm(dst - Mat(d_dst), NORM_INF) < 1e-3;
+2 -2
View File
@@ -25,12 +25,12 @@ int main()
#include "opencv2/core/core.hpp"
#include "opencv2/core/opengl.hpp"
#include "opencv2/core/gpu.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
const int win_width = 800;
const int win_height = 640;
+3 -3
View File
@@ -4,11 +4,11 @@
#include "opencv2/core.hpp"
#include <opencv2/core/utility.hpp>
#include "opencv2/highgui.hpp"
#include "opencv2/gpu.hpp"
#include "opencv2/cudaoptflow.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
inline bool isFlowCorrect(Point2f u)
{
@@ -170,7 +170,7 @@ int main(int argc, const char* argv[])
BroxOpticalFlow brox(0.197f, 50.0f, 0.8f, 10, 77, 10);
PyrLKOpticalFlow lk; lk.winSize = Size(7, 7);
FarnebackOpticalFlow farn;
OpticalFlowDual_TVL1_GPU tvl1;
OpticalFlowDual_TVL1_CUDA tvl1;
FastOpticalFlowBM fastBM;
{
+3 -6
View File
@@ -11,14 +11,11 @@
#include "cvconfig.h"
#include <iostream>
#include <iomanip>
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/cudalegacy.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/highgui/highgui_c.h"
#ifdef HAVE_CUDA
#include "opencv2/gpulegacy.hpp"
#endif
#if !defined(HAVE_CUDA)
int main( int, const char** )
{
@@ -393,7 +390,7 @@ int main(int argc, char **argv)
return result;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
std::cout << "OpenCV / NVIDIA Computer Vision\n";
std::cout << "Optical Flow Demo: Frame Interpolation\n";
+4 -4
View File
@@ -8,7 +8,7 @@ if(HAVE_opencv_nonfree)
endif()
add_executable(${the_target} ${sources} ${headers})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
if(HAVE_opencv_nonfree)
target_link_libraries(${the_target} opencv_nonfree)
@@ -16,7 +16,7 @@ endif()
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "performance_gpu"
PROJECT_LABEL "(EXAMPLE_GPU) performance")
PROJECT_LABEL "(EXAMPLE_CUDA) performance")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//gpu")
@@ -27,8 +27,8 @@ if(WIN32)
endif()
if(INSTALL_C_EXAMPLES AND NOT WIN32)
file(GLOB GPU_FILES performance/*.cpp performance/*.h)
install(FILES ${GPU_FILES}
file(GLOB CUDA_FILES performance/*.cpp performance/*.h)
install(FILES ${CUDA_FILES}
DESTINATION share/OpenCV/samples/gpu/performance
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif()
+3 -3
View File
@@ -5,7 +5,7 @@
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
void TestSystem::run()
{
@@ -158,7 +158,7 @@ int main(int argc, const char* argv[])
int num_devices = getCudaEnabledDeviceCount();
if (num_devices == 0)
{
cerr << "No GPU found or the library was compiled without GPU support";
cerr << "No GPU found or the library was compiled without CUDA support";
return -1;
}
@@ -191,7 +191,7 @@ int main(int argc, const char* argv[])
DeviceInfo dev_info(device);
if (!dev_info.isCompatible())
{
cerr << "GPU module isn't built for GPU #" << device << " " << dev_info.name() << ", CC " << dev_info.majorVersion() << '.' << dev_info.minorVersion() << endl;
cerr << "CUDA module isn't built for GPU #" << device << " " << dev_info.name() << ", CC " << dev_info.majorVersion() << '.' << dev_info.minorVersion() << endl;
return -1;
}
setDevice(device);
+6 -6
View File
@@ -1,5 +1,5 @@
#ifndef OPENCV_GPU_SAMPLE_PERFORMANCE_H_
#define OPENCV_GPU_SAMPLE_PERFORMANCE_H_
#ifndef OPENCV_CUDA_SAMPLE_PERFORMANCE_H_
#define OPENCV_CUDA_SAMPLE_PERFORMANCE_H_
#include <iostream>
#include <cstdio>
@@ -7,7 +7,7 @@
#include <numeric>
#include <string>
#include <opencv2/core/utility.hpp>
#include "opencv2/gpu.hpp"
#include "opencv2/cuda.hpp"
#define TAB " "
@@ -172,10 +172,10 @@ private:
TestSystem::instance().cpuOff(); \
} TestSystem::instance().cpuComplete()
#define GPU_ON \
#define CUDA_ON \
while (!TestSystem::instance().stop()) { \
TestSystem::instance().gpuOn()
#define GPU_OFF \
#define CUDA_OFF \
TestSystem::instance().gpuOff(); \
} TestSystem::instance().gpuComplete()
@@ -186,4 +186,4 @@ void gen(cv::Mat& mat, int rows, int cols, int type, cv::Scalar low,
// Returns abs path taking into account test system working dir
std::string abspath(const std::string& relpath);
#endif // OPENCV_GPU_SAMPLE_PERFORMANCE_H_
#endif // OPENCV_CUDA_SAMPLE_PERFORMANCE_H_
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -6,11 +6,12 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/video.hpp"
#include "opencv2/gpu.hpp"
#include "opencv2/cudaoptflow.hpp"
#include "opencv2/cudaimgproc.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
static void download(const GpuMat& d_mat, vector<Point2f>& vec)
{
@@ -179,7 +180,7 @@ int main(int argc, const char* argv[])
GpuMat d_frame0Gray(frame0Gray);
GpuMat d_prevPts;
Ptr<gpu::CornersDetector> detector = gpu::createGoodFeaturesToTrackDetector(d_frame0Gray.type(), points, 0.01, minDist);
Ptr<cuda::CornersDetector> detector = cuda::createGoodFeaturesToTrackDetector(d_frame0Gray.type(), points, 0.01, minDist);
detector->detect(d_frame0Gray, d_prevPts);
+5 -5
View File
@@ -1,5 +1,5 @@
#include <opencv2/core/utility.hpp>
#include <opencv2/gpu.hpp>
#include <opencv2/cuda.hpp>
#include <opencv2/softcascade.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
@@ -33,7 +33,7 @@ int main(int argc, char** argv)
return 1;
}
cv::gpu::setDevice(parser.get<int>("device"));
cv::cuda::setDevice(parser.get<int>("device"));
std::string cascadePath = parser.get<std::string>("cascade");
@@ -67,8 +67,8 @@ int main(int argc, char** argv)
return 1;
}
cv::gpu::GpuMat objects(1, sizeof(Detection) * 10000, CV_8UC1);
cv::gpu::printShortCudaDeviceInfo(parser.get<int>("device"));
cv::cuda::GpuMat objects(1, sizeof(Detection) * 10000, CV_8UC1);
cv::cuda::printShortCudaDeviceInfo(parser.get<int>("device"));
for (;;)
{
cv::Mat frame;
@@ -78,7 +78,7 @@ int main(int argc, char** argv)
return 0;
}
cv::gpu::GpuMat dframe(frame), roi(frame.rows, frame.cols, CV_8UC1);
cv::cuda::GpuMat dframe(frame), roi(frame.rows, frame.cols, CV_8UC1);
roi.setTo(cv::Scalar::all(1));
cascade.detect(dframe, roi, objects);
+11 -10
View File
@@ -4,8 +4,9 @@
#include <iomanip>
#include <stdexcept>
#include <opencv2/core/utility.hpp>
#include "opencv2/gpu.hpp"
#include "opencv2/cudastereo.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
using namespace cv;
using namespace std;
@@ -63,11 +64,11 @@ private:
Mat left_src, right_src;
Mat left, right;
gpu::GpuMat d_left, d_right;
cuda::GpuMat d_left, d_right;
Ptr<gpu::StereoBM> bm;
Ptr<gpu::StereoBeliefPropagation> bp;
Ptr<gpu::StereoConstantSpaceBP> csbp;
Ptr<cuda::StereoBM> bm;
Ptr<cuda::StereoBeliefPropagation> bp;
Ptr<cuda::StereoConstantSpaceBP> csbp;
int64 work_begin;
double work_fps;
@@ -140,7 +141,7 @@ Params Params::read(int argc, char** argv)
App::App(const Params& params)
: p(params), running(false)
{
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
cout << "stereo_match_gpu sample\n";
cout << "\nControls:\n"
@@ -172,13 +173,13 @@ void App::run()
imshow("right", right);
// Set common parameters
bm = gpu::createStereoBM(p.ndisp);
bp = gpu::createStereoBeliefPropagation(p.ndisp);
csbp = cv::gpu::createStereoConstantSpaceBP(p.ndisp);
bm = cuda::createStereoBM(p.ndisp);
bp = cuda::createStereoBeliefPropagation(p.ndisp);
csbp = cv::cuda::createStereoConstantSpaceBP(p.ndisp);
// Prepare disparity map of specified type
Mat disp(left.size(), CV_8U);
gpu::GpuMat d_disp(left.size(), CV_8U);
cuda::GpuMat d_disp(left.size(), CV_8U);
cout << endl;
printParams();
+28 -28
View File
@@ -16,11 +16,11 @@
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/gpustereo.hpp"
#include "opencv2/cudastereo.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
///////////////////////////////////////////////////////////
// Thread
@@ -132,18 +132,18 @@ private:
GpuMat d_leftFrame;
GpuMat d_rightFrame;
GpuMat d_disparity;
Ptr<gpu::StereoBM> d_alg;
Ptr<cuda::StereoBM> d_alg;
};
StereoSingleGpu::StereoSingleGpu(int deviceId) : deviceId_(deviceId)
{
gpu::setDevice(deviceId_);
d_alg = gpu::createStereoBM(256);
cuda::setDevice(deviceId_);
d_alg = cuda::createStereoBM(256);
}
StereoSingleGpu::~StereoSingleGpu()
{
gpu::setDevice(deviceId_);
cuda::setDevice(deviceId_);
d_leftFrame.release();
d_rightFrame.release();
d_disparity.release();
@@ -152,7 +152,7 @@ StereoSingleGpu::~StereoSingleGpu()
void StereoSingleGpu::compute(const Mat& leftFrame, const Mat& rightFrame, Mat& disparity)
{
gpu::setDevice(deviceId_);
cuda::setDevice(deviceId_);
d_leftFrame.upload(leftFrame);
d_rightFrame.upload(rightFrame);
d_alg->compute(d_leftFrame, d_rightFrame, d_disparity);
@@ -175,7 +175,7 @@ private:
GpuMat d_leftFrames[2];
GpuMat d_rightFrames[2];
GpuMat d_disparities[2];
Ptr<gpu::StereoBM> d_algs[2];
Ptr<cuda::StereoBM> d_algs[2];
struct StereoLaunchData
{
@@ -186,7 +186,7 @@ private:
GpuMat* d_leftFrame;
GpuMat* d_rightFrame;
GpuMat* d_disparity;
Ptr<gpu::StereoBM> d_alg;
Ptr<cuda::StereoBM> d_alg;
};
static void launchGpuStereoAlg(void* userData);
@@ -194,22 +194,22 @@ private:
StereoMultiGpuThread::StereoMultiGpuThread()
{
gpu::setDevice(0);
d_algs[0] = gpu::createStereoBM(256);
cuda::setDevice(0);
d_algs[0] = cuda::createStereoBM(256);
gpu::setDevice(1);
d_algs[1] = gpu::createStereoBM(256);
cuda::setDevice(1);
d_algs[1] = cuda::createStereoBM(256);
}
StereoMultiGpuThread::~StereoMultiGpuThread()
{
gpu::setDevice(0);
cuda::setDevice(0);
d_leftFrames[0].release();
d_rightFrames[0].release();
d_disparities[0].release();
d_algs[0].release();
gpu::setDevice(1);
cuda::setDevice(1);
d_leftFrames[1].release();
d_rightFrames[1].release();
d_disparities[1].release();
@@ -256,7 +256,7 @@ void StereoMultiGpuThread::launchGpuStereoAlg(void* userData)
{
StereoLaunchData* data = static_cast<StereoLaunchData*>(userData);
gpu::setDevice(data->deviceId);
cuda::setDevice(data->deviceId);
data->d_leftFrame->upload(data->leftFrame);
data->d_rightFrame->upload(data->rightFrame);
data->d_alg->compute(*data->d_leftFrame, *data->d_rightFrame, *data->d_disparity);
@@ -283,31 +283,31 @@ private:
GpuMat d_leftFrames[2];
GpuMat d_rightFrames[2];
GpuMat d_disparities[2];
Ptr<gpu::StereoBM> d_algs[2];
Ptr<cuda::StereoBM> d_algs[2];
Ptr<Stream> streams[2];
};
StereoMultiGpuStream::StereoMultiGpuStream()
{
gpu::setDevice(0);
d_algs[0] = gpu::createStereoBM(256);
cuda::setDevice(0);
d_algs[0] = cuda::createStereoBM(256);
streams[0] = makePtr<Stream>();
gpu::setDevice(1);
d_algs[1] = gpu::createStereoBM(256);
cuda::setDevice(1);
d_algs[1] = cuda::createStereoBM(256);
streams[1] = makePtr<Stream>();
}
StereoMultiGpuStream::~StereoMultiGpuStream()
{
gpu::setDevice(0);
cuda::setDevice(0);
d_leftFrames[0].release();
d_rightFrames[0].release();
d_disparities[0].release();
d_algs[0].release();
streams[0].release();
gpu::setDevice(1);
cuda::setDevice(1);
d_leftFrames[1].release();
d_rightFrames[1].release();
d_disparities[1].release();
@@ -330,22 +330,22 @@ void StereoMultiGpuStream::compute(const CudaMem& leftFrame, const CudaMem& righ
Mat disparityPart0 = disparityHdr.rowRange(0, leftFrame.rows / 2);
Mat disparityPart1 = disparityHdr.rowRange(leftFrame.rows / 2, leftFrame.rows);
gpu::setDevice(0);
cuda::setDevice(0);
d_leftFrames[0].upload(leftFrameHdr.rowRange(0, leftFrame.rows / 2 + 32), *streams[0]);
d_rightFrames[0].upload(rightFrameHdr.rowRange(0, leftFrame.rows / 2 + 32), *streams[0]);
d_algs[0]->compute(d_leftFrames[0], d_rightFrames[0], d_disparities[0], *streams[0]);
d_disparities[0].rowRange(0, leftFrame.rows / 2).download(disparityPart0, *streams[0]);
gpu::setDevice(1);
cuda::setDevice(1);
d_leftFrames[1].upload(leftFrameHdr.rowRange(leftFrame.rows / 2 - 32, leftFrame.rows), *streams[1]);
d_rightFrames[1].upload(rightFrameHdr.rowRange(leftFrame.rows / 2 - 32, leftFrame.rows), *streams[1]);
d_algs[1]->compute(d_leftFrames[1], d_rightFrames[1], d_disparities[1], *streams[1]);
d_disparities[1].rowRange(32, d_disparities[1].rows).download(disparityPart1, *streams[1]);
gpu::setDevice(0);
cuda::setDevice(0);
streams[0]->waitForCompletion();
gpu::setDevice(1);
cuda::setDevice(1);
streams[1]->waitForCompletion();
}
@@ -372,7 +372,7 @@ int main(int argc, char** argv)
DeviceInfo devInfo(i);
if (!devInfo.isCompatible())
{
cerr << "GPU module was't built for GPU #" << i << " ("
cerr << "CUDA module was't built for GPU #" << i << " ("
<< devInfo.name() << ", CC " << devInfo.majorVersion()
<< devInfo.minorVersion() << endl;
return -1;
+6 -6
View File
@@ -32,7 +32,7 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
if (name == "farneback")
{
if (useGpu)
return createOptFlow_Farneback_GPU();
return createOptFlow_Farneback_CUDA();
else
return createOptFlow_Farneback();
}
@@ -41,14 +41,14 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
else if (name == "tvl1")
{
if (useGpu)
return createOptFlow_DualTVL1_GPU();
return createOptFlow_DualTVL1_CUDA();
else
return createOptFlow_DualTVL1();
}
else if (name == "brox")
return createOptFlow_Brox_GPU();
return createOptFlow_Brox_CUDA();
else if (name == "pyrlk")
return createOptFlow_PyrLK_GPU();
return createOptFlow_PyrLK_CUDA();
else
{
cerr << "Incorrect Optical Flow algorithm - " << name << endl;
@@ -167,7 +167,7 @@ int main(int argc, const char* argv[])
#endif
{
if (useCuda)
superRes = createSuperResolution_BTVL1_GPU();
superRes = createSuperResolution_BTVL1_CUDA();
else
superRes = createSuperResolution_BTVL1();
@@ -188,7 +188,7 @@ int main(int argc, const char* argv[])
// Try to use gpu Video Decoding
try
{
frameSource = createFrameSource_Video_GPU(inputVideoName);
frameSource = createFrameSource_Video_CUDA(inputVideoName);
Mat frame;
frameSource->nextFrame(frame);
}
+8 -8
View File
@@ -7,16 +7,16 @@
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/nonfree/gpu.hpp"
#include "opencv2/cudafeatures2d.hpp"
#include "opencv2/nonfree/cuda.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cv::cuda;
static void help()
{
cout << "\nThis program demonstrates using SURF_GPU features detector, descriptor extractor and BruteForceMatcher_GPU" << endl;
cout << "\nThis program demonstrates using SURF_CUDA features detector, descriptor extractor and BruteForceMatcher_CUDA" << endl;
cout << "\nUsage:\n\tmatcher_simple_gpu --left <image1> --right <image2>" << endl;
}
@@ -48,9 +48,9 @@ int main(int argc, char* argv[])
}
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
SURF_GPU surf;
SURF_CUDA surf;
// detecting keypoints & computing descriptors
GpuMat keypoints1GPU, keypoints2GPU;
@@ -62,7 +62,7 @@ int main(int argc, char* argv[])
cout << "FOUND " << keypoints2GPU.cols << " keypoints on second image" << endl;
// matching descriptors
BFMatcher_GPU matcher(NORM_L2);
BFMatcher_CUDA matcher(NORM_L2);
GpuMat trainIdx, distance;
matcher.matchSingle(descriptors1GPU, descriptors2GPU, trainIdx, distance);
@@ -74,7 +74,7 @@ int main(int argc, char* argv[])
surf.downloadKeypoints(keypoints2GPU, keypoints2);
surf.downloadDescriptors(descriptors1GPU, descriptors1);
surf.downloadDescriptors(descriptors2GPU, descriptors2);
BFMatcher_GPU::matchDownload(trainIdx, distance, matches);
BFMatcher_CUDA::matchDownload(trainIdx, distance, matches);
// drawing the results
Mat img_matches;
+6 -6
View File
@@ -2,7 +2,7 @@
#include "opencv2/opencv_modules.hpp"
#if defined(HAVE_OPENCV_GPUCODEC)
#if defined(HAVE_OPENCV_CUDACODEC)
#include <string>
#include <vector>
@@ -11,7 +11,7 @@
#include <opencv2/core.hpp>
#include <opencv2/core/opengl.hpp>
#include <opencv2/gpucodec.hpp>
#include <opencv2/cudacodec.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/contrib.hpp>
@@ -24,13 +24,13 @@ int main(int argc, const char* argv[])
cv::namedWindow("CPU", cv::WINDOW_NORMAL);
cv::namedWindow("GPU", cv::WINDOW_OPENGL);
cv::gpu::setGlDevice();
cv::cuda::setGlDevice();
cv::Mat frame;
cv::VideoCapture reader(fname);
cv::gpu::GpuMat d_frame;
cv::Ptr<cv::gpucodec::VideoReader> d_reader = cv::gpucodec::createVideoReader(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;
@@ -78,7 +78,7 @@ int main(int argc, const char* argv[])
int main()
{
std::cout << "OpenCV was built without GPU Video decoding support\n" << std::endl;
std::cout << "OpenCV was built without CUDA Video decoding support\n" << std::endl;
return 0;
}
+8 -8
View File
@@ -2,13 +2,13 @@
#include "opencv2/opencv_modules.hpp"
#if defined(HAVE_OPENCV_GPUCODEC) && defined(WIN32)
#if defined(HAVE_OPENCV_CUDACODEC) && defined(WIN32)
#include <vector>
#include <numeric>
#include "opencv2/core.hpp"
#include "opencv2/gpucodec.hpp"
#include "opencv2/cudacodec.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/contrib.hpp"
@@ -30,13 +30,13 @@ int main(int argc, const char* argv[])
return -1;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cv::cuda::printShortCudaDeviceInfo(cv::cuda::getDevice());
cv::VideoWriter writer;
cv::Ptr<cv::gpucodec::VideoWriter> d_writer;
cv::Ptr<cv::cudacodec::VideoWriter> d_writer;
cv::Mat frame;
cv::gpu::GpuMat d_frame;
cv::cuda::GpuMat d_frame;
std::vector<double> cpu_times;
std::vector<double> gpu_times;
@@ -66,9 +66,9 @@ int main(int argc, const char* argv[])
if (d_writer.empty())
{
std::cout << "Open GPU Writer" << std::endl;
std::cout << "Open CUDA Writer" << std::endl;
d_writer = cv::gpucodec::createVideoWriter("output_gpu.avi", frame.size(), FPS);
d_writer = cv::cudacodec::createVideoWriter("output_gpu.avi", frame.size(), FPS);
}
d_frame.upload(frame);
@@ -104,7 +104,7 @@ int main(int argc, const char* argv[])
int main()
{
std::cout << "OpenCV was built without GPU Video encoding support\n" << std::endl;
std::cout << "OpenCV was built without CUDA Video encoding support\n" << std::endl;
return 0;
}