Merge remote-tracking branch 'upstream/master' into SIMDFastAreaResize-2
This commit is contained in:
commit
743dce6a4b
@ -1,8 +1,8 @@
|
||||
<?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()
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
1516
modules/imgproc/src/demosaicing.cpp
Normal file
1516
modules/imgproc/src/demosaicing.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -1685,11 +1685,13 @@ TEST(Imgproc_ColorBayer, accuracy) { CV_ColorBayerTest test; test.safe_run(); }
|
||||
|
||||
TEST(Imgproc_ColorBayer, regression)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
cvtest::TS* ts = cvtest::TS::ptr();
|
||||
|
||||
Mat given = imread(string(ts.get_data_path()) + "/cvtcolor/bayer_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat gold = imread(string(ts.get_data_path()) + "/cvtcolor/bayer_gold.png", CV_LOAD_IMAGE_UNCHANGED);
|
||||
Mat given = imread(string(ts->get_data_path()) + "/cvtcolor/bayer_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat gold = imread(string(ts->get_data_path()) + "/cvtcolor/bayer_gold.png", CV_LOAD_IMAGE_UNCHANGED);
|
||||
Mat result;
|
||||
|
||||
CV_Assert(given.data != NULL && gold.data != NULL);
|
||||
|
||||
cvtColor(given, result, CV_BayerBG2GRAY);
|
||||
|
||||
@ -1705,10 +1707,10 @@ TEST(Imgproc_ColorBayer, regression)
|
||||
|
||||
TEST(Imgproc_ColorBayerVNG, regression)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
cvtest::TS* ts = cvtest::TS::ptr();
|
||||
|
||||
Mat given = imread(string(ts.get_data_path()) + "/cvtcolor/bayer_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
string goldfname = string(ts.get_data_path()) + "/cvtcolor/bayerVNG_gold.png";
|
||||
Mat given = imread(string(ts->get_data_path()) + "/cvtcolor/bayer_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
string goldfname = string(ts->get_data_path()) + "/cvtcolor/bayerVNG_gold.png";
|
||||
Mat gold = imread(goldfname, CV_LOAD_IMAGE_UNCHANGED);
|
||||
Mat result;
|
||||
|
||||
@ -1731,91 +1733,94 @@ TEST(Imgproc_ColorBayerVNG, regression)
|
||||
}
|
||||
}
|
||||
|
||||
// creating Bayer pattern
|
||||
template <typename T, int depth>
|
||||
static void calculateBayerPattern(const Mat& src, Mat& bayer, const char* pattern)
|
||||
{
|
||||
Size ssize = src.size();
|
||||
const int scn = 1;
|
||||
bayer.create(ssize, CV_MAKETYPE(depth, scn));
|
||||
|
||||
if (!strcmp(pattern, "bg"))
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[1]);
|
||||
else if (x % 2)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[0]);
|
||||
else
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[2]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(pattern, "gb"))
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2 == 0)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[1]);
|
||||
else if (x % 2 == 0)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[0]);
|
||||
else
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[2]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(pattern, "rg"))
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[1]);
|
||||
else if (x % 2 == 0)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[0]);
|
||||
else
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2 == 0)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[1]);
|
||||
else if (x % 2)
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[0]);
|
||||
else
|
||||
bayer.at<T>(y, x) = static_cast<T>(src.at<Vec3b>(y, x)[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Imgproc_ColorBayerVNG_Strict, regression)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
cvtest::TS* ts = cvtest::TS::ptr();
|
||||
const char pattern[][3] = { "bg", "gb", "rg", "gr" };
|
||||
const std::string image_name = "lena.png";
|
||||
const std::string parent_path = string(ts.get_data_path()) + "/cvtcolor_strict/";
|
||||
const std::string parent_path = string(ts->get_data_path()) + "/cvtcolor_strict/";
|
||||
|
||||
Mat src, dst, bayer, reference;
|
||||
std::string full_path = parent_path + image_name;
|
||||
src = imread(full_path, CV_LOAD_IMAGE_UNCHANGED);
|
||||
Size ssize = src.size();
|
||||
|
||||
if (src.data == NULL)
|
||||
{
|
||||
ts.set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
|
||||
ts.printf(cvtest::TS::SUMMARY, "No input image\n");
|
||||
ts.set_gtest_status();
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
|
||||
ts->printf(cvtest::TS::SUMMARY, "No input image\n");
|
||||
ts->set_gtest_status();
|
||||
return;
|
||||
}
|
||||
|
||||
int type = -1;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
// creating Bayer pattern
|
||||
bayer.create(ssize, CV_MAKETYPE(src.depth(), 1));
|
||||
|
||||
if (!strcmp(pattern[i], "bg"))
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[1];
|
||||
else if (x % 2)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[0];
|
||||
else
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[2];
|
||||
}
|
||||
type = CV_BayerBG2BGR_VNG;
|
||||
}
|
||||
else if (!strcmp(pattern[i], "gb"))
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2 == 0)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[1];
|
||||
else if (x % 2 == 0)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[0];
|
||||
else
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[2];
|
||||
}
|
||||
type = CV_BayerGB2BGR_VNG;
|
||||
}
|
||||
else if (!strcmp(pattern[i], "rg"))
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[1];
|
||||
else if (x % 2 == 0)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[0];
|
||||
else
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[2];
|
||||
}
|
||||
type = CV_BayerRG2BGR_VNG;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int y = 0; y < ssize.height; ++y)
|
||||
for (int x = 0; x < ssize.width; ++x)
|
||||
{
|
||||
if ((x + y) % 2 == 0)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[1];
|
||||
else if (x % 2)
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[0];
|
||||
else
|
||||
bayer.at<uchar>(y, x) = src.at<Vec3b>(y, x)[2];
|
||||
}
|
||||
type = CV_BayerGR2BGR_VNG;
|
||||
}
|
||||
calculateBayerPattern<uchar, CV_8U>(src, bayer, pattern[i]);
|
||||
CV_Assert(!bayer.empty() && bayer.type() == CV_8UC1);
|
||||
|
||||
// calculating a dst image
|
||||
cvtColor(bayer, dst, type);
|
||||
cvtColor(bayer, dst, CV_BayerBG2BGR_VNG + i);
|
||||
|
||||
// reading a reference image
|
||||
full_path = parent_path + pattern[i] + image_name;
|
||||
@ -1829,16 +1834,17 @@ TEST(Imgproc_ColorBayerVNG_Strict, regression)
|
||||
if (reference.depth() != dst.depth() || reference.channels() != dst.channels() ||
|
||||
reference.size() != dst.size())
|
||||
{
|
||||
ts.set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
ts.printf(cvtest::TS::SUMMARY, "\nReference channels: %d\n"
|
||||
std::cout << reference(Rect(0, 0, 5, 5)) << std::endl << std::endl << std::endl;
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
ts->printf(cvtest::TS::SUMMARY, "\nReference channels: %d\n"
|
||||
"Actual channels: %d\n", reference.channels(), dst.channels());
|
||||
ts.printf(cvtest::TS::SUMMARY, "\nReference depth: %d\n"
|
||||
ts->printf(cvtest::TS::SUMMARY, "\nReference depth: %d\n"
|
||||
"Actual depth: %d\n", reference.depth(), dst.depth());
|
||||
ts.printf(cvtest::TS::SUMMARY, "\nReference rows: %d\n"
|
||||
ts->printf(cvtest::TS::SUMMARY, "\nReference rows: %d\n"
|
||||
"Actual rows: %d\n", reference.rows, dst.rows);
|
||||
ts.printf(cvtest::TS::SUMMARY, "\nReference cols: %d\n"
|
||||
ts->printf(cvtest::TS::SUMMARY, "\nReference cols: %d\n"
|
||||
"Actual cols: %d\n", reference.cols, dst.cols);
|
||||
ts.set_gtest_status();
|
||||
ts->set_gtest_status();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1849,16 +1855,15 @@ TEST(Imgproc_ColorBayerVNG_Strict, regression)
|
||||
int nonZero = countNonZero(diff.reshape(1) > 1);
|
||||
if (nonZero != 0)
|
||||
{
|
||||
ts.set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
|
||||
ts.printf(cvtest::TS::SUMMARY, "\nCount non zero in absdiff: %d\n", nonZero);
|
||||
ts.set_gtest_status();
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
|
||||
ts->printf(cvtest::TS::SUMMARY, "\nCount non zero in absdiff: %d\n", nonZero);
|
||||
ts->set_gtest_status();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GetTestMatrix(Mat& src)
|
||||
static void getTestMatrix(Mat& src)
|
||||
{
|
||||
Size ssize(1000, 1000);
|
||||
src.create(ssize, CV_32FC3);
|
||||
@ -1883,7 +1888,7 @@ void GetTestMatrix(Mat& src)
|
||||
}
|
||||
}
|
||||
|
||||
void validate_result(const Mat& reference, const Mat& actual, const Mat& src = Mat(), int mode = -1)
|
||||
static void validateResult(const Mat& reference, const Mat& actual, const Mat& src = Mat(), int mode = -1)
|
||||
{
|
||||
cvtest::TS* ts = cvtest::TS::ptr();
|
||||
Size ssize = reference.size();
|
||||
@ -1924,8 +1929,7 @@ void validate_result(const Mat& reference, const Mat& actual, const Mat& src = M
|
||||
TEST(Imgproc_ColorLab_Full, accuracy)
|
||||
{
|
||||
Mat src;
|
||||
GetTestMatrix(src);
|
||||
Mat reference(src.size(), CV_32FC3);
|
||||
getTestMatrix(src);
|
||||
Size ssize = src.size();
|
||||
CV_Assert(ssize.width == ssize.height);
|
||||
|
||||
@ -1942,12 +1946,245 @@ TEST(Imgproc_ColorLab_Full, accuracy)
|
||||
cv::Mat recons;
|
||||
cv::cvtColor(lab, recons, inverse_code);
|
||||
|
||||
validate_result(src, recons, src, forward_code);
|
||||
|
||||
// src *= 255.0f;
|
||||
// recons *= 255.0f;
|
||||
|
||||
// imshow("Test", src);
|
||||
// imshow("OpenCV", recons);
|
||||
// waitKey();
|
||||
validateResult(src, recons, src, forward_code);
|
||||
}
|
||||
|
||||
static void test_Bayer2RGB_EdgeAware_8u(const Mat& src, Mat& dst, int code)
|
||||
{
|
||||
if (dst.empty())
|
||||
dst.create(src.size(), CV_MAKETYPE(src.depth(), 3));
|
||||
Size size = src.size();
|
||||
size.width -= 1;
|
||||
size.height -= 1;
|
||||
|
||||
int dcn = dst.channels();
|
||||
CV_Assert(dcn == 3);
|
||||
|
||||
int step = src.step;
|
||||
const uchar* S = src.ptr<uchar>(1) + 1;
|
||||
uchar* D = dst.ptr<uchar>(1) + dcn;
|
||||
|
||||
int start_with_green = code == CV_BayerGB2BGR_EA || code == CV_BayerGR2BGR_EA ? 1 : 0;
|
||||
int blue = code == CV_BayerGB2BGR_EA || code == CV_BayerBG2BGR_EA ? 1 : 0;
|
||||
|
||||
for (int y = 1; y < size.height; ++y)
|
||||
{
|
||||
S = src.ptr<uchar>(y) + 1;
|
||||
D = dst.ptr<uchar>(y) + dcn;
|
||||
|
||||
if (start_with_green)
|
||||
{
|
||||
for (int x = 1; x < size.width; x += 2, S += 2, D += 2*dcn)
|
||||
{
|
||||
// red
|
||||
D[0] = (S[-1] + S[1]) / 2;
|
||||
D[1] = S[0];
|
||||
D[2] = (S[-step] + S[step]) / 2;
|
||||
if (!blue)
|
||||
std::swap(D[0], D[2]);
|
||||
}
|
||||
|
||||
S = src.ptr<uchar>(y) + 2;
|
||||
D = dst.ptr<uchar>(y) + 2*dcn;
|
||||
|
||||
for (int x = 2; x < size.width; x += 2, S += 2, D += 2*dcn)
|
||||
{
|
||||
// red
|
||||
D[0] = S[0];
|
||||
D[1] = (std::abs(S[-1] - S[1]) > std::abs(S[step] - S[-step]) ? (S[step] + S[-step] + 1) : (S[-1] + S[1] + 1)) / 2;
|
||||
D[2] = ((S[-step-1] + S[-step+1] + S[step-1] + S[step+1] + 2) / 4);
|
||||
if (!blue)
|
||||
std::swap(D[0], D[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 1; x < size.width; x += 2, S += 2, D += 2*dcn)
|
||||
{
|
||||
D[0] = S[0];
|
||||
D[1] = (std::abs(S[-1] - S[1]) > std::abs(S[step] - S[-step]) ? (S[step] + S[-step] + 1) : (S[-1] + S[1] + 1)) / 2;
|
||||
D[2] = ((S[-step-1] + S[-step+1] + S[step-1] + S[step+1] + 2) / 4);
|
||||
if (!blue)
|
||||
std::swap(D[0], D[2]);
|
||||
}
|
||||
|
||||
S = src.ptr<uchar>(y) + 2;
|
||||
D = dst.ptr<uchar>(y) + 2*dcn;
|
||||
|
||||
for (int x = 2; x < size.width; x += 2, S += 2, D += 2*dcn)
|
||||
{
|
||||
D[0] = (S[-1] + S[1] + 1) / 2;
|
||||
D[1] = S[0];
|
||||
D[2] = (S[-step] + S[step] + 1) / 2;
|
||||
if (!blue)
|
||||
std::swap(D[0], D[2]);
|
||||
}
|
||||
}
|
||||
|
||||
D = dst.ptr<uchar>(y + 1) - dcn;
|
||||
for (int i = 0; i < dcn; ++i)
|
||||
{
|
||||
D[i] = D[-dcn + i];
|
||||
D[-static_cast<int>(dst.step)+dcn+i] = D[-static_cast<int>(dst.step)+(dcn<<1)+i];
|
||||
}
|
||||
|
||||
start_with_green ^= 1;
|
||||
blue ^= 1;
|
||||
}
|
||||
|
||||
++size.width;
|
||||
uchar* firstRow = dst.data, *lastRow = dst.data + size.height * dst.step;
|
||||
size.width *= dcn;
|
||||
for (int x = 0; x < size.width; ++x)
|
||||
{
|
||||
firstRow[x] = firstRow[dst.step + x];
|
||||
lastRow[x] = lastRow[-static_cast<int>(dst.step)+x];
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void checkData(const Mat& actual, const Mat& reference, cvtest::TS* ts, const char* type,
|
||||
bool& next, const char* bayer_type)
|
||||
{
|
||||
EXPECT_EQ(actual.size(), reference.size());
|
||||
EXPECT_EQ(actual.channels(), reference.channels());
|
||||
EXPECT_EQ(actual.depth(), reference.depth());
|
||||
|
||||
Size size = reference.size();
|
||||
int dcn = reference.channels();
|
||||
size.width *= dcn;
|
||||
|
||||
for (int y = 0; y < size.height && next; ++y)
|
||||
{
|
||||
const T* A = reinterpret_cast<const T*>(actual.data + actual.step * y);
|
||||
const T* R = reinterpret_cast<const T*>(reference.data + reference.step * y);
|
||||
|
||||
for (int x = 0; x < size.width && next; ++x)
|
||||
if (std::abs(A[x] - R[x]) > 1)
|
||||
{
|
||||
#define SUM cvtest::TS::SUMMARY
|
||||
ts->printf(SUM, "\nReference value: %d\n", static_cast<int>(R[x]));
|
||||
ts->printf(SUM, "Actual value: %d\n", static_cast<int>(A[x]));
|
||||
ts->printf(SUM, "(y, x): (%d, %d)\n", y, x / reference.channels());
|
||||
ts->printf(SUM, "Channel pos: %d\n", x % reference.channels());
|
||||
ts->printf(SUM, "Pattern: %s\n", type);
|
||||
ts->printf(SUM, "Bayer image type: %s", bayer_type);
|
||||
#undef SUM
|
||||
|
||||
Mat diff;
|
||||
absdiff(actual, reference, diff);
|
||||
EXPECT_EQ(countNonZero(diff.reshape(1) > 1), 0);
|
||||
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
|
||||
ts->set_gtest_status();
|
||||
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ImgProc_BayerEdgeAwareDemosaicing, accuracy)
|
||||
{
|
||||
cvtest::TS* ts = cvtest::TS::ptr();
|
||||
const std::string image_name = "lena.png";
|
||||
const std::string parent_path = string(ts->get_data_path()) + "/cvtcolor_strict/";
|
||||
|
||||
Mat src, bayer;
|
||||
std::string full_path = parent_path + image_name;
|
||||
src = imread(full_path, CV_LOAD_IMAGE_UNCHANGED);
|
||||
|
||||
if (src.data == NULL)
|
||||
{
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
|
||||
ts->printf(cvtest::TS::SUMMARY, "No input image\n");
|
||||
ts->set_gtest_status();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
COLOR_BayerBG2BGR_EA = 127,
|
||||
COLOR_BayerGB2BGR_EA = 128,
|
||||
COLOR_BayerRG2BGR_EA = 129,
|
||||
COLOR_BayerGR2BGR_EA = 130,
|
||||
*/
|
||||
|
||||
bool next = true;
|
||||
const char* types[] = { "bg", "gb", "rg", "gr" };
|
||||
for (int i = 0; i < 4 && next; ++i)
|
||||
{
|
||||
calculateBayerPattern<uchar, CV_8U>(src, bayer, types[i]);
|
||||
Mat reference;
|
||||
test_Bayer2RGB_EdgeAware_8u(bayer, reference, CV_BayerBG2BGR_EA + i);
|
||||
|
||||
for (int t = 0; t <= 1; ++t)
|
||||
{
|
||||
if (t == 1)
|
||||
calculateBayerPattern<unsigned short int, CV_16U>(src, bayer, types[i]);
|
||||
|
||||
CV_Assert(!bayer.empty() && (bayer.type() == CV_8UC1 || bayer.type() == CV_16UC1));
|
||||
|
||||
Mat actual;
|
||||
cv::demosaicing(bayer, actual, CV_BayerBG2BGR_EA + i);
|
||||
|
||||
if (t == 0)
|
||||
checkData<unsigned char>(actual, reference, ts, types[i], next, "CV_8U");
|
||||
else
|
||||
{
|
||||
Mat tmp;
|
||||
reference.convertTo(tmp, CV_16U);
|
||||
checkData<unsigned short int>(actual, tmp, ts, types[i], next, "CV_16U");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ImgProc_Bayer2RGBA, accuracy)
|
||||
{
|
||||
cvtest::TS* ts = cvtest::TS::ptr();
|
||||
Mat raw = imread(string(ts->get_data_path()) + "/cvtcolor/bayer_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat rgb, reference;
|
||||
|
||||
CV_Assert(raw.channels() == 1);
|
||||
CV_Assert(raw.depth() == CV_8U);
|
||||
CV_Assert(!raw.empty());
|
||||
|
||||
for (int code = CV_BayerBG2BGR; code <= CV_BayerGR2BGR; ++code)
|
||||
{
|
||||
cvtColor(raw, rgb, code);
|
||||
cvtColor(rgb, reference, CV_BGR2BGRA);
|
||||
|
||||
Mat actual;
|
||||
cvtColor(raw, actual, code, 4);
|
||||
|
||||
EXPECT_EQ(reference.size(), actual.size());
|
||||
EXPECT_EQ(reference.depth(), actual.depth());
|
||||
EXPECT_EQ(reference.channels(), actual.channels());
|
||||
|
||||
Size ssize = raw.size();
|
||||
int cn = reference.channels();
|
||||
ssize.width *= cn;
|
||||
bool next = true;
|
||||
for (int y = 0; y < ssize.height && next; ++y)
|
||||
{
|
||||
const uchar* rD = reference.ptr<uchar>(y);
|
||||
const uchar* D = actual.ptr<uchar>(y);
|
||||
for (int x = 0; x < ssize.width && next; ++x)
|
||||
if (abs(rD[x] - D[x]) >= 1)
|
||||
{
|
||||
next = false;
|
||||
ts->printf(cvtest::TS::SUMMARY, "Error in: (%d, %d)\n", x / cn, y);
|
||||
ts->printf(cvtest::TS::SUMMARY, "Reference value: %d\n", rD[x]);
|
||||
ts->printf(cvtest::TS::SUMMARY, "Actual value: %d\n", D[x]);
|
||||
ts->printf(cvtest::TS::SUMMARY, "Src value: %d\n", raw.ptr<uchar>(y)[x]);
|
||||
ts->printf(cvtest::TS::SUMMARY, "Size: (%d, %d)\n", reference.rows, reference.cols);
|
||||
|
||||
Mat diff;
|
||||
absdiff(actual, reference, diff);
|
||||
EXPECT_EQ(countNonZero(diff.reshape(1) > 1), 0);
|
||||
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
|
||||
ts->set_gtest_status();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -66,13 +66,13 @@ parse_patterns = (
|
||||
{'name': "opencv_cxx_flags_debug", 'default': "", 'pattern': re.compile("^OPENCV_EXTRA_C_FLAGS_DEBUG:INTERNAL=(.*)$")},
|
||||
{'name': "opencv_cxx_flags_release", 'default': "", 'pattern': re.compile("^OPENCV_EXTRA_C_FLAGS_RELEASE:INTERNAL=(.*)$")},
|
||||
{'name': "cxx_flags_android", 'default': None, 'pattern': re.compile("^ANDROID_CXX_FLAGS:INTERNAL=(.*)$")},
|
||||
{'name': "cxx_compiler_path", 'default': None, 'pattern': re.compile("^CMAKE_CXX_COMPILER:FILEPATH=(.*)$")},
|
||||
{'name': "ndk_path", 'default': None, 'pattern': re.compile("^(?:ANDROID_NDK|ANDROID_STANDALONE_TOOLCHAIN)?:PATH=(.*)$")},
|
||||
{'name': "android_abi", 'default': None, 'pattern': re.compile("^ANDROID_ABI:STRING=(.*)$")},
|
||||
{'name': "android_executable", 'default': None, 'pattern': re.compile("^ANDROID_EXECUTABLE:FILEPATH=(.*android.*)$")},
|
||||
{'name': "is_x64", 'default': "OFF", 'pattern': re.compile("^CUDA_64_BIT_DEVICE_CODE:BOOL=(ON)$")},#ugly(
|
||||
{'name': "cmake_generator", 'default': None, 'pattern': re.compile("^CMAKE_GENERATOR:INTERNAL=(.+)$")},
|
||||
{'name': "cxx_compiler", 'default': None, 'pattern': re.compile("^CMAKE_CXX_COMPILER:FILEPATH=(.+)$")},
|
||||
{'name': "cxx_compiler_arg1", 'default': None, 'pattern': re.compile("^CMAKE_CXX_COMPILER_ARG1:[A-Z]+=(.+)$")},
|
||||
{'name': "with_cuda", 'default': "OFF", 'pattern': re.compile("^WITH_CUDA:BOOL=(ON)$")},
|
||||
{'name': "cuda_library", 'default': None, 'pattern': re.compile("^CUDA_CUDA_LIBRARY:FILEPATH=(.+)$")},
|
||||
{'name': "core_dependencies", 'default': None, 'pattern': re.compile("^opencv_core_LIB_DEPENDS:STATIC=(.+)$")},
|
||||
@ -199,40 +199,51 @@ def getRunningProcessExePathByName(name):
|
||||
except:
|
||||
return None
|
||||
|
||||
class RunInfo(object):
|
||||
def setCallback(self, name, callback):
|
||||
setattr(self, name, callback)
|
||||
|
||||
def __init__(self, path, options):
|
||||
class TestSuite(object):
|
||||
def __init__(self, options, path = None):
|
||||
self.options = options
|
||||
self.path = path
|
||||
self.error = None
|
||||
self.setUp = None
|
||||
self.tearDown = None
|
||||
self.nameprefix = "opencv_" + options.mode + "_"
|
||||
self.adb = None
|
||||
self.targetos = None
|
||||
self.nameprefix = "opencv_" + self.options.mode + "_"
|
||||
for p in parse_patterns:
|
||||
setattr(self, p["name"], p["default"])
|
||||
cachefile = open(os.path.join(path, "CMakeCache.txt"), "rt")
|
||||
try:
|
||||
for l in cachefile.readlines():
|
||||
ll = l.strip()
|
||||
if not ll or ll.startswith("#"):
|
||||
continue
|
||||
for p in parse_patterns:
|
||||
match = p["pattern"].match(ll)
|
||||
if match:
|
||||
value = match.groups()[0]
|
||||
if value and not value.endswith("-NOTFOUND"):
|
||||
setattr(self, p["name"], value)
|
||||
except:
|
||||
pass
|
||||
cachefile.close()
|
||||
|
||||
if self.path:
|
||||
cachefile = open(os.path.join(self.path, "CMakeCache.txt"), "rt")
|
||||
try:
|
||||
for l in cachefile.readlines():
|
||||
ll = l.strip()
|
||||
if not ll or ll.startswith("#"):
|
||||
continue
|
||||
for p in parse_patterns:
|
||||
match = p["pattern"].match(ll)
|
||||
if match:
|
||||
value = match.groups()[0]
|
||||
if value and not value.endswith("-NOTFOUND"):
|
||||
setattr(self, p["name"], value)
|
||||
except:
|
||||
pass
|
||||
cachefile.close()
|
||||
|
||||
# detect target platform
|
||||
if self.android_executable or self.android_abi or self.ndk_path:
|
||||
self.targetos = "android"
|
||||
else:
|
||||
self.targetos = hostos
|
||||
|
||||
self.initialize()
|
||||
|
||||
def initialize(self):
|
||||
# fix empty tests dir
|
||||
if not self.tests_dir:
|
||||
self.tests_dir = self.path
|
||||
self.tests_dir = os.path.normpath(self.tests_dir)
|
||||
# add path to adb
|
||||
|
||||
# compute path to adb
|
||||
if self.android_executable:
|
||||
self.adb = os.path.join(os.path.dirname(os.path.dirname(self.android_executable)), ("platform-tools/adb","platform-tools/adb.exe")[hostos == 'nt'])
|
||||
if not os.path.isfile(self.adb) or not os.access(self.adb, os.X_OK):
|
||||
@ -240,20 +251,14 @@ class RunInfo(object):
|
||||
else:
|
||||
self.adb = None
|
||||
|
||||
# detect target platform
|
||||
if self.android_executable or self.android_abi or self.ndk_path:
|
||||
self.targetos = "android"
|
||||
else:
|
||||
self.targetos = hostos
|
||||
|
||||
if self.targetos == "android":
|
||||
# fix adb tool location
|
||||
if not self.adb:
|
||||
self.adb = getRunningProcessExePathByName("adb")
|
||||
if not self.adb:
|
||||
self.adb = "adb"
|
||||
if options.adb_serial:
|
||||
self.adb = [self.adb, "-s", options.adb_serial]
|
||||
if self.options.adb_serial:
|
||||
self.adb = [self.adb, "-s", self.options.adb_serial]
|
||||
else:
|
||||
self.adb = [self.adb]
|
||||
try:
|
||||
@ -261,7 +266,7 @@ class RunInfo(object):
|
||||
except OSError:
|
||||
self.adb = []
|
||||
# remember current device serial. Needed if another device is connected while this script runs
|
||||
if self.adb and not options.adb_serial:
|
||||
if self.adb and not self.options.adb_serial:
|
||||
adb_res = self.runAdb("devices")
|
||||
if not adb_res:
|
||||
self.error = "Could not run adb command: %s (for %s)" % (self.error, self.path)
|
||||
@ -276,13 +281,10 @@ class RunInfo(object):
|
||||
self.error = "Too many (%s) devices are connected. Please specify single device using --serial option:\n\n" % (len(connected_devices)) + adb_res
|
||||
self.adb = []
|
||||
else:
|
||||
options.adb_serial = connected_devices[0].split("\t")[0]
|
||||
self.adb = self.adb + ["-s", options.adb_serial]
|
||||
self.options.adb_serial = connected_devices[0].split("\t")[0]
|
||||
self.adb = self.adb + ["-s", self.options.adb_serial]
|
||||
if self.adb:
|
||||
print "adb command:", " ".join(self.adb)
|
||||
|
||||
if self.adb:
|
||||
#construct name for aapt tool
|
||||
# construct name for aapt tool
|
||||
self.aapt = [os.path.join(os.path.dirname(self.adb[0]), ("aapt","aapt.exe")[hostos == 'nt'])]
|
||||
|
||||
# fix has_perf_tests param
|
||||
@ -295,14 +297,17 @@ class RunInfo(object):
|
||||
|
||||
# fix test path
|
||||
if "Visual Studio" in self.cmake_generator:
|
||||
if options.configuration:
|
||||
self.tests_dir = os.path.join(self.tests_dir, options.configuration)
|
||||
if self.options.configuration:
|
||||
self.tests_dir = os.path.join(self.tests_dir, self.options.configuration)
|
||||
else:
|
||||
self.tests_dir = os.path.join(self.tests_dir, self.build_type)
|
||||
elif not self.is_x64 and self.cxx_compiler:
|
||||
#one more attempt to detect x64 compiler
|
||||
try:
|
||||
output = Popen([self.cxx_compiler, "-v"], stdout=PIPE, stderr=PIPE).communicate()
|
||||
compiler = [self.cxx_compiler]
|
||||
if self.cxx_compiler_arg1:
|
||||
compiler.append(self.cxx_compiler_arg1)
|
||||
output = Popen(compiler + ["-v"], stdout=PIPE, stderr=PIPE).communicate()
|
||||
if not output[0] and "x86_64" in output[1]:
|
||||
self.is_x64 = True
|
||||
except OSError:
|
||||
@ -499,9 +504,11 @@ class RunInfo(object):
|
||||
fd = os.fdopen(tmpfile[0], "w+b")
|
||||
fd.write(SIMD_DETECTION_PROGRAM)
|
||||
fd.close();
|
||||
options = [self.cxx_compiler_path]
|
||||
options = [self.cxx_compiler]
|
||||
if self.cxx_compiler_arg1:
|
||||
options.append(self.cxx_compiler_arg1)
|
||||
cxx_flags = self.cxx_flags + " " + self.cxx_flags_release + " " + self.opencv_cxx_flags + " " + self.opencv_cxx_flags_release
|
||||
if self.targetos == "android":
|
||||
if self.targetos == "android" and self.cxx_flags_android:
|
||||
cxx_flags = self.cxx_flags_android + " " + cxx_flags
|
||||
|
||||
prev_option = None
|
||||
@ -634,21 +641,21 @@ class RunInfo(object):
|
||||
logfile = userlog[0][userlog[0].find(":")+1:]
|
||||
|
||||
if self.targetos == "android" and exe.endswith(".apk"):
|
||||
print "running java tests:", exe
|
||||
print "Run java tests:", exe
|
||||
try:
|
||||
# get package info
|
||||
output = Popen(self.aapt + ["dump", "xmltree", exe, "AndroidManifest.xml"], stdout=PIPE, stderr=_stderr).communicate()
|
||||
if not output[0]:
|
||||
print >> _stderr, "failed to get manifest info from", exe
|
||||
print >> _stderr, "fail to dump manifest from", exe
|
||||
return
|
||||
tags = re.split(r"[ ]+E: ", output[0])
|
||||
#get package name
|
||||
# get package name
|
||||
manifest_tag = [t for t in tags if t.startswith("manifest ")]
|
||||
if not manifest_tag:
|
||||
print >> _stderr, "failed to get manifest info from", exe
|
||||
print >> _stderr, "fail to read package name from", exe
|
||||
return
|
||||
pkg_name = re.search(r"^[ ]+A: package=\"(?P<pkg>.*?)\" \(Raw: \"(?P=pkg)\"\)\r?$", manifest_tag[0], flags=re.MULTILINE).group("pkg")
|
||||
#get test instrumentation info
|
||||
# get test instrumentation info
|
||||
instrumentation_tag = [t for t in tags if t.startswith("instrumentation ")]
|
||||
if not instrumentation_tag:
|
||||
print >> _stderr, "can not find instrumentation detials in", exe
|
||||
@ -663,7 +670,7 @@ class RunInfo(object):
|
||||
pkg_target += self.options.junit_package
|
||||
else:
|
||||
pkg_target = self.options.junit_package
|
||||
#uninstall already installed package
|
||||
# uninstall previously installed package
|
||||
print >> _stderr, "Uninstalling old", pkg_name, "from device..."
|
||||
Popen(self.adb + ["uninstall", pkg_name], stdout=PIPE, stderr=_stderr).communicate()
|
||||
print >> _stderr, "Installing new", exe, "to device...",
|
||||
@ -675,10 +682,10 @@ class RunInfo(object):
|
||||
print >> _stderr, "Failed to install", exe, "to device"
|
||||
return
|
||||
print >> _stderr, "Running jUnit tests for ", pkg_target
|
||||
if self.setUp is not None:
|
||||
if self.setUp:
|
||||
self.setUp()
|
||||
Popen(self.adb + ["shell", "am instrument -w -e package " + pkg_target + " " + pkg_name + "/" + pkg_runner], stdout=_stdout, stderr=_stderr).wait()
|
||||
if self.tearDown is not None:
|
||||
if self.tearDown:
|
||||
self.tearDown()
|
||||
except OSError:
|
||||
pass
|
||||
@ -693,27 +700,27 @@ class RunInfo(object):
|
||||
andoidcwd = tempdir + getpass.getuser().replace(" ","") + "_" + self.options.mode +"/"
|
||||
exename = os.path.basename(exe)
|
||||
androidexe = andoidcwd + exename
|
||||
#upload
|
||||
# upload
|
||||
_stderr.write("Uploading... ")
|
||||
output = Popen(self.adb + ["push", exe, androidexe], stdout=_stdout, stderr=_stderr).wait()
|
||||
if output != 0:
|
||||
print >> _stderr, "adb finishes unexpectedly with error code", output
|
||||
return
|
||||
#chmod
|
||||
# chmod
|
||||
output = Popen(self.adb + ["shell", "chmod 777 " + androidexe], stdout=_stdout, stderr=_stderr).wait()
|
||||
if output != 0:
|
||||
print >> _stderr, "adb finishes unexpectedly with error code", output
|
||||
return
|
||||
#run
|
||||
# run
|
||||
if self.options.help:
|
||||
command = exename + " --help"
|
||||
else:
|
||||
command = exename + " " + " ".join(args)
|
||||
print >> _stderr, "Run command:", command
|
||||
if self.setUp is not None:
|
||||
if self.setUp:
|
||||
self.setUp()
|
||||
Popen(self.adb + ["shell", "export OPENCV_TEST_DATA_PATH=" + self.test_data_path + "&& cd " + andoidcwd + "&& ./" + command], stdout=_stdout, stderr=_stderr).wait()
|
||||
if self.tearDown is not None:
|
||||
Popen(self.adb + ["shell", "export OPENCV_TEST_DATA_PATH=" + self.options.test_data_path + "&& cd " + andoidcwd + "&& ./" + command], stdout=_stdout, stderr=_stderr).wait()
|
||||
if self.tearDown:
|
||||
self.tearDown()
|
||||
# try get log
|
||||
if not self.options.help:
|
||||
@ -758,6 +765,7 @@ class RunInfo(object):
|
||||
|
||||
try:
|
||||
shutil.rmtree(temp_path)
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -767,8 +775,12 @@ class RunInfo(object):
|
||||
return None
|
||||
|
||||
def runTests(self, tests, _stdout, _stderr, workingDir, args = []):
|
||||
if not self.isRunnable():
|
||||
print >> _stderr, "Error:", self.error
|
||||
if self.error:
|
||||
return []
|
||||
if self.adb and self.targetos == "android":
|
||||
print "adb command:", " ".join(self.adb)
|
||||
if not tests:
|
||||
tests = self.tests
|
||||
logs = []
|
||||
@ -802,7 +814,6 @@ if __name__ == "__main__":
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-t", "--tests", dest="tests", help="comma-separated list of modules to test", metavar="SUITS", default="")
|
||||
|
||||
parser.add_option("-w", "--cwd", dest="cwd", help="working directory for tests", metavar="PATH", default=".")
|
||||
parser.add_option("-a", "--accuracy", dest="accuracy", help="look for accuracy tests instead of performance tests", action="store_true", default=False)
|
||||
parser.add_option("-l", "--longname", dest="useLongNames", action="store_true", help="generate log files with long names", default=False)
|
||||
@ -812,6 +823,7 @@ if __name__ == "__main__":
|
||||
parser.add_option("", "--package", dest="junit_package", help="Android: run jUnit tests for specified package", metavar="package", default="")
|
||||
parser.add_option("", "--help-tests", dest="help", help="Show help for test executable", action="store_true", default=False)
|
||||
parser.add_option("", "--check", dest="check", help="Shortcut for '--perf_min_samples=1 --perf_force_samples=1'", action="store_true", default=False)
|
||||
parser.add_option("", "--list", dest="list", help="List available tests", action="store_true", default=False)
|
||||
|
||||
(options, args) = parser.parse_args(argv)
|
||||
|
||||
@ -823,7 +835,7 @@ if __name__ == "__main__":
|
||||
run_args = getRunArgs(args[1:] or ['.'])
|
||||
|
||||
if len(run_args) == 0:
|
||||
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<build_path>"
|
||||
print >> sys.stderr, "Usage:", os.path.basename(sys.argv[0]), "[options] [build_path]"
|
||||
exit(1)
|
||||
|
||||
tests = [s.strip() for s in options.tests.split(",") if s]
|
||||
@ -833,17 +845,25 @@ if __name__ == "__main__":
|
||||
test_args = [a for a in test_args if not a.startswith("--gtest_output=")]
|
||||
|
||||
if options.check:
|
||||
test_args.extend(["--perf_min_samples=1", "--perf_force_samples=1"])
|
||||
if not [a for a in test_args if a.startswith("--perf_min_samples=")] :
|
||||
test_args.extend(["--perf_min_samples=1"])
|
||||
if not [a for a in test_args if a.startswith("--perf_force_samples=")] :
|
||||
test_args.extend(["--perf_force_samples=1"])
|
||||
if not [a for a in test_args if a.startswith("--perf_verify_sanity")] :
|
||||
test_args.extend(["--perf_verify_sanity"])
|
||||
|
||||
logs = []
|
||||
test_list = []
|
||||
for path in run_args:
|
||||
info = RunInfo(path, options)
|
||||
#print vars(info),"\n"
|
||||
if not info.isRunnable():
|
||||
print >> sys.stderr, "Error:", info.error
|
||||
suite = TestSuite(options, path)
|
||||
#print vars(suite),"\n"
|
||||
if options.list:
|
||||
test_list.extend(suite.tests)
|
||||
else:
|
||||
info.test_data_path = options.test_data_path
|
||||
logs.extend(info.runTests(tests, sys.stdout, sys.stderr, options.cwd, test_args))
|
||||
logs.extend(suite.runTests(tests, sys.stdout, sys.stderr, options.cwd, test_args))
|
||||
|
||||
if options.list:
|
||||
print os.linesep.join(test_list) or "No tests found"
|
||||
|
||||
if logs:
|
||||
print >> sys.stderr, "Collected: ", " ".join(logs)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user