Commit 6b04351c authored by ASUS's avatar ASUS

Merge branch 'accuracy' of https://github.com/obilaniu/opencv into accuracy

Conflicts:
	modules/calib3d/src/rhorefc.cpp
parents 6dbf13d7 ff2509af
...@@ -903,7 +903,7 @@ struct FeatureValAndIdxPrecalc : ParallelLoopBody ...@@ -903,7 +903,7 @@ struct FeatureValAndIdxPrecalc : ParallelLoopBody
*(idst + fi*sample_count + si) = si; *(idst + fi*sample_count + si) = si;
} }
if ( is_buf_16u ) if ( is_buf_16u )
std::sort(idst + fi*sample_count, idst + (fi + 1)*sample_count, LessThanIdx<float, unsigned short>(valCache->ptr<float>(fi)) ); std::sort(udst + fi*sample_count, udst + (fi + 1)*sample_count, LessThanIdx<float, unsigned short>(valCache->ptr<float>(fi)) );
else else
std::sort(idst + fi*sample_count, idst + (fi + 1)*sample_count, LessThanIdx<float, int>(valCache->ptr<float>(fi)) ); std::sort(idst + fi*sample_count, idst + (fi + 1)*sample_count, LessThanIdx<float, int>(valCache->ptr<float>(fi)) );
} }
......
#!/bin/sh #!/bin/sh
# Text style
TEXT_RED="$(tput setaf 1)"
TEXT_GREEN="$(tput setaf 2)"
TEXT_CYAN="$(tput setaf 6)"
TEXT_RESET="$(tput sgr0)"
# Test binaries and data paths
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@ OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
# Run tests
SUMMARY_STATUS=0 SUMMARY_STATUS=0
FAILED_TESTS=""
PASSED_TESTS=""
for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*; for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*;
do do
report="`basename "$t"`-`date --rfc-3339=date`.xml" test_name=`basename "$t"`
"$t" --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:"$report" report="$test_name-`date --rfc-3339=date`.xml"
TEST_STATUS=$?
if [ $TEST_STATUS -ne 0 ]; then cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:\"$report\""
SUMMARY_STATUS=$TEST_STATUS
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
seg_reg="${seg_reg};s/\[==========\]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [==========]
seg_reg="${seg_reg};s/\[----------\]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [----------]
seg_reg="${seg_reg};s/\[ RUN \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ RUN ]
seg_reg="${seg_reg};s/\[ OK \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ OK ]
seg_reg="${seg_reg};s/\[ FAILED \]/${TEXT_RED}&${TEXT_RESET}/g" # red for [ FAILED ]
seg_reg="${seg_reg};s/\[ PASSED \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ PASSED ]
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
eval "$cmd" | sed -r "$seg_reg"
ret=${PIPESTATUS[0]}
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
if [ $ret -ne 0 ]; then
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_RED}FAILED${TEXT_RESET}"
SUMMARY_STATUS=1
FAILED_TESTS="$FAILED_TESTS $test_name"
else
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_GREEN}OK${TEXT_RESET}"
PASSED_TESTS="$PASSED_TESTS $test_name"
fi fi
echo ""
done done
for t in $OPENCV_PYTHON_TESTS;
do
test_name=`basename "$t"`
report="$test_name-`date --rfc-3339=date`.xml"
cmd="py.test --junitxml $report \"$OPENCV_TEST_PATH\"/$t"
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
eval "$cmd" | sed -r "$seg_reg"
ret=${PIPESTATUS[0]}
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
if [ $ret -ne 0 ]; then
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_RED}FAILED${TEXT_RESET}"
SUMMARY_STATUS=1
FAILED_TESTS="$FAILED_TESTS $test_name"
else
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_GREEN}OK${TEXT_RESET}"
PASSED_TESTS="$PASSED_TESTS $test_name"
fi
echo ""
done
# Remove temporary test files
rm -f /tmp/__opencv_temp.* rm -f /tmp/__opencv_temp.*
# Report final status
echo "${TEXT_CYAN}===============================================================${TEXT_RESET}"
echo "${TEXT_CYAN}PASSED TESTS : $PASSED_TESTS${TEXT_RESET}"
echo "${TEXT_CYAN}FAILED TESTS : $FAILED_TESTS${TEXT_RESET}"
if [ $SUMMARY_STATUS -eq 0 ]; then if [ $SUMMARY_STATUS -eq 0 ]; then
echo "All OpenCV tests finished successfully" echo "${TEXT_GREEN}STATUS : OK${TEXT_RESET}"
echo "${TEXT_GREEN}STATUS : All OpenCV tests finished successfully${TEXT_RESET}"
else else
echo "OpenCV tests finished with status $SUMMARY_STATUS" echo "${TEXT_RED}STATUS : FAIL${TEXT_RESET}"
echo "${TEXT_RED}STATUS : OpenCV tests finished with status $SUMMARY_STATUS${TEXT_RESET}"
fi fi
return $SUMMARY_STATUS exit $SUMMARY_STATUS
\ No newline at end of file
...@@ -303,8 +303,7 @@ static bool createAndRunRHORegistrator(double confidence, ...@@ -303,8 +303,7 @@ static bool createAndRunRHORegistrator(double confidence,
* initialized, used, then finalized. * initialized, used, then finalized.
*/ */
RHO_HEST_REFC p; RHO_HEST_REFC* p = rhoRefCInit();
rhoRefCInit(&p);
/** /**
* Optional. Ideally, the context would survive across calls to * Optional. Ideally, the context would survive across calls to
...@@ -312,7 +311,7 @@ static bool createAndRunRHORegistrator(double confidence, ...@@ -312,7 +311,7 @@ static bool createAndRunRHORegistrator(double confidence,
* to pay is marginally more computational work than strictly needed. * to pay is marginally more computational work than strictly needed.
*/ */
rhoRefCEnsureCapacity(&p, npoints, beta); rhoRefCEnsureCapacity(p, npoints, beta);
/** /**
* The critical call. All parameters are heavily documented in rhorefc.h. * The critical call. All parameters are heavily documented in rhorefc.h.
...@@ -325,7 +324,7 @@ static bool createAndRunRHORegistrator(double confidence, ...@@ -325,7 +324,7 @@ static bool createAndRunRHORegistrator(double confidence,
* this behaviour is too problematic. * this behaviour is too problematic.
*/ */
result = !!rhoRefC(&p, result = !!rhoRefC(p,
(const float*)src.data, (const float*)src.data,
(const float*)dst.data, (const float*)dst.data,
(char*) tempMask.data, (char*) tempMask.data,
...@@ -344,7 +343,7 @@ static bool createAndRunRHORegistrator(double confidence, ...@@ -344,7 +343,7 @@ static bool createAndRunRHORegistrator(double confidence,
* Cleanup. * Cleanup.
*/ */
rhoRefCFini(&p); rhoRefCFini(p);
/* Convert float homography to double precision. */ /* Convert float homography to double precision. */
tmpH.convertTo(_H, CV_64FC1); tmpH.convertTo(_H, CV_64FC1);
......
This diff is collapsed.
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
/* Defines */ /* Defines */
#ifdef __cplusplus
/* C++ does not have the restrict keyword. */ /* C++ does not have the restrict keyword. */
#ifdef restrict #ifdef restrict
...@@ -64,15 +63,6 @@ ...@@ -64,15 +63,6 @@
#endif #endif
#define restrict #define restrict
#else
/* C99 and over has the restrict keyword. */
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#define restrict
#endif
#endif
/* Flags */ /* Flags */
#ifndef RHO_FLAG_NONE #ifndef RHO_FLAG_NONE
...@@ -90,101 +80,17 @@ ...@@ -90,101 +80,17 @@
/* Namespace cv */
namespace cv{
/* Data structures */ /* Data structures */
/** /**
* Homography Estimation context. * Homography Estimation context.
*/ */
typedef struct{ struct RHO_HEST_REFC;
/** typedef struct RHO_HEST_REFC RHO_HEST_REFC;
* Virtual Arguments.
*
* Exactly the same as at function call, except:
* - minInl is enforced to be >= 4.
*/
struct{
const float* restrict src;
const float* restrict dst;
char* restrict inl;
unsigned N;
float maxD;
unsigned maxI;
unsigned rConvg;
double cfd;
unsigned minInl;
double beta;
unsigned flags;
const float* guessH;
float* finalH;
} arg;
/* PROSAC Control */
struct{
unsigned i; /* Iteration Number */
unsigned phNum; /* Phase Number */
unsigned phEndI; /* Phase End Iteration */
double phEndFpI; /* Phase floating-point End Iteration */
unsigned phMax; /* Termination phase number */
unsigned phNumInl; /* Number of inliers for termination phase */
unsigned numModels; /* Number of models tested */
unsigned* restrict smpl; /* Sample of match indexes */
} ctrl;
/* Current model being tested */
struct{
float* restrict pkdPts; /* Packed points */
float* restrict H; /* Homography */
char* restrict inl; /* Mask of inliers */
unsigned numInl; /* Number of inliers */
} curr;
/* Best model (so far) */
struct{
float* restrict H; /* Homography */
char* restrict inl; /* Mask of inliers */
unsigned numInl; /* Number of inliers */
} best;
/* Non-randomness criterion */
struct{
unsigned* restrict tbl; /* Non-Randomness: Table */
unsigned size; /* Non-Randomness: Size */
double beta; /* Non-Randomness: Beta */
} nr;
/* SPRT Evaluator */
struct{
double t_M; /* t_M */
double m_S; /* m_S */
double epsilon; /* Epsilon */
double delta; /* delta */
double A; /* SPRT Threshold */
unsigned Ntested; /* Number of points tested */
unsigned Ntestedtotal; /* Number of points tested in total */
int good; /* Good/bad flag */
double lambdaAccept; /* Accept multiplier */
double lambdaReject; /* Reject multiplier */
} eval;
/* Levenberg-Marquardt Refinement */
struct{
float* ws; /* Levenberg-Marqhard Workspace */
float (* restrict JtJ)[8]; /* JtJ matrix */
float (* restrict tmp1)[8]; /* Temporary 1 */
float* restrict Jte; /* Jte vector */
} lm;
} RHO_HEST_REFC;
/* Extern C */
#ifdef __cplusplus
namespace cv{
/* extern "C" { */
#endif
/* Functions */ /* Functions */
...@@ -193,11 +99,10 @@ namespace cv{ ...@@ -193,11 +99,10 @@ namespace cv{
* Initialize the estimator context, by allocating the aligned buffers * Initialize the estimator context, by allocating the aligned buffers
* internally needed. * internally needed.
* *
* @param [in/out] p The uninitialized estimator context to initialize. * @return A pointer to the context if successful; NULL if an error occured.
* @return 0 if successful; non-zero if an error occured.
*/ */
int rhoRefCInit(RHO_HEST_REFC* p); RHO_HEST_REFC* rhoRefCInit(void);
/** /**
...@@ -355,11 +260,8 @@ unsigned rhoRefC(RHO_HEST_REFC* restrict p, /* Homography estimation conte ...@@ -355,11 +260,8 @@ unsigned rhoRefC(RHO_HEST_REFC* restrict p, /* Homography estimation conte
/* Extern C */ /* End Namespace cv */
#ifdef __cplusplus
/* } *//* End extern "C" */
} }
#endif
......
...@@ -94,12 +94,12 @@ private: ...@@ -94,12 +94,12 @@ private:
void print_information_1(int j, int N, int method, const Mat& H); void print_information_1(int j, int N, int method, const Mat& H);
void print_information_2(int j, int N, int method, const Mat& H, const Mat& H_res, int k, double diff); void print_information_2(int j, int N, int method, const Mat& H, const Mat& H_res, int k, double diff);
void print_information_3(int j, int N, const Mat& mask); void print_information_3(int method, int j, int N, const Mat& mask);
void print_information_4(int method, int j, int N, int k, int l, double diff); void print_information_4(int method, int j, int N, int k, int l, double diff);
void print_information_5(int method, int j, int N, int l, double diff); void print_information_5(int method, int j, int N, int l, double diff);
void print_information_6(int j, int N, int k, double diff, bool value); void print_information_6(int method, int j, int N, int k, double diff, bool value);
void print_information_7(int j, int N, int k, double diff, bool original_value, bool found_value); void print_information_7(int method, int j, int N, int k, double diff, bool original_value, bool found_value);
void print_information_8(int j, int N, int k, int l, double diff); void print_information_8(int method, int j, int N, int k, int l, double diff);
}; };
CV_HomographyTest::CV_HomographyTest() : max_diff(1e-2f), max_2diff(2e-2f) CV_HomographyTest::CV_HomographyTest() : max_diff(1e-2f), max_2diff(2e-2f)
...@@ -166,13 +166,13 @@ void CV_HomographyTest::print_information_2(int j, int N, int _method, const Mat ...@@ -166,13 +166,13 @@ void CV_HomographyTest::print_information_2(int j, int N, int _method, const Mat
cout << "Maximum allowed difference: " << max_diff << endl; cout << endl; cout << "Maximum allowed difference: " << max_diff << endl; cout << endl;
} }
void CV_HomographyTest::print_information_3(int j, int N, const Mat& mask) void CV_HomographyTest::print_information_3(int _method, int j, int N, const Mat& mask)
{ {
cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl; cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl; cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << endl; cout << endl; cout << "Count of points: " << N << endl; cout << endl;
cout << "Method: RANSAC" << endl; cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Found mask:" << endl; cout << endl; cout << "Found mask:" << endl; cout << endl;
cout << mask << endl; cout << endl; cout << mask << endl; cout << endl;
cout << "Number of rows: " << mask.rows << " Number of cols: " << mask.cols << endl; cout << endl; cout << "Number of rows: " << mask.rows << " Number of cols: " << mask.cols << endl; cout << endl;
...@@ -205,10 +205,10 @@ void CV_HomographyTest::print_information_5(int _method, int j, int N, int l, do ...@@ -205,10 +205,10 @@ void CV_HomographyTest::print_information_5(int _method, int j, int N, int l, do
cout << "Maxumum allowed difference: " << max_diff << endl; cout << endl; cout << "Maxumum allowed difference: " << max_diff << endl; cout << endl;
} }
void CV_HomographyTest::print_information_6(int j, int N, int k, double diff, bool value) void CV_HomographyTest::print_information_6(int _method, int j, int N, int k, double diff, bool value)
{ {
cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl; cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl;
cout << "Method: RANSAC" << endl; cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl; cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << " " << endl; cout << "Count of points: " << N << " " << endl;
...@@ -218,10 +218,10 @@ void CV_HomographyTest::print_information_6(int j, int N, int k, double diff, bo ...@@ -218,10 +218,10 @@ void CV_HomographyTest::print_information_6(int j, int N, int k, double diff, bo
cout << "Value of found mask: "<< value << endl; cout << endl; cout << "Value of found mask: "<< value << endl; cout << endl;
} }
void CV_HomographyTest::print_information_7(int j, int N, int k, double diff, bool original_value, bool found_value) void CV_HomographyTest::print_information_7(int _method, int j, int N, int k, double diff, bool original_value, bool found_value)
{ {
cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl; cout << endl; cout << "Checking for inliers/outliers mask..." << endl; cout << endl;
cout << "Method: RANSAC" << endl; cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl; cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
cout << "Count of points: " << N << " " << endl; cout << "Count of points: " << N << " " << endl;
...@@ -231,10 +231,10 @@ void CV_HomographyTest::print_information_7(int j, int N, int k, double diff, bo ...@@ -231,10 +231,10 @@ void CV_HomographyTest::print_information_7(int j, int N, int k, double diff, bo
cout << "Value of original mask: "<< original_value << " Value of found mask: " << found_value << endl; cout << endl; cout << "Value of original mask: "<< original_value << " Value of found mask: " << found_value << endl; cout << endl;
} }
void CV_HomographyTest::print_information_8(int j, int N, int k, int l, double diff) void CV_HomographyTest::print_information_8(int _method, int j, int N, int k, int l, double diff)
{ {
cout << endl; cout << "Checking for reprojection error of inlier..." << endl; cout << endl; cout << endl; cout << "Checking for reprojection error of inlier..." << endl; cout << endl;
cout << "Method: RANSAC" << endl; cout << "Method: "; if (_method == RANSAC) cout << "RANSAC" << endl; else if (_method == cv::RHO) cout << "RHO" << endl; else cout << _method << endl;
cout << "Sigma of normal noise: " << sigma << endl; cout << "Sigma of normal noise: " << sigma << endl;
cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << "Type of srcPoints: "; if ((j>-1) && (j<2)) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>";
cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl; cout << " Type of dstPoints: "; if (j % 2 == 0) cout << "Mat of CV_32FC2"; else cout << "vector <Point2f>"; cout << endl;
...@@ -371,7 +371,7 @@ void CV_HomographyTest::run(int) ...@@ -371,7 +371,7 @@ void CV_HomographyTest::run(int)
if (code) if (code)
{ {
print_information_3(j, N, mask[j]); print_information_3(method, j, N, mask[j]);
switch (code) switch (code)
{ {
...@@ -490,7 +490,7 @@ void CV_HomographyTest::run(int) ...@@ -490,7 +490,7 @@ void CV_HomographyTest::run(int)
if (code) if (code)
{ {
print_information_3(j, N, mask_res[j]); print_information_3(method, j, N, mask_res[j]);
switch (code) switch (code)
{ {
...@@ -522,14 +522,14 @@ void CV_HomographyTest::run(int) ...@@ -522,14 +522,14 @@ void CV_HomographyTest::run(int)
if (mask_res[j].at<bool>(k, 0) != (diff <= reproj_threshold)) if (mask_res[j].at<bool>(k, 0) != (diff <= reproj_threshold))
{ {
print_information_6(j, N, k, diff, mask_res[j].at<bool>(k, 0)); print_information_6(method, j, N, k, diff, mask_res[j].at<bool>(k, 0));
CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_MASK, MESSAGE_RANSAC_MASK_4); CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_MASK, MESSAGE_RANSAC_MASK_4);
return; return;
} }
if (mask.at<bool>(k, 0) && !mask_res[j].at<bool>(k, 0)) if (mask.at<bool>(k, 0) && !mask_res[j].at<bool>(k, 0))
{ {
print_information_7(j, N, k, diff, mask.at<bool>(k, 0), mask_res[j].at<bool>(k, 0)); print_information_7(method, j, N, k, diff, mask.at<bool>(k, 0), mask_res[j].at<bool>(k, 0));
CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_MASK, MESSAGE_RANSAC_MASK_5); CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_MASK, MESSAGE_RANSAC_MASK_5);
return; return;
} }
...@@ -549,7 +549,7 @@ void CV_HomographyTest::run(int) ...@@ -549,7 +549,7 @@ void CV_HomographyTest::run(int)
if (diff - cv::norm(noise_2d, NORM_TYPE[l]) > max_2diff) if (diff - cv::norm(noise_2d, NORM_TYPE[l]) > max_2diff)
{ {
print_information_8(j, N, k, l, diff - cv::norm(noise_2d, NORM_TYPE[l])); print_information_8(method, j, N, k, l, diff - cv::norm(noise_2d, NORM_TYPE[l]));
CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_DIFF, MESSAGE_RANSAC_DIFF); CV_Error(CALIB3D_HOMOGRAPHY_ERROR_RANSAC_DIFF, MESSAGE_RANSAC_DIFF);
return; return;
} }
......
...@@ -1471,7 +1471,7 @@ bool haveOpenCL() ...@@ -1471,7 +1471,7 @@ bool haveOpenCL()
bool useOpenCL() bool useOpenCL()
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
if( data->useOpenCL < 0 ) if( data->useOpenCL < 0 )
{ {
try try
...@@ -1490,7 +1490,7 @@ void setUseOpenCL(bool flag) ...@@ -1490,7 +1490,7 @@ void setUseOpenCL(bool flag)
{ {
if( haveOpenCL() ) if( haveOpenCL() )
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
data->useOpenCL = (flag && Device::getDefault().ptr() != NULL) ? 1 : 0; data->useOpenCL = (flag && Device::getDefault().ptr() != NULL) ? 1 : 0;
} }
} }
...@@ -2161,7 +2161,7 @@ size_t Device::profilingTimerResolution() const ...@@ -2161,7 +2161,7 @@ size_t Device::profilingTimerResolution() const
const Device& Device::getDefault() const Device& Device::getDefault()
{ {
const Context& ctx = Context::getDefault(); const Context& ctx = Context::getDefault();
int idx = coreTlsData.get()->device; int idx = getCoreTlsData().get()->device;
const Device& device = ctx.device(idx); const Device& device = ctx.device(idx);
return device; return device;
} }
...@@ -3040,7 +3040,7 @@ void* Queue::ptr() const ...@@ -3040,7 +3040,7 @@ void* Queue::ptr() const
Queue& Queue::getDefault() Queue& Queue::getDefault()
{ {
Queue& q = coreTlsData.get()->oclQueue; Queue& q = getCoreTlsData().get()->oclQueue;
if( !q.p && haveOpenCL() ) if( !q.p && haveOpenCL() )
q.create(Context::getDefault()); q.create(Context::getDefault());
return q; return q;
......
...@@ -255,7 +255,7 @@ struct CoreTLSData ...@@ -255,7 +255,7 @@ struct CoreTLSData
#endif #endif
}; };
extern TLSData<CoreTLSData> coreTlsData; TLSData<CoreTLSData>& getCoreTlsData();
#if defined(BUILD_SHARED_LIBS) #if defined(BUILD_SHARED_LIBS)
#if defined WIN32 || defined _WIN32 || defined WINCE #if defined WIN32 || defined _WIN32 || defined WINCE
......
...@@ -731,7 +731,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, ...@@ -731,7 +731,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
cv::RNG& cv::theRNG() cv::RNG& cv::theRNG()
{ {
return coreTlsData.get()->rng; return getCoreTlsData().get()->rng;
} }
void cv::randu(InputOutputArray dst, InputArray low, InputArray high) void cv::randu(InputOutputArray dst, InputArray low, InputArray high)
......
...@@ -1146,12 +1146,20 @@ TLSStorage::~TLSStorage() ...@@ -1146,12 +1146,20 @@ TLSStorage::~TLSStorage()
tlsData_.clear(); tlsData_.clear();
} }
TLSData<CoreTLSData> coreTlsData;
TLSData<CoreTLSData>& getCoreTlsData()
{
static TLSData<CoreTLSData> *value = new TLSData<CoreTLSData>();
return *value;
}
#ifdef CV_COLLECT_IMPL_DATA #ifdef CV_COLLECT_IMPL_DATA
void setImpl(int flags) void setImpl(int flags)
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
data->implFlags = flags; data->implFlags = flags;
data->implCode.clear(); data->implCode.clear();
data->implFun.clear(); data->implFun.clear();
...@@ -1159,7 +1167,7 @@ void setImpl(int flags) ...@@ -1159,7 +1167,7 @@ void setImpl(int flags)
void addImpl(int flag, const char* func) void addImpl(int flag, const char* func)
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
data->implFlags |= flag; data->implFlags |= flag;
if(func) // use lazy collection if name was not specified if(func) // use lazy collection if name was not specified
{ {
...@@ -1174,7 +1182,7 @@ void addImpl(int flag, const char* func) ...@@ -1174,7 +1182,7 @@ void addImpl(int flag, const char* func)
int getImpl(std::vector<int> &impl, std::vector<String> &funName) int getImpl(std::vector<int> &impl, std::vector<String> &funName)
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
impl = data->implCode; impl = data->implCode;
funName = data->implFun; funName = data->implFun;
return data->implFlags; // return actual flags for lazy collection return data->implFlags; // return actual flags for lazy collection
...@@ -1182,13 +1190,13 @@ int getImpl(std::vector<int> &impl, std::vector<String> &funName) ...@@ -1182,13 +1190,13 @@ int getImpl(std::vector<int> &impl, std::vector<String> &funName)
bool useCollection() bool useCollection()
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
return data->useCollection; return data->useCollection;
} }
void setUseCollection(bool flag) void setUseCollection(bool flag)
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
data->useCollection = flag; data->useCollection = flag;
} }
#endif #endif
...@@ -1221,7 +1229,7 @@ String getIppErrorLocation() ...@@ -1221,7 +1229,7 @@ String getIppErrorLocation()
bool useIPP() bool useIPP()
{ {
#ifdef HAVE_IPP #ifdef HAVE_IPP
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
if(data->useIPP < 0) if(data->useIPP < 0)
{ {
const char* pIppEnv = getenv("OPENCV_IPP"); const char* pIppEnv = getenv("OPENCV_IPP");
...@@ -1238,7 +1246,7 @@ bool useIPP() ...@@ -1238,7 +1246,7 @@ bool useIPP()
void setUseIPP(bool flag) void setUseIPP(bool flag)
{ {
CoreTLSData* data = coreTlsData.get(); CoreTLSData* data = getCoreTlsData().get();
#ifdef HAVE_IPP #ifdef HAVE_IPP
data->useIPP = flag; data->useIPP = flag;
#else #else
......
...@@ -731,7 +731,7 @@ public: ...@@ -731,7 +731,7 @@ public:
for( i = 0; i < l_count; i++ ) for( i = 0; i < l_count; i++ )
{ {
int n = layer_sizes[i]; int n = layer_sizes[i];
x[i].resize(n); x[i].resize(n+1);
df[i].resize(n); df[i].resize(n);
dw[i].create(weights[i].size(), CV_64F); dw[i].create(weights[i].size(), CV_64F);
} }
......
...@@ -449,6 +449,12 @@ bool FeatureEvaluator::updateScaleData( Size imgsz, const std::vector<float>& _s ...@@ -449,6 +449,12 @@ bool FeatureEvaluator::updateScaleData( Size imgsz, const std::vector<float>& _s
s.ystep = sc >= 2 ? 1 : 2; s.ystep = sc >= 2 ? 1 : 2;
s.scale = sc; s.scale = sc;
s.szi = Size(sz.width+1, sz.height+1); s.szi = Size(sz.width+1, sz.height+1);
if( i == 0 )
{
layer_dy = s.szi.height;
}
if( layer_ofs.x + s.szi.width > sbufSize.width ) if( layer_ofs.x + s.szi.width > sbufSize.width )
{ {
layer_ofs = Point(0, layer_ofs.y + layer_dy); layer_ofs = Point(0, layer_ofs.y + layer_dy);
......
...@@ -301,8 +301,10 @@ void HOGDescriptor::computeGradient(const Mat& img, Mat& grad, Mat& qangle, ...@@ -301,8 +301,10 @@ void HOGDescriptor::computeGradient(const Mat& img, Mat& grad, Mat& qangle,
for( y = 0; y < gradsize.height; y++ ) for( y = 0; y < gradsize.height; y++ )
{ {
const uchar* imgPtr = img.ptr(ymap[y]); const uchar* imgPtr = img.ptr(ymap[y]);
const uchar* prevPtr = img.ptr(ymap[y-1]); //In case subimage is used ptr() generates an assert for next and prev rows
const uchar* nextPtr = img.ptr(ymap[y+1]); //(see http://code.opencv.org/issues/4149)
const uchar* prevPtr = img.data + img.step*ymap[y-1];
const uchar* nextPtr = img.data + img.step*ymap[y+1];
float* gradPtr = grad.ptr<float>(y); float* gradPtr = grad.ptr<float>(y);
uchar* qanglePtr = qangle.ptr(y); uchar* qanglePtr = qangle.ptr(y);
......
...@@ -398,5 +398,5 @@ int main() ...@@ -398,5 +398,5 @@ int main()
} }
} }
return 1; return 0;
} }
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