Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vadim Pisarevsky 2012-10-09 21:52:56 +04:00
commit 89de0bebd8
28 changed files with 207 additions and 102 deletions

View File

@ -57,13 +57,12 @@ PROJECT_NAME = sys.argv[2]
CLASS_PATH = os.path.join(INSTALL_DIRECTORY, "sdk/java/bin/classes")
if (not os.path.exists(CLASS_PATH)):
print("Error: no java classes found in \"%s\"", CLASS_PATH)
print("Error: no java classes found in \"%s\"" % CLASS_PATH)
exit(-2)
if (os.environ.has_key("NDK_ROOT")):
ANDROID_NDK_PATH = os.environ["NDK_ROOT"];
print("Using Android NDK from NDK_ROOT (\"%s\")" % ANDROID_NDK_PATH)
if (not ANDROID_NDK_PATH):
pipe = os.popen("which ndk-build")
@ -112,13 +111,14 @@ outputFile.write("\n\t" + "\n\t".join(cppHeaders))
outputFile.write("\n\t" + "\n\t".join(jniHeaders))
outputFile.write("\n</headers>\n\n")
includes = []
includes = [os.path.join(INSTALL_DIRECTORY, "sdk", "native", "jni", "include"),
os.path.join(INSTALL_DIRECTORY, "sdk", "native", "jni", "include", "opencv"),
os.path.join(INSTALL_DIRECTORY, "sdk", "native", "jni", "include", "opencv2")]
for inc in SYS_INCLUDES:
includes.append(os.path.join(ANDROID_NDK_PATH, inc))
outputFile.write("<include_paths>\n\tOpenCV-2.4.2-branch/sdk/native/jni/include\n\tOpenCV-2.4.2-branch/sdk/native/jni/include/opencv\n\tOpenCV-2.4.2-branch/sdk/native/jni/include/opencv2\n")
outputFile.write("\t%s\n</include_paths>\n\n" % "\n\t".join(includes))
outputFile.write("<include_paths>\n\t%s\n</include_paths>\n\n" % "\n\t".join(includes))
libraries = []
for lib in TARGET_LIBS:

View File

@ -581,7 +581,7 @@ function(ocv_add_perf_tests)
__ocv_parse_test_sources(PERF ${ARGN})
# opencv_highgui is required for imread/imwrite
set(perf_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_PERF_${the_module}_DEPS})
set(perf_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_PERF_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
ocv_check_dependencies(${perf_deps})
if(OCV_DEPENDENCIES_FOUND)
@ -632,7 +632,7 @@ function(ocv_add_accuracy_tests)
__ocv_parse_test_sources(TEST ${ARGN})
# opencv_highgui is required for imread/imwrite
set(test_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_TEST_${the_module}_DEPS})
set(test_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_TEST_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS})
ocv_check_dependencies(${test_deps})
if(OCV_DEPENDENCIES_FOUND)

View File

@ -323,7 +323,7 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling)
:alt: Eclipse About
:align: center
.. important:: OpenCV for Android 2.4.2 package contains sample projects pre-configured CDT Builders. For your own projects follow the steps below.
.. important:: OpenCV for Android package since version 2.4.2 contains sample projects pre-configured CDT Builders. For your own projects follow the steps below.
#. Define the ``NDKROOT`` environment variable containing the path to Android NDK in your system (e.g. ``"X:\\Apps\\android-ndk-r8"`` or ``"/opt/android-ndk-r8"``).
**On Windows** an environment variable can be set via :guilabel:`My Computer -> Properties -> Advanced -> Environment variables` and restarting Eclipse.

View File

@ -16,7 +16,7 @@ Installation by using the pre-built libraries
1. Open up a web browser and go to: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/
#. Open the folder for the latest version (currently this is 2.4.2).
#. Open the folder for the latest version (currently this is |release|).
#. Choose a build you want to use and download it. The naming conventions used will show what kind of support they offer. For example:

View File

@ -1,4 +1,5 @@
#include "perf_precomp.hpp"
#include "opencv2/core/internal.hpp"
using namespace std;
using namespace cv;
@ -48,7 +49,10 @@ PERF_TEST_P(PointsNum_Algo, solvePnP,
declare.in(points3d, points2d);
TEST_CYCLE_N(1000) solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
TEST_CYCLE_N(1000)
{
solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
}
SANITY_CHECK(rvec, 1e-6);
SANITY_CHECK(tvec, 1e-6);
@ -83,7 +87,10 @@ PERF_TEST(PointsNum_Algo, solveP3P)
declare.in(points3d, points2d);
TEST_CYCLE_N(1000) solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, CV_P3P);
TEST_CYCLE_N(1000)
{
solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, CV_P3P);
}
SANITY_CHECK(rvec, 1e-6);
SANITY_CHECK(tvec, 1e-6);
@ -117,9 +124,10 @@ PERF_TEST_P(PointsNum, SolvePnPRansac, testing::Values(4, 3*9, 7*13))
Mat rvec;
Mat tvec;
solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
declare.time(3.0);
#ifdef HAVE_TBB
// limit concurrency to get determenistic result
cv::Ptr<tbb::task_scheduler_init> one_thread = new tbb::task_scheduler_init(1);
#endif
TEST_CYCLE()
{

View File

@ -260,6 +260,8 @@ namespace cv
{
rvec.copyTo(initRvec);
tvec.copyTo(initTvec);
generator.state = theRNG().state; //to control it somehow...
}
private:
PnPSolver& operator=(const PnPSolver&);

View File

@ -27,6 +27,7 @@ class DetectionBasedTracker
minNeighbours(2),
scaleFactor(1.1f)
{}
virtual ~IDetector() {}
virtual void detect(const cv::Mat& image, std::vector<cv::Rect>& objects) = 0;
@ -62,7 +63,6 @@ class DetectionBasedTracker
{
minNeighbours = value;
}
virtual ~IDetector() {}
protected:
cv::Size minObjSize;
@ -107,7 +107,6 @@ class DetectionBasedTracker
};
virtual void getObjects(std::vector<ExtObject>& result) const;
virtual int addObject(const cv::Rect& location); //returns id of the new object
protected:
@ -170,7 +169,7 @@ class DetectionBasedTracker
namespace cv
{
typedef ::DetectionBasedTracker DetectionBasedTracker;
using ::DetectionBasedTracker;
} //end of cv namespace
#endif

View File

@ -1278,7 +1278,11 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
"nor 'array op scalar', nor 'scalar op array'" );
haveScalar = true;
CV_Assert(src2.type() == CV_64F && (src2.rows == 4 || src2.rows == 1));
depth2 = MAX(src1.depth(), actualScalarDepth(src2.ptr<double>(), src1.channels()));
if (usrdata == 0) // hack to filter out multiply and divide
depth2 = actualScalarDepth(src2.ptr<double>(), src1.channels());
else
depth2 = CV_64F;
}
int cn = src1.channels(), depth1 = src1.depth(), wtype;

View File

@ -6,17 +6,15 @@ using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
CV_FLAGS(NormType, NORM_L1, NORM_L2, NORM_L2SQR, NORM_HAMMING, NORM_HAMMING2)
CV_ENUM(SourceType, CV_32F, CV_8U)
CV_ENUM(DestinationType, CV_32F, CV_32S)
CV_ENUM(NormType, NORM_L1, NORM_L2, NORM_L2SQR, NORM_HAMMING, NORM_HAMMING2)
typedef std::tr1::tuple<NormType, DestinationType, bool> Norm_Destination_CrossCheck_t;
typedef std::tr1::tuple<NormType, MatType, bool> Norm_Destination_CrossCheck_t;
typedef perf::TestBaseWithParam<Norm_Destination_CrossCheck_t> Norm_Destination_CrossCheck;
typedef std::tr1::tuple<NormType, bool> Norm_CrossCheck_t;
typedef perf::TestBaseWithParam<Norm_CrossCheck_t> Norm_CrossCheck;
typedef std::tr1::tuple<SourceType, bool> Source_CrossCheck_t;
typedef std::tr1::tuple<MatType, bool> Source_CrossCheck_t;
typedef perf::TestBaseWithParam<Source_CrossCheck_t> Source_CrossCheck;
void generateData( Mat& query, Mat& train, const int sourceType );
@ -29,27 +27,25 @@ PERF_TEST_P(Norm_Destination_CrossCheck, batchDistance_8U,
)
{
NormType normType = get<0>(GetParam());
DestinationType destinationType = get<1>(GetParam());
int destinationType = get<1>(GetParam());
bool isCrossCheck = get<2>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors;
Mat trainDescriptors;
Mat dist;
Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, CV_8U);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE()
{
batchDistance(queryDescriptors, trainDescriptors, dist, destinationType, (isCrossCheck) ? ndix : noArray(),
normType, knn, Mat(), 0, isCrossCheck);
}
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
}
PERF_TEST_P(Norm_CrossCheck, batchDistance_Dest_32S,
@ -60,25 +56,23 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_Dest_32S,
{
NormType normType = get<0>(GetParam());
bool isCrossCheck = get<1>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors;
Mat trainDescriptors;
Mat dist;
Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, CV_8U);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE()
{
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32S, (isCrossCheck) ? ndix : noArray(),
normType, knn, Mat(), 0, isCrossCheck);
}
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
}
PERF_TEST_P(Source_CrossCheck, batchDistance_L2,
@ -87,27 +81,25 @@ PERF_TEST_P(Source_CrossCheck, batchDistance_L2,
)
)
{
SourceType sourceType = get<0>(GetParam());
int sourceType = get<0>(GetParam());
bool isCrossCheck = get<1>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors;
Mat trainDescriptors;
Mat dist;
Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, sourceType);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE()
{
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(),
NORM_L2, knn, Mat(), 0, isCrossCheck);
}
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
}
PERF_TEST_P(Norm_CrossCheck, batchDistance_32F,
@ -118,25 +110,23 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_32F,
{
NormType normType = get<0>(GetParam());
bool isCrossCheck = get<1>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors;
Mat trainDescriptors;
Mat dist;
Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, CV_32F);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE()
{
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(),
normType, knn, Mat(), 0, isCrossCheck);
}
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
}
void generateData( Mat& query, Mat& train, const int sourceType )

View File

@ -6,15 +6,23 @@ using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
typedef perf::TestBaseWithParam<std::string> fast;
enum { TYPE_5_8 =FastFeatureDetector::TYPE_5_8, TYPE_7_12 = FastFeatureDetector::TYPE_7_12, TYPE_9_16 = FastFeatureDetector::TYPE_9_16 };
CV_ENUM(FastType, TYPE_5_8, TYPE_7_12, TYPE_9_16)
typedef std::tr1::tuple<String, FastType> File_Type_t;
typedef perf::TestBaseWithParam<File_Type_t> fast;
#define FAST_IMAGES \
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
"stitching/a3.png"
PERF_TEST_P(fast, detectForORB, testing::Values(FAST_IMAGES))
PERF_TEST_P(fast, detect, testing::Combine(
testing::Values(FAST_IMAGES),
testing::ValuesIn(FastType::all())
))
{
String filename = getDataPath(GetParam());
String filename = getDataPath(get<0>(GetParam()));
int type = get<1>(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
if (frame.empty())
@ -22,13 +30,11 @@ PERF_TEST_P(fast, detectForORB, testing::Values(FAST_IMAGES))
declare.in(frame);
FastFeatureDetector fd(20, true, FastFeatureDetector::TYPE_5_8);
FastFeatureDetector fd(20, true, type);
vector<KeyPoint> points;
TEST_CYCLE() fd.detect(frame, points);
fd = FastFeatureDetector(20, true, FastFeatureDetector::TYPE_7_12);
TEST_CYCLE() fd.detect(frame, points);
fd = FastFeatureDetector(20, true, FastFeatureDetector::TYPE_9_16);
TEST_CYCLE() fd.detect(frame, points);
SANITY_CHECK_KEYPOINTS(points);
}

View File

@ -26,6 +26,8 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
vector<KeyPoint> points;
TEST_CYCLE() detector(frame, mask, points);
SANITY_CHECK_KEYPOINTS(points);
}
PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
@ -46,6 +48,8 @@ PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
Mat descriptors;
TEST_CYCLE() detector(frame, mask, points, descriptors, true);
SANITY_CHECK(descriptors);
}
PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
@ -64,4 +68,7 @@ PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
Mat descriptors;
TEST_CYCLE() detector(frame, mask, points, descriptors, false);
SANITY_CHECK_KEYPOINTS(points);
SANITY_CHECK(descriptors);
}

View File

@ -23,5 +23,6 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile,
TEST_CYCLE() cap.open(filename);
SANITY_CHECK(cap.isOpened());
bool dummy = cap.isOpened();
SANITY_CHECK(dummy);
}

View File

