Commit 89de0beb authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge remote-tracking branch 'origin/master'

parents 3243ad34 0afd5125
...@@ -57,13 +57,12 @@ PROJECT_NAME = sys.argv[2] ...@@ -57,13 +57,12 @@ PROJECT_NAME = sys.argv[2]
CLASS_PATH = os.path.join(INSTALL_DIRECTORY, "sdk/java/bin/classes") CLASS_PATH = os.path.join(INSTALL_DIRECTORY, "sdk/java/bin/classes")
if (not os.path.exists(CLASS_PATH)): 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) exit(-2)
if (os.environ.has_key("NDK_ROOT")): if (os.environ.has_key("NDK_ROOT")):
ANDROID_NDK_PATH = os.environ["NDK_ROOT"]; ANDROID_NDK_PATH = os.environ["NDK_ROOT"];
print("Using Android NDK from NDK_ROOT (\"%s\")" % ANDROID_NDK_PATH) print("Using Android NDK from NDK_ROOT (\"%s\")" % ANDROID_NDK_PATH)
if (not ANDROID_NDK_PATH): if (not ANDROID_NDK_PATH):
pipe = os.popen("which ndk-build") pipe = os.popen("which ndk-build")
...@@ -112,13 +111,14 @@ outputFile.write("\n\t" + "\n\t".join(cppHeaders)) ...@@ -112,13 +111,14 @@ outputFile.write("\n\t" + "\n\t".join(cppHeaders))
outputFile.write("\n\t" + "\n\t".join(jniHeaders)) outputFile.write("\n\t" + "\n\t".join(jniHeaders))
outputFile.write("\n</headers>\n\n") 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: for inc in SYS_INCLUDES:
includes.append(os.path.join(ANDROID_NDK_PATH, inc)) 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("<include_paths>\n\t%s\n</include_paths>\n\n" % "\n\t".join(includes))
outputFile.write("\t%s\n</include_paths>\n\n" % "\n\t".join(includes))
libraries = [] libraries = []
for lib in TARGET_LIBS: for lib in TARGET_LIBS:
......
...@@ -581,7 +581,7 @@ function(ocv_add_perf_tests) ...@@ -581,7 +581,7 @@ function(ocv_add_perf_tests)
__ocv_parse_test_sources(PERF ${ARGN}) __ocv_parse_test_sources(PERF ${ARGN})
# opencv_highgui is required for imread/imwrite # 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}) ocv_check_dependencies(${perf_deps})
if(OCV_DEPENDENCIES_FOUND) if(OCV_DEPENDENCIES_FOUND)
...@@ -632,7 +632,7 @@ function(ocv_add_accuracy_tests) ...@@ -632,7 +632,7 @@ function(ocv_add_accuracy_tests)
__ocv_parse_test_sources(TEST ${ARGN}) __ocv_parse_test_sources(TEST ${ARGN})
# opencv_highgui is required for imread/imwrite # 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}) ocv_check_dependencies(${test_deps})
if(OCV_DEPENDENCIES_FOUND) if(OCV_DEPENDENCIES_FOUND)
......
...@@ -323,7 +323,7 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling) ...@@ -323,7 +323,7 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling)
:alt: Eclipse About :alt: Eclipse About
:align: center :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"``). #. 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. **On Windows** an environment variable can be set via :guilabel:`My Computer -> Properties -> Advanced -> Environment variables` and restarting Eclipse.
......
...@@ -16,7 +16,7 @@ Installation by using the pre-built libraries ...@@ -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/ 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: #. Choose a build you want to use and download it. The naming conventions used will show what kind of support they offer. For example:
......
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#include "opencv2/core/internal.hpp"
using namespace std; using namespace std;
using namespace cv; using namespace cv;
...@@ -48,7 +49,10 @@ PERF_TEST_P(PointsNum_Algo, solvePnP, ...@@ -48,7 +49,10 @@ PERF_TEST_P(PointsNum_Algo, solvePnP,
declare.in(points3d, points2d); 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(rvec, 1e-6);
SANITY_CHECK(tvec, 1e-6); SANITY_CHECK(tvec, 1e-6);
...@@ -83,7 +87,10 @@ PERF_TEST(PointsNum_Algo, solveP3P) ...@@ -83,7 +87,10 @@ PERF_TEST(PointsNum_Algo, solveP3P)
declare.in(points3d, points2d); 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(rvec, 1e-6);
SANITY_CHECK(tvec, 1e-6); SANITY_CHECK(tvec, 1e-6);
...@@ -117,9 +124,10 @@ PERF_TEST_P(PointsNum, SolvePnPRansac, testing::Values(4, 3*9, 7*13)) ...@@ -117,9 +124,10 @@ PERF_TEST_P(PointsNum, SolvePnPRansac, testing::Values(4, 3*9, 7*13))
Mat rvec; Mat rvec;
Mat tvec; Mat tvec;
solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec); #ifdef HAVE_TBB
// limit concurrency to get determenistic result
declare.time(3.0); cv::Ptr<tbb::task_scheduler_init> one_thread = new tbb::task_scheduler_init(1);
#endif
TEST_CYCLE() TEST_CYCLE()
{ {
......
...@@ -260,6 +260,8 @@ namespace cv ...@@ -260,6 +260,8 @@ namespace cv
{ {
rvec.copyTo(initRvec); rvec.copyTo(initRvec);
tvec.copyTo(initTvec); tvec.copyTo(initTvec);
generator.state = theRNG().state; //to control it somehow...
} }
private: private:
PnPSolver& operator=(const PnPSolver&); PnPSolver& operator=(const PnPSolver&);
......
...@@ -27,6 +27,7 @@ class DetectionBasedTracker ...@@ -27,6 +27,7 @@ class DetectionBasedTracker
minNeighbours(2), minNeighbours(2),
scaleFactor(1.1f) scaleFactor(1.1f)
{} {}
virtual ~IDetector() {}
virtual void detect(const cv::Mat& image, std::vector<cv::Rect>& objects) = 0; virtual void detect(const cv::Mat& image, std::vector<cv::Rect>& objects) = 0;
...@@ -62,7 +63,6 @@ class DetectionBasedTracker ...@@ -62,7 +63,6 @@ class DetectionBasedTracker
{ {
minNeighbours = value; minNeighbours = value;
} }
virtual ~IDetector() {}
protected: protected:
cv::Size minObjSize; cv::Size minObjSize;
...@@ -107,7 +107,6 @@ class DetectionBasedTracker ...@@ -107,7 +107,6 @@ class DetectionBasedTracker
}; };
virtual void getObjects(std::vector<ExtObject>& result) const; virtual void getObjects(std::vector<ExtObject>& result) const;
virtual int addObject(const cv::Rect& location); //returns id of the new object virtual int addObject(const cv::Rect& location); //returns id of the new object
protected: protected:
...@@ -170,7 +169,7 @@ class DetectionBasedTracker ...@@ -170,7 +169,7 @@ class DetectionBasedTracker
namespace cv namespace cv
{ {
typedef ::DetectionBasedTracker DetectionBasedTracker; using ::DetectionBasedTracker;
} //end of cv namespace } //end of cv namespace
#endif #endif
...@@ -1278,7 +1278,11 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, ...@@ -1278,7 +1278,11 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
"nor 'array op scalar', nor 'scalar op array'" ); "nor 'array op scalar', nor 'scalar op array'" );
haveScalar = true; haveScalar = true;
CV_Assert(src2.type() == CV_64F && (src2.rows == 4 || src2.rows == 1)); 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; int cn = src1.channels(), depth1 = src1.depth(), wtype;
......
...@@ -6,17 +6,15 @@ using namespace perf; ...@@ -6,17 +6,15 @@ using namespace perf;
using std::tr1::make_tuple; using std::tr1::make_tuple;
using std::tr1::get; using std::tr1::get;
CV_FLAGS(NormType, NORM_L1, NORM_L2, NORM_L2SQR, NORM_HAMMING, NORM_HAMMING2) CV_ENUM(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)
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 perf::TestBaseWithParam<Norm_Destination_CrossCheck_t> Norm_Destination_CrossCheck;
typedef std::tr1::tuple<NormType, bool> Norm_CrossCheck_t; typedef std::tr1::tuple<NormType, bool> Norm_CrossCheck_t;
typedef perf::TestBaseWithParam<Norm_CrossCheck_t> Norm_CrossCheck; 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; typedef perf::TestBaseWithParam<Source_CrossCheck_t> Source_CrossCheck;
void generateData( Mat& query, Mat& train, const int sourceType ); void generateData( Mat& query, Mat& train, const int sourceType );
...@@ -29,27 +27,25 @@ PERF_TEST_P(Norm_Destination_CrossCheck, batchDistance_8U, ...@@ -29,27 +27,25 @@ PERF_TEST_P(Norm_Destination_CrossCheck, batchDistance_8U,
) )
{ {
NormType normType = get<0>(GetParam()); NormType normType = get<0>(GetParam());
DestinationType destinationType = get<1>(GetParam()); int destinationType = get<1>(GetParam());
bool isCrossCheck = get<2>(GetParam()); bool isCrossCheck = get<2>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors; Mat queryDescriptors;
Mat trainDescriptors; Mat trainDescriptors;
Mat dist; Mat dist;
Mat ndix; Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, CV_8U); generateData(queryDescriptors, trainDescriptors, CV_8U);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE() TEST_CYCLE()
{ {
batchDistance(queryDescriptors, trainDescriptors, dist, destinationType, (isCrossCheck) ? ndix : noArray(), batchDistance(queryDescriptors, trainDescriptors, dist, destinationType, (isCrossCheck) ? ndix : noArray(),
normType, knn, Mat(), 0, isCrossCheck); normType, knn, Mat(), 0, isCrossCheck);
} }
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
} }
PERF_TEST_P(Norm_CrossCheck, batchDistance_Dest_32S, PERF_TEST_P(Norm_CrossCheck, batchDistance_Dest_32S,
...@@ -60,25 +56,23 @@ 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()); NormType normType = get<0>(GetParam());
bool isCrossCheck = get<1>(GetParam()); bool isCrossCheck = get<1>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors; Mat queryDescriptors;
Mat trainDescriptors; Mat trainDescriptors;
Mat dist; Mat dist;
Mat ndix; Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, CV_8U); generateData(queryDescriptors, trainDescriptors, CV_8U);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE() TEST_CYCLE()
{ {
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32S, (isCrossCheck) ? ndix : noArray(), batchDistance(queryDescriptors, trainDescriptors, dist, CV_32S, (isCrossCheck) ? ndix : noArray(),
normType, knn, Mat(), 0, isCrossCheck); normType, knn, Mat(), 0, isCrossCheck);
} }
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
} }
PERF_TEST_P(Source_CrossCheck, batchDistance_L2, PERF_TEST_P(Source_CrossCheck, batchDistance_L2,
...@@ -87,27 +81,25 @@ 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()); bool isCrossCheck = get<1>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors; Mat queryDescriptors;
Mat trainDescriptors; Mat trainDescriptors;
Mat dist; Mat dist;
Mat ndix; Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, sourceType); generateData(queryDescriptors, trainDescriptors, sourceType);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE() TEST_CYCLE()
{ {
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(), batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(),
NORM_L2, knn, Mat(), 0, isCrossCheck); NORM_L2, knn, Mat(), 0, isCrossCheck);
} }
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
} }
PERF_TEST_P(Norm_CrossCheck, batchDistance_32F, PERF_TEST_P(Norm_CrossCheck, batchDistance_32F,
...@@ -118,25 +110,23 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_32F, ...@@ -118,25 +110,23 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_32F,
{ {
NormType normType = get<0>(GetParam()); NormType normType = get<0>(GetParam());
bool isCrossCheck = get<1>(GetParam()); bool isCrossCheck = get<1>(GetParam());
int knn = isCrossCheck ? 1 : 0;
Mat queryDescriptors; Mat queryDescriptors;
Mat trainDescriptors; Mat trainDescriptors;
Mat dist; Mat dist;
Mat ndix; Mat ndix;
int knn = 1;
generateData(queryDescriptors, trainDescriptors, CV_32F); generateData(queryDescriptors, trainDescriptors, CV_32F);
if(!isCrossCheck)
{
knn = 0;
}
declare.time(30);
TEST_CYCLE() TEST_CYCLE()
{ {
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(), batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(),
normType, knn, Mat(), 0, isCrossCheck); normType, knn, Mat(), 0, isCrossCheck);
} }
SANITY_CHECK(dist);
if (isCrossCheck) SANITY_CHECK(ndix);
} }
void generateData( Mat& query, Mat& train, const int sourceType ) void generateData( Mat& query, Mat& train, const int sourceType )
......
...@@ -6,15 +6,23 @@ using namespace perf; ...@@ -6,15 +6,23 @@ using namespace perf;
using std::tr1::make_tuple; using std::tr1::make_tuple;
using std::tr1::get; 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 \ #define FAST_IMAGES \
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\ "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
"stitching/a3.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); Mat frame = imread(filename, IMREAD_GRAYSCALE);
if (frame.empty()) if (frame.empty())
...@@ -22,13 +30,11 @@ PERF_TEST_P(fast, detectForORB, testing::Values(FAST_IMAGES)) ...@@ -22,13 +30,11 @@ PERF_TEST_P(fast, detectForORB, testing::Values(FAST_IMAGES))
declare.in(frame); declare.in(frame);
FastFeatureDetector fd(20, true, FastFeatureDetector::TYPE_5_8); FastFeatureDetector fd(20, true, type);
vector<KeyPoint> points; vector<KeyPoint> points;
TEST_CYCLE() fd.detect(frame, points); TEST_CYCLE() fd.detect(frame, points);
fd = FastFeatureDetector(20, true, FastFeatureDetector::TYPE_7_12);
TEST_CYCLE() fd.detect(frame, points); SANITY_CHECK_KEYPOINTS(points);
fd = FastFeatureDetector(20, true, FastFeatureDetector::TYPE_9_16);
TEST_CYCLE() fd.detect(frame, points);
} }
...@@ -26,6 +26,8 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES)) ...@@ -26,6 +26,8 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
vector<KeyPoint> points; vector<KeyPoint> points;
TEST_CYCLE() detector(frame, mask, points); TEST_CYCLE() detector(frame, mask, points);
SANITY_CHECK_KEYPOINTS(points);
} }
PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES)) PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
...@@ -46,6 +48,8 @@ PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES)) ...@@ -46,6 +48,8 @@ PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
Mat descriptors; Mat descriptors;
TEST_CYCLE() detector(frame, mask, points, descriptors, true); TEST_CYCLE() detector(frame, mask, points, descriptors, true);
SANITY_CHECK(descriptors);
} }
PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES)) PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
...@@ -64,4 +68,7 @@ PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES)) ...@@ -64,4 +68,7 @@ PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
Mat descriptors; Mat descriptors;
TEST_CYCLE() detector(frame, mask, points, descriptors, false); TEST_CYCLE() detector(frame, mask, points, descriptors, false);
SANITY_CHECK_KEYPOINTS(points);
SANITY_CHECK(descriptors);
} }
...@@ -23,5 +23,6 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, ...@@ -23,5 +23,6 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile,
TEST_CYCLE() cap.open(filename); TEST_CYCLE() cap.open(filename);
SANITY_CHECK(cap.isOpened()); bool dummy = cap.isOpened();
SANITY_CHECK(dummy);
} }
...@@ -25,5 +25,6 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame, ...@@ -25,5 +25,6 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
TEST_CYCLE() { Mat image = imread(filename, 1); writer << image; } TEST_CYCLE() { Mat image = imread(filename, 1); writer << image; }
SANITY_CHECK(writer.isOpened()); bool dummy = writer.isOpened();
SANITY_CHECK(dummy);
} }
...@@ -210,13 +210,7 @@ if(ANDROID) ...@@ -210,13 +210,7 @@ if(ANDROID)
list(REMOVE_ITEM android_lib_project_files "${ANDROID_MANIFEST_FILE}") list(REMOVE_ITEM android_lib_project_files "${ANDROID_MANIFEST_FILE}")
foreach(f ${android_lib_project_files}) foreach(f ${android_lib_project_files})
if(NOT f MATCHES "\\.svn") if(NOT f MATCHES "\\.svn")
add_custom_command( configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${f}" "${OpenCV_BINARY_DIR}/${f}")
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}"
)
list(APPEND lib_proj_files "${OpenCV_BINARY_DIR}/${f}") list(APPEND lib_proj_files "${OpenCV_BINARY_DIR}/${f}")
if(NOT f MATCHES "jni/.+") if(NOT f MATCHES "jni/.+")
...@@ -250,11 +244,13 @@ if(ANDROID) ...@@ -250,11 +244,13 @@ if(ANDROID)
COMMAND ${CMAKE_COMMAND} -E remove ${lib_target_files} 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 ${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 ${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}" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${ANDROID_MANIFEST_FILE}"
DEPENDS ${lib_proj_files} DEPENDS ${lib_proj_files}
COMMENT "Generating OpenCV Android library project. SDK target: ${lib_target_sdk_target}" 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_PROJECT_PROPERTIES_FILE}" DESTINATION ${JAVA_INSTALL_ROOT} COMPONENT main)
install(FILES "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_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 # creating empty 'gen' and 'res' folders
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="cls"/> <classpathentry kind="output" path="cls"/>
</classpath> </classpath>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>OpenCV Library - 2.4.2</name> <name>OpenCV Library - @OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv" package="org.opencv"
android:versionCode="242" android:versionCode="@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@"
android:versionName="2.4.2"> android:versionName="@OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@"
<uses-sdk android:minSdkVersion="8" /> <uses-sdk android:minSdkVersion="8" />
</manifest> </manifest>
...@@ -26,6 +26,8 @@ PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES)) ...@@ -26,6 +26,8 @@ PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES))
vector<KeyPoint> points; vector<KeyPoint> points;
TEST_CYCLE() detector(frame, mask, points); TEST_CYCLE() detector(frame, mask, points);
SANITY_CHECK_KEYPOINTS(points);
} }
PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES)) PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES))
...@@ -45,6 +47,8 @@ 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); detector(frame, mask, points);
TEST_CYCLE() detector(frame, mask, points, descriptors, true); TEST_CYCLE() detector(frame, mask, points, descriptors, true);
SANITY_CHECK(descriptors, 1e-4);
} }
PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES)) PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES))
...@@ -62,4 +66,7 @@ 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; vector<float> descriptors;
TEST_CYCLE() detector(frame, mask, points, descriptors, false); TEST_CYCLE() detector(frame, mask, points, descriptors, false);
SANITY_CHECK_KEYPOINTS(points);
SANITY_CHECK(descriptors, 1e-4);
} }
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include <list> #include <list>
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#define ENABLE_LOG 1 #define ENABLE_LOG 0
// TODO remove LOG macros, add logging class // TODO remove LOG macros, add logging class
#if ENABLE_LOG #if ENABLE_LOG
......
...@@ -56,6 +56,8 @@ PERF_TEST_P(stitch, a123, TEST_DETECTORS) ...@@ -56,6 +56,8 @@ PERF_TEST_P(stitch, a123, TEST_DETECTORS)
stitcher.stitch(imgs, pano); stitcher.stitch(imgs, pano);
stopTimer(); stopTimer();
} }
SANITY_CHECK(pano, 2);
} }
PERF_TEST_P(stitch, b12, TEST_DETECTORS) PERF_TEST_P(stitch, b12, TEST_DETECTORS)
...@@ -88,6 +90,8 @@ PERF_TEST_P(stitch, b12, TEST_DETECTORS) ...@@ -88,6 +90,8 @@ PERF_TEST_P(stitch, b12, TEST_DETECTORS)
stitcher.stitch(imgs, pano); stitcher.stitch(imgs, pano);
stopTimer(); stopTimer();
} }
SANITY_CHECK(pano, 2);
} }
PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS) PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
...@@ -122,8 +126,7 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS) ...@@ -122,8 +126,7 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
detail::MatchesInfo pairwise_matches; detail::MatchesInfo pairwise_matches;
declare.in(features1.descriptors, features2.descriptors) declare.in(features1.descriptors, features2.descriptors);
.iterations(100);
while(next()) while(next())
{ {
...@@ -133,6 +136,8 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS) ...@@ -133,6 +136,8 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
stopTimer(); stopTimer();
matcher->collectGarbage(); matcher->collectGarbage();
} }
SANITY_CHECK_MATCHES(pairwise_matches.matches);
} }
PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine( PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine(
...@@ -186,4 +191,8 @@ PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine( ...@@ -186,4 +191,8 @@ PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine(
stopTimer(); stopTimer();
matcher->collectGarbage(); matcher->collectGarbage();
} }
std::vector<DMatch>& matches = pairwise_matches[0].matches;
SANITY_CHECK_MATCHES(matches);
} }
...@@ -74,7 +74,9 @@ void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &imag ...@@ -74,7 +74,9 @@ void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &imag
const vector<pair<Mat,uchar> > &masks) const vector<pair<Mat,uchar> > &masks)
{ {
LOGLN("Exposure compensation..."); LOGLN("Exposure compensation...");
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
CV_Assert(corners.size() == images.size() && images.size() == masks.size()); CV_Assert(corners.size() == images.size() && images.size() == masks.size());
......
...@@ -105,7 +105,9 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c ...@@ -105,7 +105,9 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c
vector<CameraParams> &cameras) vector<CameraParams> &cameras)
{ {
LOGLN("Estimating rotations..."); LOGLN("Estimating rotations...");
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
const int num_images = static_cast<int>(features.size()); const int num_images = static_cast<int>(features.size());
...@@ -172,7 +174,9 @@ void BundleAdjusterBase::estimate(const vector<ImageFeatures> &features, ...@@ -172,7 +174,9 @@ void BundleAdjusterBase::estimate(const vector<ImageFeatures> &features,
vector<CameraParams> &cameras) vector<CameraParams> &cameras)
{ {
LOG_CHAT("Bundle adjustment"); LOG_CHAT("Bundle adjustment");
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
num_images_ = static_cast<int>(features.size()); num_images_ = static_cast<int>(features.size());
features_ = &features[0]; features_ = &features[0];
...@@ -582,7 +586,9 @@ void BundleAdjusterRay::calcJacobian(Mat &jac) ...@@ -582,7 +586,9 @@ void BundleAdjusterRay::calcJacobian(Mat &jac)
void waveCorrect(vector<Mat> &rmats, WaveCorrectKind kind) void waveCorrect(vector<Mat> &rmats, WaveCorrectKind kind)
{ {
LOGLN("Wave correcting..."); LOGLN("Wave correcting...");
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
Mat moment = Mat::zeros(3, 3, CV_32F); Mat moment = Mat::zeros(3, 3, CV_32F);
for (size_t i = 0; i < rmats.size(); ++i) for (size_t i = 0; i < rmats.size(); ++i)
......
...@@ -52,10 +52,12 @@ void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne ...@@ -52,10 +52,12 @@ void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
vector<Mat> &masks) vector<Mat> &masks)
{ {
LOGLN("Finding seams..."); LOGLN("Finding seams...");
if (src.size() == 0) if (src.size() == 0)
return; return;
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
images_ = src; images_ = src;
sizes_.resize(src.size()); sizes_.resize(src.size());
...@@ -87,10 +89,12 @@ void VoronoiSeamFinder::find(const vector<Size> &sizes, const vector<Point> &cor ...@@ -87,10 +89,12 @@ void VoronoiSeamFinder::find(const vector<Size> &sizes, const vector<Point> &cor
vector<Mat> &masks) vector<Mat> &masks)
{ {
LOGLN("Finding seams..."); LOGLN("Finding seams...");
if (sizes.size() == 0) if (sizes.size() == 0)
return; return;
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
sizes_ = sizes; sizes_ = sizes;
corners_ = corners; corners_ = corners;
...@@ -161,7 +165,9 @@ DpSeamFinder::DpSeamFinder(CostFunction costFunc) : costFunc_(costFunc) {} ...@@ -161,7 +165,9 @@ DpSeamFinder::DpSeamFinder(CostFunction costFunc) : costFunc_(costFunc) {}
void DpSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners, vector<Mat> &masks) void DpSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners, vector<Mat> &masks)
{ {
LOGLN("Finding seams..."); LOGLN("Finding seams...");
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
if (src.size() == 0) if (src.size() == 0)
return; return;
...@@ -700,7 +706,7 @@ void DpSeamFinder::computeCosts( ...@@ -700,7 +706,7 @@ void DpSeamFinder::computeCosts(
{ {
CV_Assert(states_[comp] & INTERS); CV_Assert(states_[comp] & INTERS);
// compute costs // compute costs
float (*diff)(const Mat&, int, int, const Mat&, int, int) = 0; float (*diff)(const Mat&, int, int, const Mat&, int, int) = 0;
if (image1.type() == CV_32FC3 && image2.type() == CV_32FC3) if (image1.type() == CV_32FC3 && image2.type() == CV_32FC3)
...@@ -1055,10 +1061,10 @@ public: ...@@ -1055,10 +1061,10 @@ public:
void findInPair(size_t first, size_t second, Rect roi); void findInPair(size_t first, size_t second, Rect roi);
private: 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); const Mat &mask1, const Mat &mask2, GCGraph<float> &graph);
void setGraphWeightsColorGrad(const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, 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, const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
GCGraph<float> &graph); GCGraph<float> &graph);
vector<Mat> dx_, dy_; vector<Mat> dx_, dy_;
...@@ -1148,8 +1154,8 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat & ...@@ -1148,8 +1154,8 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &
void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad( void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, 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,
GCGraph<float> &graph) GCGraph<float> &graph)
{ {
const Size img_size = img1.size(); const Size img_size = img1.size();
...@@ -1177,7 +1183,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad( ...@@ -1177,7 +1183,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
float grad = dx1.at<float>(y, x) + dx1.at<float>(y, x + 1) + 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; 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)) + 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; weight_eps;
if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y, x + 1) || if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y, x + 1) ||
!mask2.at<uchar>(y, x) || !mask2.at<uchar>(y, x + 1)) !mask2.at<uchar>(y, x) || !mask2.at<uchar>(y, x + 1))
...@@ -1186,10 +1192,10 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad( ...@@ -1186,10 +1192,10 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
} }
if (y < img_size.height - 1) 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; 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)) + 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 + normL2(img1.at<Point3f>(y + 1, x), img2.at<Point3f>(y + 1, x))) / grad +
weight_eps; weight_eps;
if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y + 1, x) || if (!mask1.at<uchar>(y, x) || !mask1.at<uchar>(y + 1, x) ||
!mask2.at<uchar>(y, x) || !mask2.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) ...@@ -1271,7 +1277,7 @@ void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)
setGraphWeightsColor(subimg1, subimg2, submask1, submask2, graph); setGraphWeightsColor(subimg1, subimg2, submask1, submask2, graph);
break; break;
case GraphCutSeamFinder::COST_COLOR_GRAD: case GraphCutSeamFinder::COST_COLOR_GRAD:
setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2, setGraphWeightsColorGrad(subimg1, subimg2, subdx1, subdx2, subdy1, subdy2,
submask1, submask2, graph); submask1, submask2, graph);
break; break;
default: default:
...@@ -1402,17 +1408,17 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi) ...@@ -1402,17 +1408,17 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi)
} }
} }
} }
Mat terminals, leftT, rightT, top, bottom; Mat terminals, leftT, rightT, top, bottom;
switch (cost_type_) switch (cost_type_)
{ {
case GraphCutSeamFinder::COST_COLOR: case GraphCutSeamFinder::COST_COLOR:
setGraphWeightsColor(subimg1, subimg2, submask1, submask2, setGraphWeightsColor(subimg1, subimg2, submask1, submask2,
terminals, leftT, rightT, top, bottom); terminals, leftT, rightT, top, bottom);
break; break;
case GraphCutSeamFinder::COST_COLOR_GRAD: 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); submask1, submask2, terminals, leftT, rightT, top, bottom);
break; break;
default: default:
...@@ -1448,7 +1454,7 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi) ...@@ -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) Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)
{ {
const Size img_size = img1.size(); const Size img_size = img1.size();
...@@ -1540,7 +1546,7 @@ void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img ...@@ -1540,7 +1546,7 @@ void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img
void GraphCutSeamFinderGpu::setGraphWeightsColorGrad( void GraphCutSeamFinderGpu::setGraphWeightsColorGrad(
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, 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) Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)
{ {
const Size img_size = img1.size(); const Size img_size = img1.size();
......
...@@ -152,7 +152,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) ...@@ -152,7 +152,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano)
Mat &pano_ = pano.getMatRef(); Mat &pano_ = pano.getMatRef();
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
vector<Point> corners(imgs_.size()); vector<Point> corners(imgs_.size());
vector<Mat> masks_warped(imgs_.size()); vector<Mat> masks_warped(imgs_.size());
...@@ -201,7 +203,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano) ...@@ -201,7 +203,9 @@ Stitcher::Status Stitcher::composePanorama(InputArray images, OutputArray pano)
masks.clear(); masks.clear();
LOGLN("Compositing..."); LOGLN("Compositing...");
#if ENABLE_LOG
t = getTickCount(); t = getTickCount();
#endif
Mat img_warped, img_warped_s; Mat img_warped, img_warped_s;
Mat dilated_mask, seam_mask, mask, mask_warped; Mat dilated_mask, seam_mask, mask, mask_warped;
...@@ -349,7 +353,9 @@ Stitcher::Status Stitcher::matchImages() ...@@ -349,7 +353,9 @@ Stitcher::Status Stitcher::matchImages()
full_img_sizes_.resize(imgs_.size()); full_img_sizes_.resize(imgs_.size());
LOGLN("Finding features..."); LOGLN("Finding features...");
#if ENABLE_LOG
int64 t = getTickCount(); int64 t = getTickCount();
#endif
for (size_t i = 0; i < imgs_.size(); ++i) for (size_t i = 0; i < imgs_.size(); ++i)
{ {
...@@ -406,7 +412,9 @@ Stitcher::Status Stitcher::matchImages() ...@@ -406,7 +412,9 @@ Stitcher::Status Stitcher::matchImages()
LOGLN("Finding features, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec"); LOGLN("Finding features, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
LOG("Pairwise matching"); LOG("Pairwise matching");
#if ENABLE_LOG
t = getTickCount(); t = getTickCount();
#endif
(*features_matcher_)(features_, pairwise_matches_, matching_mask_); (*features_matcher_)(features_, pairwise_matches_, matching_mask_);
features_matcher_->collectGarbage(); features_matcher_->collectGarbage();
LOGLN("Pairwise matching, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec"); LOGLN("Pairwise matching, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
......
...@@ -10,7 +10,8 @@ endif() ...@@ -10,7 +10,8 @@ endif()
set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE) 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_glob_module_sources()
ocv_module_include_directories() ocv_module_include_directories()
ocv_create_module() ocv_create_module()
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define __OPENCV_TS_PERF_HPP__ #define __OPENCV_TS_PERF_HPP__
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "ts_gtest.h" #include "ts_gtest.h"
#ifdef HAVE_TBB #ifdef HAVE_TBB
...@@ -165,6 +166,8 @@ class CV_EXPORTS Regression ...@@ -165,6 +166,8 @@ class CV_EXPORTS Regression
{ {
public: public:
static Regression& add(TestBase* test, const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); 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"); 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); Regression& operator() (const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
...@@ -199,6 +202,8 @@ private: ...@@ -199,6 +202,8 @@ private:
}; };
#define SANITY_CHECK(array, ...) ::perf::Regression::add(this, #array, array , ## __VA_ARGS__) #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__)
/*****************************************************************************************\ /*****************************************************************************************\
......
...@@ -103,6 +103,38 @@ Regression& Regression::add(TestBase* test, const std::string& name, cv::InputAr ...@@ -103,6 +103,38 @@ Regression& Regression::add(TestBase* test, const std::string& name, cv::InputAr
return instance()(name, array, eps, err); 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) void Regression::Init(const std::string& testSuitName, const std::string& ext)
{ {
instance().init(testSuitName, ext); instance().init(testSuitName, ext);
...@@ -490,6 +522,12 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR ...@@ -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) 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(); std::string nodename = getCurrentTestNodeName();
cv::FileNode n = rootIn[nodename]; cv::FileNode n = rootIn[nodename];
...@@ -674,6 +712,8 @@ cv::Size TestBase::getSize(cv::InputArray a) ...@@ -674,6 +712,8 @@ cv::Size TestBase::getSize(cv::InputArray a)
bool TestBase::next() bool TestBase::next()
{ {
bool has_next = ++currentIter < nIters && totalTime < timeLimit; bool has_next = ++currentIter < nIters && totalTime < timeLimit;
cv::theRNG().state = param_seed; //this rng should generate same numbers for each run
#ifdef ANDROID #ifdef ANDROID
if (log_power_checkpoints) if (log_power_checkpoints)
{ {
...@@ -948,7 +988,6 @@ void TestBase::SetUp() ...@@ -948,7 +988,6 @@ void TestBase::SetUp()
currentIter = (unsigned int)-1; currentIter = (unsigned int)-1;
timeLimit = timeLimitDefault; timeLimit = timeLimitDefault;
times.clear(); times.clear();
cv::theRNG().state = param_seed;//this rng should generate same numbers for each run
} }
void TestBase::TearDown() void TestBase::TearDown()
......
...@@ -91,6 +91,10 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine( ...@@ -91,6 +91,10 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine(
Size(winSize, winSize), maxLevel, criteria, Size(winSize, winSize), maxLevel, criteria,
flags, minEigThreshold); 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; 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 ...@@ -166,6 +170,10 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize_Deriv, OpticalFlowPyrLK_self, testing::Com
Size(winSize, winSize), maxLevel, criteria, Size(winSize, winSize), maxLevel, criteria,
flags, minEigThreshold); flags, minEigThreshold);
} }
SANITY_CHECK(outPoints);
SANITY_CHECK(status);
SANITY_CHECK(err, 1e-5);
} }
CV_ENUM(PyrBorderMode, BORDER_DEFAULT, BORDER_TRANSPARENT); CV_ENUM(PyrBorderMode, BORDER_DEFAULT, BORDER_TRANSPARENT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment