Commit ce0570b7 authored by Olexa Bilaniuk's avatar Olexa Bilaniuk

Splitting vectorized code into separate branch.

Deleted SSE code from master branch.
Slight cleanups in fundam.cpp were made as a consequence.
parent 69b14641
...@@ -42,9 +42,6 @@ ...@@ -42,9 +42,6 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "rhorefc.h" #include "rhorefc.h"
#if CV_SSE2
#include "rhosse2.h"
#endif
#include <iostream> #include <iostream>
namespace cv namespace cv
...@@ -279,65 +276,83 @@ public: ...@@ -279,65 +276,83 @@ public:
namespace cv{ namespace cv{
static bool createAndRunRHORegistrator(double confidence, int maxIters, double ransacReprojThreshold, int npoints, InputArray _src, InputArray _dst, OutputArray _H, OutputArray _tempMask){ static bool createAndRunRHORegistrator(double confidence,
Mat src = _src.getMat(); int maxIters,
Mat dst = _dst.getMat(); double ransacReprojThreshold,
Mat tempMask = _tempMask.getMat(); int npoints,
bool result; InputArray _src,
InputArray _dst,
OutputArray _H,
OutputArray _tempMask){
Mat src = _src.getMat();
Mat dst = _dst.getMat();
Mat tempMask = _tempMask.getMat();
bool result;
double beta = 0.35;/* 0.35 is a value that often works. */
/* Run RHO. Needs cleanup or separate function to invoke. */ /* Create temporary output matrix (RHO outputs a single-precision H only). */
Mat tmpH = Mat(3, 3, CV_32FC1); Mat tmpH = Mat(3, 3, CV_32FC1);
/* Create output mask. */
if(!tempMask.data){ if(!tempMask.data){
tempMask = Mat(npoints, 1, CV_8U); tempMask = Mat(npoints, 1, CV_8U);
} }
double beta = 0.35;/* 0.35 is a value that often works. */
#if CV_SSE2 && 0
if(useOptimized()){ /**
RHO_HEST_SSE2 p; * Make use of the RHO estimator API.
rhoSSE2Init(&p); *
rhoSSE2EnsureCapacity(&p, npoints, beta); * This is where the math happens. A homography estimation context is
result = !!rhoSSE2(&p, * initialized, used, then finalized.
(const float*)src.data, */
(const float*)dst.data,
(char*) tempMask.data, RHO_HEST_REFC p;
npoints, rhoRefCInit(&p);
ransacReprojThreshold,
maxIters, /**
maxIters, * Optional. Ideally, the context would survive across calls to
confidence, * findHomography(), but no clean way appears to exit to do so. The price
4, * to pay is marginally more computational work than strictly needed.
beta, */
RHO_FLAG_ENABLE_NR,
NULL, rhoRefCEnsureCapacity(&p, npoints, beta);
(float*)tmpH.data);
rhoSSE2Fini(&p); /**
}else * The critical call. All parameters are heavily documented in rhorefc.h.
#endif *
{ * Currently, NR (Non-Randomness criterion) and Final Refinement (with
RHO_HEST_REFC p; * internal, optimized Levenberg-Marquardt method) are enabled. However,
rhoRefCInit(&p); * while refinement seems to correctly smooth jitter most of the time, when
rhoRefCEnsureCapacity(&p, npoints, beta); * refinement fails it tends to make the estimate visually very much worse.
result = !!rhoRefC(&p, * It may be necessary to remove the refinement flags in a future commit if
(const float*)src.data, * this behaviour is too problematic.
(const float*)dst.data, */
(char*) tempMask.data,
npoints, result = !!rhoRefC(&p,
ransacReprojThreshold, (const float*)src.data,
maxIters, (const float*)dst.data,
maxIters, (char*) tempMask.data,
confidence, npoints,
4, ransacReprojThreshold,
beta, maxIters,
/*RHO_FLAG_ENABLE_NR,*/ maxIters,
RHO_FLAG_ENABLE_NR | RHO_FLAG_ENABLE_FINAL_REFINEMENT, confidence,
NULL, 4,
(float*)tmpH.data); beta,
rhoRefCFini(&p); RHO_FLAG_ENABLE_NR | RHO_FLAG_ENABLE_FINAL_REFINEMENT,
} NULL,
(float*)tmpH.data);
/**
* Cleanup.
*/
rhoRefCFini(&p);
/* Convert float homography to double precision. */
tmpH.convertTo(_H, CV_64FC1); tmpH.convertTo(_H, CV_64FC1);
/* Maps non-zero maks elems to 1, for the sake of the testcase. */ /* Maps non-zero mask elems to 1, for the sake of the testcase. */
for(int k=0;k<npoints;k++){ for(int k=0;k<npoints;k++){
tempMask.data[k] = !!tempMask.data[k]; tempMask.data[k] = !!tempMask.data[k];
} }
......
This diff is collapsed.
This diff is collapsed.
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