Commit 743dce6a authored by Ilya Lavrenov's avatar Ilya Lavrenov

Merge remote-tracking branch 'upstream/master' into SIMDFastAreaResize-2

parents aa0dafcc 2508d8e2
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine"
android:versionCode="23@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.3" >
android:versionCode="24@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.4" >
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
......
......@@ -358,6 +358,8 @@ public class ManagerActivity extends Activity
else
{
temp.put("Activity", "n");
if (!PublicName.equals("Built-in OpenCV library"))
Tags = "safe to remove";
}
}
else
......
......@@ -2,8 +2,6 @@
# CMake file for OpenCV docs
#
file(GLOB FILES_DOC *.htm *.txt *.jpg *.png *.pdf)
file(GLOB FILES_DOC_VS vidsurv/*.doc)
file(GLOB FILES_TEX *.tex *.sty *.bib)
file(GLOB FILES_TEX_PICS pics/*.png pics/*.jpg)
......@@ -11,6 +9,14 @@ if(BUILD_DOCS AND HAVE_SPHINX)
project(opencv_docs)
set(DOC_LIST "${OpenCV_SOURCE_DIR}/doc/opencv-logo.png" "${OpenCV_SOURCE_DIR}/doc/opencv-logo2.png"
"${OpenCV_SOURCE_DIR}/doc/opencv-logo-white.png" "${OpenCV_SOURCE_DIR}/doc/opencv.ico"
"${OpenCV_SOURCE_DIR}/doc/haartraining.htm" "${OpenCV_SOURCE_DIR}/doc/license.txt"
"${OpenCV_SOURCE_DIR}/doc/pattern.png" "${OpenCV_SOURCE_DIR}/doc/acircles_pattern.png")
set(OPTIONAL_DOC_LIST "")
set(OPENCV2_BASE_MODULES core imgproc highgui video calib3d features2d objdetect ml flann gpu photo stitching nonfree contrib legacy)
# build lists of modules to be documented
......@@ -81,6 +87,9 @@ if(BUILD_DOCS AND HAVE_SPHINX)
COMMENT "Generating the PDF Manuals"
)
LIST(APPEND OPTIONAL_DOC_LIST "${CMAKE_BINARY_DIR}/doc/opencv2refman.pdf" "${CMAKE_BINARY_DIR}/doc/opencv2manager.pdf"
"${CMAKE_BINARY_DIR}/doc/opencv_user.pdf" "${CMAKE_BINARY_DIR}/doc/opencv_tutorials.pdf" "${CMAKE_BINARY_DIR}/doc/opencv_cheatsheet.pdf")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(docs PROPERTIES FOLDER "documentation")
endif()
......@@ -97,7 +106,13 @@ if(BUILD_DOCS AND HAVE_SPHINX)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(html_docs PROPERTIES FOLDER "documentation")
endif()
endif()
install(FILES ${FILES_DOC} DESTINATION "${OPENCV_DOC_INSTALL_PATH}" COMPONENT main)
install(FILES ${FILES_DOC_VS} DESTINATION "${OPENCV_DOC_INSTALL_PATH}/vidsurv" COMPONENT main)
foreach(f ${DOC_LIST})
install(FILES "${f}" DESTINATION "${OPENCV_DOC_INSTALL_PATH}" COMPONENT main)
endforeach()
foreach(f ${OPTIONAL_DOC_LIST})
install(FILES "${f}" DESTINATION "${OPENCV_DOC_INSTALL_PATH}" OPTIONAL)
endforeach()
endif()
\ No newline at end of file
......@@ -16,7 +16,7 @@ typedef perf::TestBaseWithParam<int> PointsNum;
PERF_TEST_P(PointsNum_Algo, solvePnP,
testing::Combine(
testing::Values(4, 3*9, 7*13),
testing::Values(/*4,*/ 3*9, 7*13), //TODO: find why results on 4 points are too unstable
testing::Values((int)CV_ITERATIVE, (int)CV_EPNP)
)
)
......
......@@ -109,13 +109,6 @@ template<typename _Tp> class CV_EXPORTS MatIterator_;
template<typename _Tp> class CV_EXPORTS MatConstIterator_;
template<typename _Tp> class CV_EXPORTS MatCommaInitializer_;
#if !defined(ANDROID) || (defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_WCHAR_T)
typedef std::basic_string<wchar_t> WString;
CV_EXPORTS string fromUtf16(const WString& str);
CV_EXPORTS WString toUtf16(const string& str);
#endif
CV_EXPORTS string format( const char* fmt, ... );
CV_EXPORTS string tempfile( const char* suffix CV_DEFAULT(0));
......@@ -1284,6 +1277,8 @@ public:
operator _Tp* ();
operator const _Tp*() const;
bool operator==(const Ptr<_Tp>& ptr) const;
_Tp* obj; //< the object pointer.
int* refcount; //< the associated reference counter
};
......
......@@ -2690,6 +2690,11 @@ template<typename _Tp> template<typename _Tp2> inline const Ptr<_Tp2> Ptr<_Tp>::
return p;
}
template<typename _Tp> inline bool Ptr<_Tp>::operator==(const Ptr<_Tp>& _ptr) const
{
return refcount == _ptr.refcount;
}
//// specializied implementations of Ptr::delete_obj() for classic OpenCV types
template<> CV_EXPORTS void Ptr<CvMat>::delete_obj();
......
......@@ -45,7 +45,6 @@
#include <ctype.h>
#include <deque>
#include <iterator>
#include <wchar.h>
#define USE_ZLIB 1
......@@ -156,35 +155,6 @@ cv::string cv::FileStorage::getDefaultObjectName(const string& _filename)
return cv::string(name);
}
namespace cv
{
#if !defined(ANDROID) || (defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_WCHAR_T)
string fromUtf16(const WString& str)
{
cv::AutoBuffer<char> _buf(str.size()*4 + 1);
char* buf = _buf;
size_t sz = wcstombs(buf, str.c_str(), str.size());
if( sz == (size_t)-1 )
return string();
buf[sz] = '\0';
return string(buf);
}
WString toUtf16(const string& str)
{
cv::AutoBuffer<wchar_t> _buf(str.size() + 1);
wchar_t* buf = _buf;
size_t sz = mbstowcs(buf, str.c_str(), str.size());
if( sz == (size_t)-1 )
return WString();
buf[sz] = '\0';
return WString(buf);
}
#endif
}
typedef struct CvGenericHash
{
CV_SET_FIELDS()
......
......@@ -359,26 +359,24 @@ string format( const char* fmt, ... )
string tempfile( const char* suffix )
{
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
string fname;
#if defined WIN32 || defined _WIN32
char temp_dir[MAX_PATH + 1] = { 0 };
char temp_dir2[MAX_PATH + 1] = { 0 };
char temp_file[MAX_PATH + 1] = { 0 };
::GetTempPathA(sizeof(temp_dir), temp_dir);
if (temp_dir == 0 || temp_dir[0] == 0)
{
::GetTempPathA(sizeof(temp_dir2), temp_dir2);
temp_dir = temp_dir2;
}
if(0 == ::GetTempFileNameA(temp_dir, "ocv", 0, temp_file))
return string();
DeleteFileA(temp_file);
string name = temp_file;
if(suffix)
{
if (suffix[0] != '.')
return name + "." + suffix;
else
return name + suffix;
}
else
return name;
fname = temp_file;
# else
# ifdef ANDROID
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
......@@ -387,9 +385,7 @@ string tempfile( const char* suffix )
char defaultTemplate[] = "/tmp/__opencv_temp.XXXXXX";
# endif
string fname;
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
if(temp_dir == 0 || temp_dir[0] == 0)
if (temp_dir == 0 || temp_dir[0] == 0)
fname = defaultTemplate;
else
{
......@@ -401,19 +397,20 @@ string tempfile( const char* suffix )
}
const int fd = mkstemp((char*)fname.c_str());
if(fd == -1) return "";
if (fd == -1) return string();
close(fd);
remove(fname.c_str());
# endif
if(suffix)
if (suffix)
{
if (suffix[0] != '.')
fname = fname + "." + suffix;
return fname + "." + suffix;
else
fname += suffix;
return fname + suffix;
}
return fname;
# endif
}
static CvErrorCallback customErrorCallback = 0;
......
......@@ -31,7 +31,7 @@ PERF_TEST_P(fast, detect, testing::Combine(
declare.in(frame);
Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FAST");
ASSERT_FALSE( fd == 0 );
ASSERT_FALSE( fd.empty() );
fd->set("threshold", 20);
fd->set("nonmaxSuppression", true);
fd->set("type", type);
......
......@@ -531,7 +531,7 @@ void FlannBasedMatcher::train()
void FlannBasedMatcher::read( const FileNode& fn)
{
if (indexParams == 0)
if (indexParams.empty())
indexParams = new flann::IndexParams();
FileNode ip = fn["indexParams"];
......@@ -570,7 +570,7 @@ void FlannBasedMatcher::read( const FileNode& fn)
};
}
if (searchParams == 0)
if (searchParams.empty())
searchParams = new flann::SearchParams();
FileNode sp = fn["searchParams"];
......
......@@ -23,7 +23,7 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
string filename = getDataPath(get<0>(GetParam()));
bool isColor = get<1>(GetParam());
VideoWriter writer("perf_writer.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cv::Size(640, 480), isColor);
VideoWriter writer(cv::tempfile(".avi"), CV_FOURCC('X', 'V', 'I', 'D'), 25, cv::Size(640, 480), isColor);
TEST_CYCLE() { Mat image = imread(filename, 1); writer << image; }
......
......@@ -1048,7 +1048,18 @@ enum
COLOR_RGBA2mRGBA = 125,
COLOR_mRGBA2RGBA = 126,
COLOR_COLORCVT_MAX = 127
// Edge-Aware Demosaicing
COLOR_BayerBG2BGR_EA = 127,
COLOR_BayerGB2BGR_EA = 128,
COLOR_BayerRG2BGR_EA = 129,
COLOR_BayerGR2BGR_EA = 130,
COLOR_BayerBG2RGB_EA = COLOR_BayerRG2BGR_EA,
COLOR_BayerGB2RGB_EA = COLOR_BayerGR2BGR_EA,
COLOR_BayerRG2RGB_EA = COLOR_BayerBG2BGR_EA,
COLOR_BayerGR2RGB_EA = COLOR_BayerGB2BGR_EA,
COLOR_COLORCVT_MAX = 131
};
......@@ -1252,6 +1263,9 @@ protected:
Point2f bottomRight;
};
// main function for all demosaicing procceses
CV_EXPORTS_W void demosaicing(InputArray _src, OutputArray _dst, int code, int dcn = 0);
}
#endif /* __cplusplus */
......
......@@ -310,7 +310,18 @@ enum
CV_RGBA2mRGBA = 125,
CV_mRGBA2RGBA = 126,
CV_COLORCVT_MAX = 127
// Edge-Aware Demosaicing
CV_BayerBG2BGR_EA = 127,
CV_BayerGB2BGR_EA = 128,
CV_BayerRG2BGR_EA = 129,
CV_BayerGR2BGR_EA = 130,
CV_BayerBG2RGB_EA = CV_BayerRG2BGR_EA,
CV_BayerGB2RGB_EA = CV_BayerGR2BGR_EA,
CV_BayerRG2RGB_EA = CV_BayerBG2BGR_EA,
CV_BayerGR2RGB_EA = CV_BayerGB2BGR_EA,
CV_COLORCVT_MAX = 131
};
......
......@@ -276,3 +276,28 @@ PERF_TEST_P(Size_CvtMode2, cvtColorYUV420,
SANITY_CHECK(dst, 1);
}
CV_ENUM(EdgeAwareBayerMode, COLOR_BayerBG2BGR_EA, COLOR_BayerGB2BGR_EA, COLOR_BayerRG2BGR_EA, COLOR_BayerGR2BGR_EA)
typedef std::tr1::tuple<Size, EdgeAwareBayerMode> EdgeAwareParams;
typedef perf::TestBaseWithParam<EdgeAwareParams> EdgeAwareDemosaicingTest;
PERF_TEST_P(EdgeAwareDemosaicingTest, demosaicingEA,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)),
testing::ValuesIn(EdgeAwareBayerMode::all())
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
Mat src(sz, CV_8UC1);
Mat dst(sz, CV_8UC3);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cvtColor(src, dst, mode, 3);
SANITY_CHECK(dst, 1);
}
......@@ -70,7 +70,7 @@ PERF_TEST_P( Image_KernelSize, GaborFilter2d,
filter2D(sourceImage, filteredImage, CV_32F, gaborKernel);
}
SANITY_CHECK(filteredImage);
SANITY_CHECK(filteredImage, 1e-3);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -27,7 +27,7 @@ PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES))
TEST_CYCLE() detector(frame, mask, points);
SANITY_CHECK_KEYPOINTS(points);
SANITY_CHECK_KEYPOINTS(points, 1e-3);
}
PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES))
......@@ -67,6 +67,6 @@ PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES))
TEST_CYCLE() detector(frame, mask, points, descriptors, false);
SANITY_CHECK_KEYPOINTS(points);
SANITY_CHECK_KEYPOINTS(points, 1e-3);
SANITY_CHECK(descriptors, 1e-4);
}
......@@ -534,12 +534,14 @@ public:
int shrinkage;
};
enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT};
// An empty cascade will be created.
// Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed.
// Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed.
// Param scales is a number of scales from minScale to maxScale.
// Param rejfactor is used for NMS.
CV_WRAP SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55, const int rejfactor = 1);
// Param rejCriteria is used for NMS.
CV_WRAP SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55, const int rejCriteria = 1);
CV_WRAP virtual ~SCascade();
......@@ -571,7 +573,7 @@ private:
double maxScale;
int scales;
int rejfactor;
int rejCriteria;
};
CV_EXPORTS bool initModule_objdetect(void);
......
......@@ -46,10 +46,10 @@ namespace cv
{
CV_INIT_ALGORITHM(SCascade, "CascadeDetector.SCascade",
obj.info()->addParam(obj, "minScale", obj.minScale);
obj.info()->addParam(obj, "maxScale", obj.maxScale);
obj.info()->addParam(obj, "scales", obj.scales);
obj.info()->addParam(obj, "rejfactor", obj.rejfactor));
obj.info()->addParam(obj, "minScale", obj.minScale);
obj.info()->addParam(obj, "maxScale", obj.maxScale);
obj.info()->addParam(obj, "scales", obj.scales);
obj.info()->addParam(obj, "rejCriteria", obj.rejCriteria));
bool initModule_objdetect(void)
{
......
......@@ -422,7 +422,7 @@ struct cv::SCascade::Fields
};
cv::SCascade::SCascade(const double mins, const double maxs, const int nsc, const int rej)
: fields(0), minScale(mins), maxScale(maxs), scales(nsc), rejfactor(rej) {}
: fields(0), minScale(mins), maxScale(maxs), scales(nsc), rejCriteria(rej) {}
cv::SCascade::~SCascade() { delete fields;}
......@@ -439,6 +439,57 @@ bool cv::SCascade::load(const FileNode& fn)
return fields->fill(fn);
}
namespace {
typedef cv::SCascade::Detection Detection;
typedef std::vector<Detection> dvector;
struct ConfidenceGt
{
bool operator()(const Detection& a, const Detection& b) const
{
return a.confidence > b.confidence;
}
};
static float overlap(const cv::Rect &a, const cv::Rect &b)
{
int w = std::min(a.x + a.width, b.x + b.width) - std::max(a.x, b.x);
int h = std::min(a.y + a.height, b.y + b.height) - std::max(a.y, b.y);
return (w < 0 || h < 0)? 0.f : (float)(w * h);
}
void DollarNMS(dvector& objects)
{
static const float DollarThreshold = 0.65f;
std::sort(objects.begin(), objects.end(), ConfidenceGt());
for (dvector::iterator dIt = objects.begin(); dIt != objects.end(); ++dIt)
{
const Detection &a = *dIt;
for (dvector::iterator next = dIt + 1; next != objects.end(); )
{
const Detection &b = *next;
const float ovl = overlap(a.bb, b.bb) / std::min(a.bb.area(), b.bb.area());
if (ovl > DollarThreshold)
next = objects.erase(next);
else
++next;
}
}
}
static void suppress(int type, std::vector<Detection>& objects)
{
CV_Assert(type == cv::SCascade::DOLLAR);
DollarNMS(objects);
}
}
void cv::SCascade::detectNoRoi(const cv::Mat& image, std::vector<Detection>& objects) const
{
Fields& fld = *fields;
......@@ -459,6 +510,8 @@ void cv::SCascade::detectNoRoi(const cv::Mat& image, std::vector<Detection>& obj
}
}
}
if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects);
}
void cv::SCascade::detect(cv::InputArray _image, cv::InputArray _rois, std::vector<Detection>& objects) const
......@@ -506,6 +559,8 @@ void cv::SCascade::detect(cv::InputArray _image, cv::InputArray _rois, std::vect
}
}
}
if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects);
}
void cv::SCascade::detect(InputArray _image, InputArray _rois, OutputArray _rects, OutputArray _confs) const
......
......@@ -19,7 +19,7 @@ typedef TestBaseWithParam<String> match;
typedef std::tr1::tuple<String, int> matchVector_t;
typedef TestBaseWithParam<matchVector_t> matchVector;
#ifdef HAVE_OPENCV_NONFREE
#ifdef HAVE_OPENCV_NONFREE_TODO_FIND_WHY_SURF_IS_NOT_ABLE_TO_STITCH_PANOS
#define TEST_DETECTORS testing::Values("surf", "orb")
#else
#define TEST_DETECTORS testing::Values<String>("orb")
......@@ -57,7 +57,11 @@ PERF_TEST_P(stitch, a123, TEST_DETECTORS)
stopTimer();
}
SANITY_CHECK(pano, 2);
Mat pano_small;
if (!pano.empty())
resize(pano, pano_small, Size(320, 240), 0, 0, INTER_AREA);
SANITY_CHECK(pano_small, 5);
}
PERF_TEST_P(stitch, b12, TEST_DETECTORS)
......@@ -91,7 +95,11 @@ PERF_TEST_P(stitch, b12, TEST_DETECTORS)
stopTimer();
}
SANITY_CHECK(pano, 2);
Mat pano_small;
if (!pano.empty())
resize(pano, pano_small, Size(320, 240), 0, 0, INTER_AREA);
SANITY_CHECK(pano_small, 5);
}
PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
......@@ -137,7 +145,11 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
matcher->collectGarbage();
}
SANITY_CHECK_MATCHES(pairwise_matches.matches);
std::vector<DMatch>& matches = pairwise_matches.matches;
if (GetParam() == "orb") matches.resize(0);
for(size_t q = 0; q < matches.size(); ++q)
if (matches[q].imgIdx < 0) { matches.resize(q); break;}
SANITY_CHECK_MATCHES(matches);
}
PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine(
......@@ -193,6 +205,8 @@ PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine(
}
std::vector<DMatch>& matches = pairwise_matches[0].matches;
std::vector<DMatch>& matches = pairwise_matches[detectorName == "surf" ? 1 : 0].matches;
for(size_t q = 0; q < matches.size(); ++q)
if (matches[q].imgIdx < 0) { matches.resize(q); break;}
SANITY_CHECK_MATCHES(matches);
}
......@@ -350,7 +350,7 @@ void SurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)
Mat gray_image;
CV_Assert(image.type() == CV_8UC3);
cvtColor(image, gray_image, CV_BGR2GRAY);
if (surf == 0)
if (surf.empty())
{
detector_->detect(gray_image, features.keypoints);
extractor_->compute(gray_image, features.keypoints, features.descriptors);
......
This diff is collapsed.
......@@ -16,7 +16,8 @@ const std::string command_line_keys =
"{ perf_force_samples |100 |force set maximum number of samples for all tests}"
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_threads |-1 |the number of worker threads, if parallel execution is enabled}"
"{ perf_write_sanity | |allow to create new records for sanity checks}"
"{ perf_write_sanity | |create new records for sanity checks}"
"{ perf_verify_sanity | |fail tests having no regression data for sanity checks}"
#ifdef ANDROID
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
......@@ -41,6 +42,7 @@ static uint64 param_seed;
static double param_time_limit;
static int param_threads;
static bool param_write_sanity;
static bool param_verify_sanity;
#ifdef HAVE_CUDA
static bool param_run_cpu;
static int param_cuda_device;
......@@ -491,7 +493,7 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR
cv::minMaxLoc(diff.reshape(1), 0, &max);
FAIL() << " Absolute difference (=" << max << ") between argument \""
<< node.name() << "[" << idx << "]\" and expected value is bugger than " << eps;
<< node.name() << "[" << idx << "]\" and expected value is greater than " << eps;
}
}
else if (err == ERROR_RELATIVE)
......@@ -501,7 +503,7 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR
if (violations > 0)
{
FAIL() << " Relative difference (" << maxv << " of " << maxa << " allowed) between argument \""
<< node.name() << "[" << idx << "]\" and expected value is bugger than " << eps << " in " << violations << " points";
<< node.name() << "[" << idx << "]\" and expected value is greater than " << eps << " in " << violations << " points";
}
}
}
......@@ -545,7 +547,7 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR
cv::minMaxLoc(diff.reshape(1), 0, &max);
FAIL() << " Difference (=" << max << ") between argument1 \"" << node.name()
<< "\" and expected value is bugger than " << eps;
<< "\" and expected value is greater than " << eps;
}
}
else if (err == ERROR_RELATIVE)
......@@ -555,7 +557,7 @@ void Regression::verify(cv::FileNode node, cv::InputArray array, double eps, ERR
if (violations > 0)
{
FAIL() << " Relative difference (" << maxv << " of " << maxa << " allowed) between argument \"" << node.name()
<< "\" and expected value is bugger than " << eps << " in " << violations << " points";
<< "\" and expected value is greater than " << eps << " in " << violations << " points";
}
}
}
......@@ -595,10 +597,15 @@ Regression& Regression::operator() (const std::string& name, cv::InputArray arra
write() << nodename << "{";
}
// TODO: verify that name is alphanumeric, current error message is useless
write() << name << "{";
write(array);
write() << "}";
}
else if(param_verify_sanity)
{
ADD_FAILURE() << " No regression data for " << name << " argument";
}
}
else
{
......@@ -656,6 +663,7 @@ void TestBase::Init(int argc, const char* const argv[])
param_time_limit = std::max(0., args.get<double>("perf_time_limit"));
param_force_samples = args.get<unsigned int>("perf_force_samples");
param_write_sanity = args.has("perf_write_sanity");
param_verify_sanity = args.has("perf_verify_sanity");
param_threads = args.get<int>("perf_threads");
#ifdef ANDROID
param_affinity_mask = args.get<int>("perf_affinity_mask");
......@@ -970,7 +978,7 @@ void TestBase::validateMetrics()
if (m.gstddev > DBL_EPSILON)
{
EXPECT_GT(/*m.gmean * */1., /*m.gmean * */ 2 * sinh(m.gstddev * param_max_deviation))
<< " Test results are not reliable ((mean-sigma,mean+sigma) deviation interval is bigger than measured time interval).";
<< " Test results are not reliable ((mean-sigma,mean+sigma) deviation interval is greater than measured time interval).";
}
EXPECT_LE(m.outliers, std::max((unsigned int)cvCeil(m.samples * param_max_outliers / 100.), 1u))
......
......@@ -29,5 +29,5 @@ PERF_TEST_P(ImagePair, OpticalFlowDual_TVL1, testing::Values(impair("cv/optflow/
tvl1(frame1, frame2, flow);
}
SANITY_CHECK(flow);
SANITY_CHECK(flow, 0.5);
}
......@@ -41,7 +41,7 @@ void CV_BackgroundSubtractorTest::run(int)
Algorithm::create<BackgroundSubtractorGMG>("BackgroundSubtractor.GMG");
Mat fgmask;
if (fgbg == NULL)
if (fgbg.empty())
CV_Error(CV_StsError,"Failed to create Algorithm\n");
/**
......
......@@ -107,10 +107,41 @@ namespace
}
}
}
bool isFlowCorrect(Point2f u)
{
return !cvIsNaN(u.x) && !cvIsNaN(u.y) && (fabs(u.x) < 1e9) && (fabs(u.y) < 1e9);
}
double calcRMSE(const Mat_<Point2f>& flow1, const Mat_<Point2f>& flow2)
{
double sum = 0.0;
int counter = 0;
for (int i = 0; i < flow1.rows; ++i)
{
for (int j = 0; j < flow1.cols; ++j)
{
const Point2f u1 = flow1(i, j);
const Point2f u2 = flow2(i, j);
if (isFlowCorrect(u1) && isFlowCorrect(u2))
{
const Point2f diff = u1 - u2;
sum += diff.ddot(diff);
++counter;
}
}
}
return sqrt(sum / (1e-9 + counter));
}
}
TEST(Video_calcOpticalFlowDual_TVL1, Regression)
{
const double MAX_RMSE = 0.01;
const string frame1_path = TS::ptr()->get_data_path() + "optflow/RubberWhale1.png";
const string frame2_path = TS::ptr()->get_data_path() + "optflow/RubberWhale2.png";
const string gold_flow_path = TS::ptr()->get_data_path() + "optflow/tvl1_flow.flo";
......@@ -130,7 +161,11 @@ TEST(Video_calcOpticalFlowDual_TVL1, Regression)
#else
Mat_<Point2f> gold;
readOpticalFlowFromFile(gold, gold_flow_path);
double err = norm(gold, flow, NORM_INF);
EXPECT_EQ(0.0f, err);
ASSERT_EQ(gold.rows, flow.rows);
ASSERT_EQ(gold.cols, flow.cols);
const double err = calcRMSE(gold, flow);
EXPECT_LE(err, MAX_RMSE);
#endif
}
package org.opencv.samples.tutorial5;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.ListIterator;
......@@ -9,6 +11,7 @@ import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
......@@ -20,6 +23,7 @@ import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.widget.Toast;
public class Sample5CameraControl extends Activity implements CvCameraViewListener, OnTouchListener {
private static final String TAG = "OCVSample::Activity";
......@@ -100,6 +104,11 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen
public boolean onCreateOptionsMenu(Menu menu) {
List<String> effects = mOpenCvCameraView.getEffectList();
if (effects == null) {
Log.e(TAG, "Color effects are not supported by device!");
return true;
}
mEffectMenuItems = new MenuItem[effects.size()];
int idx = 0;
......@@ -115,13 +124,20 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen
public boolean onOptionsItemSelected(MenuItem item) {
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
mOpenCvCameraView.setEffect((String) item.getTitle());
Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show();
return true;
}
@SuppressLint("SimpleDateFormat")
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i(TAG,"onTouch event");
mOpenCvCameraView.takePicture(Environment.getExternalStorageDirectory().getPath() + "/sample_picture.jpg");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDateandTime = sdf.format(new Date());
String fileName = Environment.getExternalStorageDirectory().getPath() +
"/sample_picture_" + currentDateandTime + ".jpg";
mOpenCvCameraView.takePicture(fileName);
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
return false;
}
}
......@@ -25,6 +25,10 @@ public class SampleJavaCameraView extends JavaCameraView {
return mCamera.getParameters().getSupportedColorEffects();
}
public boolean isEffectSupported() {
return (mCamera.getParameters().getColorEffect() != null);
}
public String getEffect() {
return mCamera.getParameters().getColorEffect();
}
......@@ -48,6 +52,7 @@ public class SampleJavaCameraView extends JavaCameraView {
try {
FileOutputStream out = new FileOutputStream(mPictureFileName);
picture.compress(Bitmap.CompressFormat.JPEG, 90, out);
picture.recycle();
mCamera.startPreview();
} catch (Exception e) {
e.printStackTrace();
......
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