mirror of
https://github.com/opencv/opencv.git
synced 2024-12-29 04:28:17 +08:00
13cd0a0502
Original pull requests: #996 from jet47:gpu-nvcuvid-libraries #995 from jet47:fix-bug-2985 #999 from snosov1:unreliable-results-fix #1005 from alekcac:doc_fix #1004 from jet47:fix-bug-3068 #987 from jet47:bug-3085-fix #969 from pengx17:2.4_binary_cache #929 from dominikrose:mingw-libdc1394-2-windows #1000 from ivan-korolev:fix_sift_bug_2892 #1001 from ivan-korolev:fix_stitching_bug_2405 #998 from asmorkalov:android_cmake_mips_fix #993 from ivan-korolev:fix_videostab_bug_3023 #988 from snosov1:3071-fix #986 from pengx17:2.4_initiated_context #982 from pengx17:2.4_fix_two_bugs #981 from SeninAndrew:ximea_camera_support_fix #991 from asmorkalov:android_javadoc_fix #972 from jet47:mog2-params-bug-2168 #980 from SpecLad:include-config #973 from pengx17:2.4_oclclahe #903 from aks2:2.4 #968 from asmorkalov:android_na_cproj_fix #971 from SpecLad:matchers-ctor #970 from asmorkalov:dshow_valid_check_fix #965 from apavlenko:fix_java_empty_mats Conflicts: cmake/OpenCVModule.cmake modules/core/src/matmul.cpp modules/gpu/CMakeLists.txt modules/ocl/include/opencv2/ocl/ocl.hpp modules/ocl/perf/perf_imgproc.cpp modules/ocl/src/imgproc.cpp modules/ocl/src/initialization.cpp modules/stitching/src/matchers.cpp modules/video/src/video_init.cpp modules/videostab/src/global_motion.cpp
222 lines
7.5 KiB
C++
222 lines
7.5 KiB
C++
#include "perf_precomp.hpp"
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
using namespace perf;
|
|
using std::tr1::make_tuple;
|
|
using std::tr1::get;
|
|
|
|
typedef tr1::tuple<std::string, int, int, tr1::tuple<int,int>, int> Path_Idx_Cn_NPoints_WSize_t;
|
|
typedef TestBaseWithParam<Path_Idx_Cn_NPoints_WSize_t> Path_Idx_Cn_NPoints_WSize;
|
|
|
|
void FormTrackingPointsArray(vector<Point2f>& points, int width, int height, int nPointsX, int nPointsY)
|
|
{
|
|
int stepX = width / nPointsX;
|
|
int stepY = height / nPointsY;
|
|
if (stepX < 1 || stepY < 1) FAIL() << "Specified points number is too big";
|
|
|
|
points.clear();
|
|
points.reserve(nPointsX * nPointsY);
|
|
|
|
for( int x = stepX / 2; x < width; x += stepX )
|
|
{
|
|
for( int y = stepY / 2; y < height; y += stepY )
|
|
{
|
|
Point2f pt(static_cast<float>(x), static_cast<float>(y));
|
|
points.push_back(pt);
|
|
}
|
|
}
|
|
}
|
|
|
|
PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine(
|
|
testing::Values<std::string>("cv/optflow/frames/VGA_%02d.png", "cv/optflow/frames/720p_%02d.png"),
|
|
testing::Range(1, 3),
|
|
testing::Values(1, 3, 4),
|
|
testing::Values(make_tuple(9, 9), make_tuple(15, 15)),
|
|
testing::Values(7, 11)
|
|
)
|
|
)
|
|
{
|
|
string filename1 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam())));
|
|
string filename2 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam()) + 1));
|
|
Mat img1 = imread(filename1);
|
|
Mat img2 = imread(filename2);
|
|
if (img1.empty()) FAIL() << "Unable to load source image " << filename1;
|
|
if (img2.empty()) FAIL() << "Unable to load source image " << filename2;
|
|
|
|
int cn = get<2>(GetParam());
|
|
int nPointsX = min(get<0>(get<3>(GetParam())), img1.cols);
|
|
int nPointsY = min(get<1>(get<3>(GetParam())), img1.rows);
|
|
int winSize = get<4>(GetParam());
|
|
|
|
int maxLevel = 2;
|
|
TermCriteria criteria(TermCriteria::COUNT|TermCriteria::EPS, 7, 0.001);
|
|
int flags = 0;
|
|
double minEigThreshold = 1e-4;
|
|
|
|
Mat frame1, frame2;
|
|
switch(cn)
|
|
{
|
|
case 1:
|
|
cvtColor(img1, frame1, COLOR_BGR2GRAY, cn);
|
|
cvtColor(img2, frame2, COLOR_BGR2GRAY, cn);
|
|
break;
|
|
case 3:
|
|
frame1 = img1;
|
|
frame2 = img2;
|
|
break;
|
|
case 4:
|
|
cvtColor(img1, frame1, COLOR_BGR2BGRA, cn);
|
|
cvtColor(img2, frame2, COLOR_BGR2BGRA, cn);
|
|
break;
|
|
default:
|
|
FAIL() << "Unexpected number of channels: " << cn;
|
|
}
|
|
|
|
vector<Point2f> inPoints;
|
|
vector<Point2f> outPoints;
|
|
vector<uchar> status;
|
|
vector<float> err;
|
|
|
|
FormTrackingPointsArray(inPoints, frame1.cols, frame1.rows, nPointsX, nPointsY);
|
|
outPoints.resize(inPoints.size());
|
|
status.resize(inPoints.size());
|
|
err.resize(inPoints.size());
|
|
|
|
declare.in(frame1, frame2, inPoints).out(outPoints);
|
|
|
|
TEST_CYCLE_N(30)
|
|
{
|
|
calcOpticalFlowPyrLK(frame1, frame2, inPoints, outPoints, status, err,
|
|
Size(winSize, winSize), maxLevel, criteria,
|
|
flags, minEigThreshold);
|
|
}
|
|
|
|
SANITY_CHECK(outPoints, 0.3);
|
|
SANITY_CHECK(status);
|
|
SANITY_CHECK(err, 2);
|
|
}
|
|
|
|
typedef tr1::tuple<std::string, int, int, tr1::tuple<int,int>, int, bool> Path_Idx_Cn_NPoints_WSize_Deriv_t;
|
|
typedef TestBaseWithParam<Path_Idx_Cn_NPoints_WSize_Deriv_t> Path_Idx_Cn_NPoints_WSize_Deriv;
|
|
|
|
PERF_TEST_P(Path_Idx_Cn_NPoints_WSize_Deriv, OpticalFlowPyrLK_self, testing::Combine(
|
|
testing::Values<std::string>("cv/optflow/frames/VGA_%02d.png", "cv/optflow/frames/720p_%02d.png"),
|
|
testing::Range(1, 3),
|
|
testing::Values(1, 3, 4),
|
|
testing::Values(make_tuple(9, 9), make_tuple(15, 15)),
|
|
testing::Values(7, 11),
|
|
testing::Bool()
|
|
)
|
|
)
|
|
{
|
|
string filename1 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam())));
|
|
string filename2 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam()) + 1));
|
|
Mat img1 = imread(filename1);
|
|
Mat img2 = imread(filename2);
|
|
if (img1.empty()) FAIL() << "Unable to load source image " << filename1;
|
|
if (img2.empty()) FAIL() << "Unable to load source image " << filename2;
|
|
|
|
int cn = get<2>(GetParam());
|
|
int nPointsX = min(get<0>(get<3>(GetParam())), img1.cols);
|
|
int nPointsY = min(get<1>(get<3>(GetParam())), img1.rows);
|
|
int winSize = get<4>(GetParam());
|
|
bool withDerivatives = get<5>(GetParam());
|
|
|
|
int maxLevel = 2;
|
|
TermCriteria criteria(TermCriteria::COUNT|TermCriteria::EPS, 7, 0.001);
|
|
int flags = 0;
|
|
double minEigThreshold = 1e-4;
|
|
|
|
Mat frame1, frame2;
|
|
switch(cn)
|
|
{
|
|
case 1:
|
|
cvtColor(img1, frame1, COLOR_BGR2GRAY, cn);
|
|
cvtColor(img2, frame2, COLOR_BGR2GRAY, cn);
|
|
break;
|
|
case 3:
|
|
frame1 = img1;
|
|
frame2 = img2;
|
|
break;
|
|
case 4:
|
|
cvtColor(img1, frame1, COLOR_BGR2BGRA, cn);
|
|
cvtColor(img2, frame2, COLOR_BGR2BGRA, cn);
|
|
break;
|
|
default:
|
|
FAIL() << "Unexpected number of channels: " << cn;
|
|
}
|
|
|
|
vector<Point2f> inPoints;
|
|
vector<Point2f> outPoints;
|
|
vector<uchar> status;
|
|
vector<float> err;
|
|
|
|
FormTrackingPointsArray(inPoints, frame1.cols, frame1.rows, nPointsX, nPointsY);
|
|
outPoints.resize(inPoints.size());
|
|
status.resize(inPoints.size());
|
|
err.resize(inPoints.size());
|
|
|
|
std::vector<Mat> pyramid1, pyramid2;
|
|
|
|
maxLevel = buildOpticalFlowPyramid(frame1, pyramid1, Size(winSize, winSize), maxLevel, withDerivatives);
|
|
maxLevel = buildOpticalFlowPyramid(frame2, pyramid2, Size(winSize, winSize), maxLevel, withDerivatives);
|
|
|
|
declare.in(pyramid1, pyramid2, inPoints).out(outPoints);
|
|
declare.time(400);
|
|
|
|
int runs = 3;
|
|
TEST_CYCLE_MULTIRUN(runs)
|
|
{
|
|
calcOpticalFlowPyrLK(pyramid1, pyramid2, inPoints, outPoints, status, err,
|
|
Size(winSize, winSize), maxLevel, criteria,
|
|
flags, minEigThreshold);
|
|
}
|
|
|
|
SANITY_CHECK(outPoints, 0.3);
|
|
SANITY_CHECK(status);
|
|
SANITY_CHECK(err, 2);
|
|
}
|
|
|
|
CV_ENUM(PyrBorderMode, BORDER_DEFAULT, BORDER_TRANSPARENT);
|
|
typedef tr1::tuple<std::string, int, bool, PyrBorderMode, bool> Path_Win_Deriv_Border_Reuse_t;
|
|
typedef TestBaseWithParam<Path_Win_Deriv_Border_Reuse_t> Path_Win_Deriv_Border_Reuse;
|
|
|
|
PERF_TEST_P(Path_Win_Deriv_Border_Reuse, OpticalFlowPyrLK_pyr, testing::Combine(
|
|
testing::Values<std::string>("cv/optflow/frames/720p_01.png"),
|
|
testing::Values(7, 11),
|
|
testing::Bool(),
|
|
PyrBorderMode::all(),
|
|
testing::Bool()
|
|
)
|
|
)
|
|
{
|
|
string filename = getDataPath(get<0>(GetParam()));
|
|
Mat img = imread(filename);
|
|
Size winSize(get<1>(GetParam()), get<1>(GetParam()));
|
|
bool withDerivatives = get<2>(GetParam());
|
|
int derivBorder = get<3>(GetParam());
|
|
int pyrBorder = derivBorder;
|
|
if(derivBorder != BORDER_TRANSPARENT)
|
|
{
|
|
derivBorder = BORDER_CONSTANT;
|
|
pyrBorder = BORDER_REFLECT_101;
|
|
}
|
|
bool tryReuseInputImage = get<4>(GetParam());
|
|
std::vector<Mat> pyramid;
|
|
|
|
img.adjustROI(winSize.height, winSize.height, winSize.width, winSize.width);
|
|
|
|
int maxLevel = buildOpticalFlowPyramid(img, pyramid, winSize, 1000, withDerivatives, BORDER_CONSTANT, BORDER_CONSTANT, tryReuseInputImage);
|
|
|
|
declare.in(img).out(pyramid);
|
|
|
|
|
|
TEST_CYCLE()
|
|
{
|
|
buildOpticalFlowPyramid(img, pyramid, winSize, maxLevel, withDerivatives, pyrBorder, derivBorder, tryReuseInputImage);
|
|
}
|
|
|
|
SANITY_CHECK(pyramid);
|
|
}
|