Merge remote-tracking branch 'origin/2.4' into merge-2.4

Conflicts:
	cmake/OpenCVModule.cmake
	doc/tutorials/calib3d/camera_calibration/camera_calibration.rst
	doc/tutorials/features2d/feature_detection/feature_detection.rst
	doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.rst
	doc/tutorials/features2d/feature_homography/feature_homography.rst
	modules/core/include/opencv2/core/operations.hpp
	modules/core/src/arithm.cpp
	modules/gpu/perf/perf_video.cpp
	modules/imgproc/include/opencv2/imgproc/imgproc.hpp
	modules/java/generator/gen_java.py
	modules/java/generator/src/cpp/VideoCapture.cpp
	modules/nonfree/src/opencl/surf.cl
	modules/ocl/include/opencv2/ocl/ocl.hpp
	modules/ocl/perf/perf_haar.cpp
	modules/ocl/perf/perf_precomp.hpp
	modules/ocl/src/color.cpp
	modules/ocl/src/filtering.cpp
	modules/ocl/test/test_color.cpp
	modules/ocl/test/test_objdetect.cpp
	modules/python/src2/cv2.cpp
	samples/gpu/CMakeLists.txt
	samples/gpu/super_resolution.cpp
This commit is contained in:
Roman Donchenko
2013-08-19 14:08:34 +04:00
148 changed files with 1855 additions and 2753 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ static int mushroom_read_database( const char* filename, CvMat** data, CvMat** m
}
cvReleaseMemStorage( &storage );
delete el_ptr;
delete [] el_ptr;
return 1;
}
@@ -15,7 +15,6 @@ using namespace cv;
Mat src, dst;
int top, bottom, left, right;
int borderType;
Scalar value;
const char* window_name = "copyMakeBorder Demo";
RNG rng(12345);
@@ -64,7 +63,7 @@ int main( int, char** argv )
else if( (char)c == 'r' )
{ borderType = BORDER_REPLICATE; }
value = Scalar( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
Scalar value( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
copyMakeBorder( src, dst, top, bottom, left, right, borderType, value );
imshow( window_name, dst );
+8 -2
View File
@@ -5,7 +5,6 @@ SET(OPENCV_GPU_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc ope
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})
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
@@ -32,6 +31,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
ocv_include_directories(${CUDA_INCLUDE_DIRS})
endif()
if(HAVE_OPENCL)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/ocl/include")
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
@@ -51,6 +54,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
target_link_libraries(${the_target} opencv_gpucodec)
endif()
if(HAVE_OPENCL)
target_link_libraries(${the_target} opencv_ocl)
endif()
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${project}-example-${name}"
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
@@ -84,4 +91,3 @@ if (INSTALL_C_EXAMPLES AND NOT WIN32)
DESTINATION share/OpenCV/samples/${project}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif()
+128 -16
View File
@@ -8,11 +8,16 @@
#include "opencv2/contrib.hpp"
#include "opencv2/superres.hpp"
#include "opencv2/superres/optical_flow.hpp"
#include "opencv2/opencv_modules.hpp"
#if defined(HAVE_OPENCV_OCL)
#include "opencv2/ocl/ocl.hpp"
#endif
using namespace std;
using namespace cv;
using namespace cv::superres;
bool useOclChanged;
#define MEASURE_TIME(op) \
{ \
TickMeter tm; \
@@ -50,9 +55,38 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
}
return 0;
}
#if defined(HAVE_OPENCV_OCL)
static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name)
{
if (name == "farneback")
{
return createOptFlow_Farneback_OCL();
}
else if (name == "simple")
{
useOclChanged = true;
std::cout<<"simple on OpenCL has not been implemented. Use CPU instead!\n";
return createOptFlow_Simple();
}
else if (name == "tvl1")
return createOptFlow_DualTVL1_OCL();
else if (name == "brox")
{
std::cout<<"brox has not been implemented!\n";
return NULL;
}
else if (name == "pyrlk")
return createOptFlow_PyrLK_OCL();
else
{
cerr << "Incorrect Optical Flow algorithm - " << name << endl;
}
return 0;
}
#endif
int main(int argc, const char* argv[])
{
useOclChanged = false;
CommandLineParser cmd(argc, argv,
"{ v video | | Input video }"
"{ o output | | Output video }"
@@ -60,7 +94,7 @@ int main(int argc, const char* argv[])
"{ i iterations | 180 | Iteration count }"
"{ t temporal | 4 | Radius of the temporal search area }"
"{ f flow | farneback | Optical flow algorithm (farneback, simple, tvl1, brox, pyrlk) }"
"{ gpu | false | Use GPU }"
"{ g | false | CPU as default device, cuda for CUDA and ocl for OpenCL }"
"{ h help | false | Print help message }"
);
@@ -77,25 +111,79 @@ int main(int argc, const char* argv[])
const int iterations = cmd.get<int>("iterations");
const int temporalAreaRadius = cmd.get<int>("temporal");
const string optFlow = cmd.get<string>("flow");
const bool useGpu = cmd.get<bool>("gpu");
string gpuOption = cmd.get<string>("gpu");
std::transform(gpuOption.begin(), gpuOption.end(), gpuOption.begin(), ::tolower);
bool useCuda = false;
bool useOcl = false;
if(gpuOption.compare("ocl") == 0)
useOcl = true;
else if(gpuOption.compare("cuda") == 0)
useCuda = true;
#ifndef HAVE_OPENCV_OCL
if(useOcl)
{
{
cout<<"OPENCL is not compiled\n";
return 0;
}
}
#endif
#if defined(HAVE_OPENCV_OCL)
std::vector<cv::ocl::Info>info;
if(useCuda)
{
CV_Assert(!useOcl);
info.clear();
}
if(useOcl)
{
CV_Assert(!useCuda);
cv::ocl::getDevice(info);
}
#endif
Ptr<SuperResolution> superRes;
if (useGpu)
superRes = createSuperResolution_BTVL1_GPU();
#if defined(HAVE_OPENCV_OCL)
if(useOcl)
{
Ptr<DenseOpticalFlowExt> of = createOptFlow(optFlow);
if (of.empty())
exit(-1);
if(useOclChanged)
{
superRes = createSuperResolution_BTVL1();
useOcl = !useOcl;
}else
superRes = createSuperResolution_BTVL1_OCL();
superRes->set("opticalFlow", of);
}
else
superRes = createSuperResolution_BTVL1();
#endif
{
if (useCuda)
superRes = createSuperResolution_BTVL1_GPU();
else
superRes = createSuperResolution_BTVL1();
Ptr<DenseOpticalFlowExt> of = createOptFlow(optFlow, useCuda);
if (of.empty())
exit(-1);
superRes->set("opticalFlow", of);
}
superRes->set("scale", scale);
superRes->set("iterations", iterations);
superRes->set("temporalAreaRadius", temporalAreaRadius);
Ptr<DenseOpticalFlowExt> of = createOptFlow(optFlow, useGpu);
if (of.empty())
exit(-1);
superRes->set("opticalFlow", of);
Ptr<FrameSource> frameSource;
if (useGpu)
if (useCuda)
{
// Try to use gpu Video Decoding
try
@@ -121,7 +209,11 @@ int main(int argc, const char* argv[])
cout << "Iterations : " << iterations << endl;
cout << "Temporal radius : " << temporalAreaRadius << endl;
cout << "Optical Flow : " << optFlow << endl;
cout << "Mode : " << (useGpu ? "GPU" : "CPU") << endl;
#if defined(HAVE_OPENCV_OCL)
cout << "Mode : " << (useCuda ? "CUDA" : useOcl? "OpenCL" : "CPU") << endl;
#else
cout << "Mode : " << (useGpu ? "CUDA" : "CPU") << endl;
#endif
}
superRes->setInput(frameSource);
@@ -131,10 +223,30 @@ int main(int argc, const char* argv[])
for (int i = 0;; ++i)
{
cout << '[' << setw(3) << i << "] : ";
Mat result;
MEASURE_TIME(superRes->nextFrame(result));
#if defined(HAVE_OPENCV_OCL)
cv::ocl::oclMat result_;
if(useOcl)
{
MEASURE_TIME(superRes->nextFrame(result_));
}
else
#endif
{
MEASURE_TIME(superRes->nextFrame(result));
}
#ifdef HAVE_OPENCV_OCL
if(useOcl)
{
if(!result_.empty())
{
result_.download(result);
}
}
#endif
if (result.empty())
break;