1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #12827 from hrnr:stitching_4

[evolution] Stitching for OpenCV 4.0

* stitching: wrap Stitcher::create for bindings

* provide method for consistent stitcher usage across languages

* samples: add python stitching sample

* port cpp stitching sample to python

* stitching: consolidate Stitcher create methods

* remove Stitcher::createDefault, it returns Stitcher, not Ptr<Stitcher> -> inconsistent API
* deprecate cv::createStitcher and cv::createStitcherScans in favor of Stitcher::create

* stitching: avoid anonymous enum in Stitcher

* ORIG_RESOL should be double
* add documentatiton

* stitching: improve documentation in Stitcher

* stitching: expose estimator in Stitcher

* remove ABI hack

* stitching: drop try_use_gpu flag

* OCL will be used automatically through T-API in OCL-enable paths
* CUDA won't be used unless user sets CUDA-enabled classes manually

* stitching: drop FeaturesFinder

* use Feature2D instead of FeaturesFinder
* interoperability with features2d module
* detach from dependency on xfeatures2d

* features2d: fix compute and detect to work with UMat vectors

* correctly pass UMats as UMats to allow OCL paths
* support vector of UMats as output arg

* stitching: use nearest interpolation for resizing masks

* fix warnings
This commit is contained in:
Jiri Horner
2018-11-10 17:53:48 +01:00
committed by Alexander Alekhin
parent be9b676db3
commit 1ba7c728a6
18 changed files with 329 additions and 810 deletions
+46 -26
View File
@@ -71,29 +71,38 @@ void Feature2D::detect( InputArray image,
}
void Feature2D::detect( InputArrayOfArrays _images,
void Feature2D::detect( InputArrayOfArrays images,
std::vector<std::vector<KeyPoint> >& keypoints,
InputArrayOfArrays _masks )
InputArrayOfArrays masks )
{
CV_INSTRUMENT_REGION();
vector<Mat> images, masks;
int nimages = (int)images.total();
_images.getMatVector(images);
size_t i, nimages = images.size();
if( !_masks.empty() )
if (!masks.empty())
{
_masks.getMatVector(masks);
CV_Assert(masks.size() == nimages);
CV_Assert(masks.total() == (size_t)nimages);
}
keypoints.resize(nimages);
for( i = 0; i < nimages; i++ )
if (images.isMatVector())
{
detect(images[i], keypoints[i], masks.empty() ? Mat() : masks[i] );
for (int i = 0; i < nimages; i++)
{
detect(images.getMat(i), keypoints[i], masks.empty() ? noArray() : masks.getMat(i));
}
}
else
{
// assume UMats
for (int i = 0; i < nimages; i++)
{
detect(images.getUMat(i), keypoints[i], masks.empty() ? noArray() : masks.getUMat(i));
}
}
}
/*
@@ -116,29 +125,40 @@ void Feature2D::compute( InputArray image,
detectAndCompute(image, noArray(), keypoints, descriptors, true);
}
void Feature2D::compute( InputArrayOfArrays _images,
void Feature2D::compute( InputArrayOfArrays images,
std::vector<std::vector<KeyPoint> >& keypoints,
OutputArrayOfArrays _descriptors )
OutputArrayOfArrays descriptors )
{
CV_INSTRUMENT_REGION();
if( !_descriptors.needed() )
if( !descriptors.needed() )
return;
vector<Mat> images;
int nimages = (int)images.total();
_images.getMatVector(images);
size_t i, nimages = images.size();
CV_Assert( keypoints.size() == nimages );
CV_Assert( _descriptors.kind() == _InputArray::STD_VECTOR_MAT );
vector<Mat>& descriptors = *(vector<Mat>*)_descriptors.getObj();
descriptors.resize(nimages);
for( i = 0; i < nimages; i++ )
CV_Assert( keypoints.size() == (size_t)nimages );
// resize descriptors to appropriate size and compute
if (descriptors.isMatVector())
{
compute(images[i], keypoints[i], descriptors[i]);
vector<Mat>& vec = *(vector<Mat>*)descriptors.getObj();
vec.resize(nimages);
for (int i = 0; i < nimages; i++)
{
compute(images.getMat(i), keypoints[i], vec[i]);
}
}
else if (descriptors.isUMatVector())
{
vector<UMat>& vec = *(vector<UMat>*)descriptors.getObj();
vec.resize(nimages);
for (int i = 0; i < nimages; i++)
{
compute(images.getUMat(i), keypoints[i], vec[i]);
}
}
else
{
CV_Error(Error::StsBadArg, "descriptors must be vector<Mat> or vector<UMat>");
}
}