@ -25,5 +25,6 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
TEST_CYCLE() { Mat image = imread(filename, 1); writer << image; }
SANITY_CHECK(writer.isOpened());
bool dummy = writer.isOpened();
SANITY_CHECK(dummy);
}

View File

@ -210,13 +210,7 @@ if(ANDROID)
list(REMOVE_ITEM android_lib_project_files "${ANDROID_MANIFEST_FILE}")
foreach(f ${android_lib_project_files})
if(NOT f MATCHES "\\.svn")
add_custom_command(
OUTPUT "${OpenCV_BINARY_DIR}/${f}"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${f}" "${OpenCV_BINARY_DIR}/${f}"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${f}"
COMMENT "Generating ${f}"
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${f}" "${OpenCV_BINARY_DIR}/${f}")
list(APPEND lib_proj_files "${OpenCV_BINARY_DIR}/${f}")
if(NOT f MATCHES "jni/.+")
@ -250,11 +244,13 @@ if(ANDROID)
COMMAND ${CMAKE_COMMAND} -E remove ${lib_target_files}
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}"
COMMAND ${ANDROID_EXECUTABLE} --silent create lib-project --path \"${OpenCV_BINARY_DIR}\" --target \"${lib_target_sdk_target}\" --name OpenCV --package org.opencv 2>\"${CMAKE_CURRENT_BINARY_DIR}/create_lib_project.log\"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${ANDROID_MANIFEST_FILE}"
DEPENDS ${lib_proj_files}
COMMENT "Generating OpenCV Android library project. SDK target: ${lib_target_sdk_target}"
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}")
install(FILES "${OpenCV_BINARY_DIR}/${ANDROID_PROJECT_PROPERTIES_FILE}" DESTINATION ${JAVA_INSTALL_ROOT} COMPONENT main)
install(FILES "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" DESTINATION ${JAVA_INSTALL_ROOT} COMPONENT main)
# creating empty 'gen' and 'res' folders

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="cls"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="cls"/>
</classpath>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenCV Library - 2.4.2</name>
<name>OpenCV Library - @OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@</name>
<comment></comment>
<projects>
</projects>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv"
android:versionCode="242"
android:versionName="2.4.2">
android:versionCode="@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@"
android:versionName="@OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@"
<uses-sdk android:minSdkVersion="8" />
</manifest>

View File

@ -26,6 +26,8 @@ PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES))
vector<KeyPoint> points;
TEST_CYCLE() detector(frame, mask, points);
SANITY_CHECK_KEYPOINTS(points);
}
PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES))
@ -45,6 +47,8 @@ PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES))
detector(frame, mask, points);
TEST_CYCLE() detector(frame, mask, points, descriptors, true);
SANITY_CHECK(descriptors, 1e-4);
}
PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES))
@ -62,4 +66,7 @@ PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES))
vector<float> descriptors;
TEST_CYCLE() detector(frame, mask, points, descriptors, false);
SANITY_CHECK_KEYPOINTS(points);
SANITY_CHECK(descriptors, 1e-4);
}

View File

@ -46,7 +46,7 @@
#include <list>
#include "opencv2/core/core.hpp"
#define ENABLE_LOG 1
#define ENABLE_LOG 0
// TODO remove LOG macros, add logging class
#if ENABLE_LOG

View File

@ -56,6 +56,8 @@ PERF_TEST_P(stitch, a123, TEST_DETECTORS)
stitcher.stitch(imgs, pano);
stopTimer();
}
SANITY_CHECK(pano, 2);
}
PERF_TEST_P(stitch, b12, TEST_DETECTORS)
@ -88,6 +90,8 @@ PERF_TEST_P(stitch, b12, TEST_DETECTORS)
stitcher.stitch(imgs, pano);
stopTimer();
}
SANITY_CHECK(pano, 2);
}
PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
@ -122,8 +126,7 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
detail::MatchesInfo pairwise_matches;
declare.in(features1.descriptors, features2.descriptors)
.iterations(100);
declare.in(features1.descriptors, features2.descriptors);
while(next())
{
@ -133,6 +136,8 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
stopTimer();
matcher->collectGarbage();
}
SANITY_CHECK_MATCHES(pairwise_matches.matches);
}
PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine(
@ -186,4 +191,8 @@ PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine(
stopTimer();
matcher->collectGarbage();
}
std::vector<DMatch>& matches = pairwise_matches[0].matches;
SANITY_CHECK_MATCHES(matches);
}

