mirror of
https://github.com/opencv/opencv.git
synced 2024-12-29 04:28:17 +08:00
dcaf923517
Conflicts: 3rdparty/ffmpeg/ffmpeg_version.cmake cmake/OpenCVFindLibsGrfmt.cmake cmake/templates/cvconfig.h.cmake modules/bioinspired/doc/retina/index.rst modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst modules/calib3d/src/precomp.hpp modules/contrib/src/inputoutput.cpp modules/contrib/src/precomp.hpp modules/core/include/opencv2/core/internal.hpp modules/core/include/opencv2/core/types_c.h modules/core/src/drawing.cpp modules/core/src/precomp.hpp modules/core/src/system.cpp modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst modules/features2d/doc/common_interfaces_of_feature_detectors.rst modules/features2d/include/opencv2/features2d/features2d.hpp modules/features2d/src/precomp.hpp modules/flann/src/precomp.hpp modules/gpu/doc/camera_calibration_and_3d_reconstruction.rst modules/gpu/doc/image_filtering.rst modules/gpu/doc/image_processing.rst modules/gpu/doc/video.rst modules/gpu/perf/perf_imgproc.cpp modules/gpu/perf4au/main.cpp modules/gpu/src/imgproc.cpp modules/gpu/src/precomp.hpp modules/gpu/test/test_imgproc.cpp modules/highgui/CMakeLists.txt modules/highgui/test/test_precomp.hpp modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst modules/imgproc/src/precomp.hpp modules/java/generator/src/cpp/Mat.cpp modules/legacy/src/precomp.hpp modules/ml/doc/k_nearest_neighbors.rst modules/ml/src/precomp.hpp modules/nonfree/doc/feature_detection.rst modules/nonfree/src/precomp.hpp modules/objdetect/include/opencv2/objdetect/objdetect.hpp modules/objdetect/src/cascadedetect.cpp modules/objdetect/src/hog.cpp modules/objdetect/src/precomp.hpp modules/objdetect/test/test_latentsvmdetector.cpp modules/ocl/src/hog.cpp modules/ocl/src/opencl/objdetect_hog.cl modules/ocl/src/precomp.hpp modules/photo/src/precomp.hpp modules/stitching/src/precomp.hpp modules/superres/perf/perf_precomp.hpp modules/superres/src/optical_flow.cpp modules/superres/src/precomp.hpp modules/superres/test/test_precomp.hpp modules/ts/include/opencv2/ts.hpp modules/video/src/precomp.hpp modules/videostab/src/precomp.hpp modules/world/src/precomp.hpp
147 lines
4.6 KiB
C++
147 lines
4.6 KiB
C++
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
//
|
|
// By downloading, copying, installing or using the software you agree to this license.
|
|
// If you do not agree to this license, do not download, install,
|
|
// copy or use the software.
|
|
//
|
|
//
|
|
// License Agreement
|
|
// For Open Source Computer Vision Library
|
|
//
|
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
|
// Third party copyrights are property of their respective owners.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without modification,
|
|
// are permitted provided that the following conditions are met:
|
|
//
|
|
// * Redistribution's of source code must retain the above copyright notice,
|
|
// this list of conditions and the following disclaimer.
|
|
//
|
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
// and/or other materials provided with the distribution.
|
|
//
|
|
// * The name of the copyright holders may not be used to endorse or promote products
|
|
// derived from this software without specific prior written permission.
|
|
//
|
|
// This software is provided by the copyright holders and contributors "as is" and
|
|
// any express or implied warranties, including, but not limited to, the implied
|
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
// indirect, incidental, special, exemplary, or consequential damages
|
|
// (including, but not limited to, procurement of substitute goods or services;
|
|
// loss of use, data, or profits; or business interruption) however caused
|
|
// and on any theory of liability, whether in contract, strict liability,
|
|
// or tort (including negligence or otherwise) arising in any way out of
|
|
// the use of this software, even if advised of the possibility of such damage.
|
|
//
|
|
//M*/
|
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
#ifdef HAVE_OPENCL
|
|
|
|
#include "opencv2/ocl.hpp"
|
|
using namespace std;
|
|
using namespace testing;
|
|
using namespace perf;
|
|
using namespace cv;
|
|
using namespace cv::superres;
|
|
|
|
namespace
|
|
{
|
|
class OneFrameSource_OCL : public FrameSource
|
|
{
|
|
public:
|
|
explicit OneFrameSource_OCL(const ocl::oclMat& frame) : frame_(frame) {}
|
|
|
|
void nextFrame(OutputArray frame)
|
|
{
|
|
ocl::getOclMatRef(frame) = frame_;
|
|
}
|
|
void reset()
|
|
{
|
|
}
|
|
|
|
private:
|
|
ocl::oclMat frame_;
|
|
};
|
|
|
|
|
|
class ZeroOpticalFlowOCL : public DenseOpticalFlowExt
|
|
{
|
|
public:
|
|
void calc(InputArray frame0, InputArray, OutputArray flow1, OutputArray flow2)
|
|
{
|
|
ocl::oclMat& frame0_ = ocl::getOclMatRef(frame0);
|
|
ocl::oclMat& flow1_ = ocl::getOclMatRef(flow1);
|
|
ocl::oclMat& flow2_ = ocl::getOclMatRef(flow2);
|
|
|
|
cv::Size size = frame0_.size();
|
|
|
|
if(!flow2.needed())
|
|
{
|
|
flow1_.create(size, CV_32FC2);
|
|
flow1_.setTo(Scalar::all(0));
|
|
}
|
|
else
|
|
{
|
|
flow1_.create(size, CV_32FC1);
|
|
flow2_.create(size, CV_32FC1);
|
|
|
|
flow1_.setTo(Scalar::all(0));
|
|
flow2_.setTo(Scalar::all(0));
|
|
}
|
|
}
|
|
|
|
void collectGarbage()
|
|
{
|
|
}
|
|
};
|
|
}
|
|
|
|
PERF_TEST_P(Size_MatType, SuperResolution_BTVL1_OCL,
|
|
Combine(Values(szSmall64, szSmall128),
|
|
Values(MatType(CV_8UC1), MatType(CV_8UC3))))
|
|
{
|
|
std::vector<cv::ocl::Info>info;
|
|
cv::ocl::getDevice(info);
|
|
|
|
declare.time(5 * 60);
|
|
|
|
const Size size = std::tr1::get<0>(GetParam());
|
|
const int type = std::tr1::get<1>(GetParam());
|
|
|
|
Mat frame(size, type);
|
|
declare.in(frame, WARMUP_RNG);
|
|
|
|
ocl::oclMat frame_ocl;
|
|
frame_ocl.upload(frame);
|
|
|
|
|
|
const int scale = 2;
|
|
const int iterations = 50;
|
|
const int temporalAreaRadius = 1;
|
|
Ptr<DenseOpticalFlowExt> opticalFlowOcl(new ZeroOpticalFlowOCL);
|
|
|
|
Ptr<SuperResolution> superRes_ocl = createSuperResolution_BTVL1_OCL();
|
|
|
|
superRes_ocl->set("scale", scale);
|
|
superRes_ocl->set("iterations", iterations);
|
|
superRes_ocl->set("temporalAreaRadius", temporalAreaRadius);
|
|
superRes_ocl->set("opticalFlow", opticalFlowOcl);
|
|
|
|
superRes_ocl->setInput(new OneFrameSource_OCL(frame_ocl));
|
|
|
|
ocl::oclMat dst_ocl;
|
|
superRes_ocl->nextFrame(dst_ocl);
|
|
|
|
TEST_CYCLE_N(10) superRes_ocl->nextFrame(dst_ocl);
|
|
frame_ocl.release();
|
|
CPU_SANITY_CHECK(dst_ocl);
|
|
}
|
|
#endif
|