mirror of
https://github.com/opencv/opencv.git
synced 2025-07-25 22:57:53 +08:00
change flags and bugfix graph
This commit is contained in:
parent
a3e7c2d8e3
commit
0c4a8e2ca8
@ -355,7 +355,7 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
|
|||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION();
|
CV_INSTRUMENT_REGION();
|
||||||
|
|
||||||
if (method >= 32 && method <= 38)
|
if (method >= USAC_DEFAULT && method <= USAC_MAGSAC)
|
||||||
return usac::findHomography(_points1, _points2, method, ransacReprojThreshold,
|
return usac::findHomography(_points1, _points2, method, ransacReprojThreshold,
|
||||||
_mask, maxIters, confidence);
|
_mask, maxIters, confidence);
|
||||||
|
|
||||||
@ -831,7 +831,7 @@ cv::Mat cv::findFundamentalMat( InputArray _points1, InputArray _points2,
|
|||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION();
|
CV_INSTRUMENT_REGION();
|
||||||
|
|
||||||
if (method >= 32 && method <= 38)
|
if (method >= USAC_DEFAULT && method <= USAC_MAGSAC)
|
||||||
return usac::findFundamentalMat(_points1, _points2, method,
|
return usac::findFundamentalMat(_points1, _points2, method,
|
||||||
ransacReprojThreshold, confidence, maxIters, _mask);
|
ransacReprojThreshold, confidence, maxIters, _mask);
|
||||||
|
|
||||||
|
@ -930,7 +930,7 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers,
|
|||||||
const size_t refineIters)
|
const size_t refineIters)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (method >= 32 && method <= 38)
|
if (method >= USAC_DEFAULT && method <= USAC_MAGSAC)
|
||||||
return cv::usac::estimateAffine2D(_from, _to, _inliers, method,
|
return cv::usac::estimateAffine2D(_from, _to, _inliers, method,
|
||||||
ransacReprojThreshold, (int)maxIters, confidence, (int)refineIters);
|
ransacReprojThreshold, (int)maxIters, confidence, (int)refineIters);
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
|||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION();
|
CV_INSTRUMENT_REGION();
|
||||||
|
|
||||||
if (flags >= 32 && flags <= 38)
|
if (flags >= USAC_DEFAULT && flags <= USAC_MAGSAC)
|
||||||
return usac::solvePnPRansac(_opoints, _ipoints, _cameraMatrix, _distCoeffs,
|
return usac::solvePnPRansac(_opoints, _ipoints, _cameraMatrix, _distCoeffs,
|
||||||
_rvec, _tvec, useExtrinsicGuess, iterationsCount, reprojectionError,
|
_rvec, _tvec, useExtrinsicGuess, iterationsCount, reprojectionError,
|
||||||
confidence, _inliers, flags);
|
confidence, _inliers, flags);
|
||||||
|
@ -136,6 +136,7 @@ private:
|
|||||||
|
|
||||||
std::fill(used_edges.begin(), used_edges.end(), false);
|
std::fill(used_edges.begin(), used_edges.end(), false);
|
||||||
|
|
||||||
|
bool has_edges = false;
|
||||||
// Iterate through all points and set their edges
|
// Iterate through all points and set their edges
|
||||||
for (int point_idx = 0; point_idx < points_size; ++point_idx) {
|
for (int point_idx = 0; point_idx < points_size; ++point_idx) {
|
||||||
energy = energies[point_idx];
|
energy = energies[point_idx];
|
||||||
@ -154,9 +155,8 @@ private:
|
|||||||
b = spatial_coherence, c = spatial_coherence, d = 0;
|
b = spatial_coherence, c = spatial_coherence, d = 0;
|
||||||
graph.addTermWeights(point_idx, d, a);
|
graph.addTermWeights(point_idx, d, a);
|
||||||
b -= a;
|
b -= a;
|
||||||
if (b + c >= 0)
|
if (b + c < 0)
|
||||||
// Non-submodular expansion term detected; smooth costs must be a metric for expansion
|
continue; // invalid regularity
|
||||||
continue;
|
|
||||||
if (b < 0) {
|
if (b < 0) {
|
||||||
graph.addTermWeights(point_idx, 0, b);
|
graph.addTermWeights(point_idx, 0, b);
|
||||||
graph.addTermWeights(actual_neighbor_idx, 0, -b);
|
graph.addTermWeights(actual_neighbor_idx, 0, -b);
|
||||||
@ -167,9 +167,13 @@ private:
|
|||||||
graph.addEdges(point_idx, actual_neighbor_idx, b + c, 0);
|
graph.addEdges(point_idx, actual_neighbor_idx, b + c, 0);
|
||||||
} else
|
} else
|
||||||
graph.addEdges(point_idx, actual_neighbor_idx, b, c);
|
graph.addEdges(point_idx, actual_neighbor_idx, b, c);
|
||||||
|
has_edges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!has_edges)
|
||||||
|
return quality->getInliers(model, labeling_inliers);
|
||||||
|
|
||||||
graph.maxFlow();
|
graph.maxFlow();
|
||||||
|
|
||||||
int inlier_number = 0;
|
int inlier_number = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user