View File

@ -74,7 +74,9 @@ void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &imag
const vector<pair<Mat,uchar> > &masks)
{
LOGLN("Exposure compensation...");
#if ENABLE_LOG
int64 t = getTickCount();
#endif
CV_Assert(corners.size() == images.size() && images.size() == masks.size());

View File

@ -105,7 +105,9 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c
vector<CameraParams> &cameras)
{
LOGLN("Estimating rotations...");
#if ENABLE_LOG
int64 t = getTickCount();
#endif
const int num_images = static_cast<int>(features.size());
@ -172,7 +174,9 @@ void BundleAdjusterBase::estimate(const vector<ImageFeatures> &features,
vector<CameraParams> &cameras)
{
LOG_CHAT("Bundle adjustment");
#if ENABLE_LOG
int64 t = getTickCount();
#endif
num_images_ = static_cast<int>(features.size());
features_ = &features[0];
@ -582,7 +586,9 @@ void BundleAdjusterRay::calcJacobian(Mat &jac)
void waveCorrect(vector<Mat> &rmats, WaveCorrectKind kind)
{
LOGLN("Wave correcting...");
#if ENABLE_LOG
int64 t = getTickCount();
#endif
Mat moment = Mat::zeros(3, 3, CV_32F);
for (size_t i = 0; i < rmats.size(); ++i)

View File

@ -52,10 +52,12 @@ void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
vector<Mat> &masks)
{
LOGLN("Finding seams...");
if (src.size() == 0)
if (src.size() == 0)
return;
#if ENABLE_LOG
int64 t = getTickCount();
#endif
images_ = src;
sizes_.resize(src.size());
@ -87,10 +89,12 @@ void VoronoiSeamFinder::find(const vector<Size> &sizes, const vector<Point> &cor
vector<Mat> &masks)
{
LOGLN("Finding seams...");
if (sizes.size() == 0)
if (sizes.size() == 0)
return;
#if ENABLE_LOG
int64 t = getTickCount();
#endif
sizes_ = sizes;
corners_ = corners;
@ -161,7 +165,9 @@ DpSeamFinder::DpSeamFinder(CostFunction costFunc) : costFunc_(costFunc) {}
void DpSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners, vector<Mat> &masks)
{
LOGLN("Finding seams...");
#if ENABLE_LOG
int64 t = getTickCount();
#endif
if (src.size() == 0)
return;
@ -700,7 +706,7 @@ void DpSeamFinder::computeCosts(
{
CV_Assert(states_[comp] & INTERS);
// compute costs
// compute costs
float (*diff)(const Mat&, int, int, const Mat&, int, int) = 0;
if (image1.type() == CV_32FC3 && image2.type() == CV_32FC3)
@ -1055,10 +1061,10 @@ public:
void findInPair(size_t first, size_t second, Rect roi);
private:
void setGraphWeightsColor(const Mat &img1, const Mat &img2,
void setGraphWeightsColor(const Mat &img1, const Mat &img2,
const Mat &mask1, const Mat &mask2, GCGraph<float> &graph);
void setGraphWeightsColorGrad(const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
void setGraphWeightsColorGrad(const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
GCGraph<float> &graph);
vector<Mat> dx_, dy_;
@ -1148,8 +1154,8 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &
void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
GCGraph<float> &graph)
{
const Size img_size = img1.size();
@ -1177,7 +1183,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
float grad = dx1.at<float>(y, x) + dx1.at<float>(y, x + 1) +
dx2.at<float>(y, x) + dx2.at<float>(y, x + 1) + weight_eps;
float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) +
normL2(img1.at<Point3f>(y, x + 1), img2.at<Point3f>(y, x + 1))) / grad +
normL2(img1.at<Point3f>(y, x + 1), img2.at<Point3f>(y, x + 1))) / grad +
weight_eps;
if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y, x + 1) ||
!mask2.at<uchar>(y, x) || !mask2.at<uchar>(y, x + 1))
@ -1186,10 +1192,10 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
}
if (y < img_size.height - 1)
{
float grad = dy1.at<float>(y, x) + dy1.at<float>(y + 1, x) +
float grad = dy1.at<float>(y, x) + dy1.at<float>(y + 1, x) +
dy2.at<float>(y, x) + dy2.at<float>(y + 1, x) + weight_eps;
float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) +
normL2(img1.at<Point3f>(y + 1, x), img2.at<Point3f>(y + 1, x))) / grad +
float weight = (normL2(img1.at<Point3f>(y, x), img2.at<Point3f>(y, x)) +
normL2(img1.at<Point3f>(y + 1, x), img2.at<Point3f>(y + 1, x))) / grad +
weight_eps;
if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y + 1, x) ||
!mask2.at<uchar>(y, x) || !mask2.at<uchar>(y + 1, x))
@ -1271,7 +1277,7 @@ void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)
setGraphWeightsColor(subimg1, subimg2, submask1, submask2, graph);
break;
case GraphCutSeamFinder::COST_COLOR_GRAD:
setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,
setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,
submask1, submask2, graph);
break;
default:
@ -1402,17 +1408,17 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi)
}
}
}
Mat terminals, leftT, rightT, top, bottom;
switch (cost_type_)
{
case GraphCutSeamFinder::COST_COLOR:
setGraphWeightsColor(subimg1, subimg2, submask1, submask2,
setGraphWeightsColor(subimg1, subimg2, submask1, submask2,
terminals, leftT, rightT, top, bottom);
break;
case GraphCutSeamFinder::COST_COLOR_GRAD:
setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,
setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,
submask1, submask2, terminals, leftT, rightT, top, bottom);
break;
default:
@ -1448,7 +1454,7 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi)
}
void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img2, const Mat &mask1, const Mat &mask2,
void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img2, const Mat &mask1, const Mat &mask2,
Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)
{
const Size img_size = img1.size();
@ -1540,7 +1546,7 @@ void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img
void GraphCutSeamFinderGpu::setGraphWeightsColorGrad(
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)
{
const Size img_size = img1.size();

View File

@ -152,7 +152,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano)
Mat &pano_ = pano.getMatRef();
#if ENABLE_LOG
int64 t = getTickCount();
#endif
vector<Point> corners(imgs_.size());
vector<Mat> masks_warped(imgs_.size());
@ -201,7 +203,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano)
masks.clear();
LOGLN("Compositing...");
#if ENABLE_LOG
t = getTickCount();
#endif
Mat img_warped, img_warped_s;
Mat dilated_mask, seam_mask, mask, mask_warped;
@ -349,7 +353,9 @@ Stitcher::Status Stitcher::matchImages()
full_img_sizes_.resize(imgs_.size());
LOGLN("Finding features...");
#if ENABLE_LOG
int64 t = getTickCount();
#endif
for (size_t i = 0; i < imgs_.size(); ++i)
{
@ -406,7 +412,9 @@ Stitcher::Status Stitcher::matchImages()
LOGLN("Finding features, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
LOG("Pairwise matching");
#if ENABLE_LOG
t = getTickCount();
#endif
(*features_matcher_)(features_, pairwise_matches_, matching_mask_);
features_matcher_->collectGarbage();
LOGLN("Pairwise matching, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");

View File

@ -10,7 +10,8 @@ endif()
set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE)
ocv_add_module(ts opencv_core)
ocv_add_module(ts opencv_core opencv_features2d)
ocv_glob_module_sources()
ocv_module_include_directories()
ocv_create_module()

View File

@ -2,6 +2,7 @@
#define __OPENCV_TS_PERF_HPP__
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "ts_gtest.h"
#ifdef HAVE_TBB
@ -165,6 +166,8 @@ class CV_EXPORTS Regression
{
public:
static Regression& add(TestBase* test, const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
static Regression& addKeypoints(TestBase* test, const std::string& name, const std::vector<cv::KeyPoint>& array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
static Regression& addMatches(TestBase* test, const std::string& name, const std::vector<cv::DMatch>& array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
static void Init(const std::string& testSuitName, const std::string& ext = ".xml");
Regression& operator() (const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
@ -199,6 +202,8 @@ private:
};
#define SANITY_CHECK(array, ...) ::perf::Regression::add(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__)
/*****************************************************************************************\

View File

@ -103,6 +103,38 @@ Regression& Regression::add(TestBase* test, const std::string& name, cv::InputAr
return instance()(name, array, eps, err);
}
Regression& Regression::addKeypoints(TestBase* test, const std::string& name, const std::vector<cv::KeyPoint>& array, double eps, ERROR_TYPE err)
{
int len = (int)array.size();
cv::Mat pt (len, 1, CV_32FC2, (void*)&array[0].pt, sizeof(cv::KeyPoint));
cv::Mat size (len, 1, CV_32FC1, (void*)&array[0].size, sizeof(cv::KeyPoint));
cv::Mat angle (len, 1, CV_32FC1, (void*)&array[0].angle, sizeof(cv::KeyPoint));
cv::Mat response(len, 1, CV_32FC1, (void*)&array[0].response, sizeof(cv::KeyPoint));
cv::Mat octave (len, 1, CV_32SC1, (void*)&array[0].octave, sizeof(cv::KeyPoint));
cv::Mat class_id(len, 1, CV_32SC1, (void*)&array[0].class_id, sizeof(cv::KeyPoint));
return Regression::add(test, name + "-pt", pt, eps, ERROR_ABSOLUTE)
(name + "-size", size, eps, ERROR_ABSOLUTE)
(name + "-angle", angle, eps, ERROR_ABSOLUTE)
(name + "-response", response, eps, err)
(name + "-octave", octave, eps, ERROR_ABSOLUTE)
(name + "-class_id", class_id, eps, ERROR_ABSOLUTE);
}
Regression& Regression::addMatches(TestBase* test, const std::string& name, const std::vector<cv::DMatch>& array, double eps, ERROR_TYPE err)
{
int len = (int)array.size();
cv::Mat queryIdx(len, 1, CV_32SC1, (void*)&array[0].queryIdx, sizeof(cv::DMatch));
cv::Mat trainIdx(len, 1, CV_32SC1, (void*)&array[0].trainIdx, sizeof(cv::DMatch));
cv::Mat imgIdx (len, 1, CV_32SC1, (void*)&array[0].imgIdx, sizeof(cv::DMatch));
cv::Mat distance(len, 1, CV_32FC1, (void*)&array[0].distance, sizeof(cv::DMatch));
return Regression::add(test, name + "-queryIdx", queryIdx, DBL_EPSILON, ERROR_ABSOLUTE)
(name + "-trainIdx", trainIdx, DBL_EPSILON, ERROR_ABSOLUTE)
(name + "-imgIdx", imgIdx, DBL_EPSILON, ERROR_ABSOLUTE)
(name + "-distance", distance, eps, err);
}
void Regression::Init(const std::string& testSuitName, const std::string& ext)
{
instance().init(testSuitName, ext);
@ -490,6 +522,12 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR
Regression& Regression::operator() (const std::string& name, cv::InputArray array, double eps, ERROR_TYPE err)
{
if(!array.empty() && array.depth() == CV_USRTYPE1)
{
ADD_FAILURE() << " Can not check regression for CV_USRTYPE1 data type for " << name;
return *this;
}
std::string nodename = getCurrentTestNodeName();
cv::FileNode n = rootIn[nodename];
@ -674,6 +712,8 @@ cv::Size TestBase::getSize(cv::InputArray a)
bool TestBase::next()
{
bool has_next = ++currentIter < nIters && totalTime < timeLimit;
cv::theRNG().state = param_seed; //this rng should generate same numbers for each run
#ifdef ANDROID
if (log_power_checkpoints)
{
@ -948,7 +988,6 @@ void TestBase::SetUp()
currentIter = (unsigned int)-1;
timeLimit = timeLimitDefault;
times.clear();
cv::theRNG().state = param_seed;//this rng should generate same numbers for each run
}
void TestBase::TearDown()

View File

@ -91,6 +91,10 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine(
Size(winSize, winSize), maxLevel, criteria,
flags, minEigThreshold);
}
SANITY_CHECK(outPoints);
SANITY_CHECK(status);
SANITY_CHECK(err, 1e-5);
}
typedef tr1::tuple<std::string, int, int, tr1::tuple<int,int>, int, bool> Path_Idx_Cn_NPoints_WSize_Deriv_t;
@ -166,6 +170,10 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize_Deriv, OpticalFlowPyrLK_self, testing::Com
Size(winSize, winSize), maxLevel, criteria,
flags, minEigThreshold);
}
SANITY_CHECK(outPoints);
SANITY_CHECK(status);
SANITY_CHECK(err, 1e-5);
}
CV_ENUM(PyrBorderMode, BORDER_DEFAULT, BORDER_TRANSPARENT);