Skip to content

Commit f6c2bf2

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 8cc2cbf + f53ff0d commit f6c2bf2

File tree

12 files changed

+331
-68
lines changed

12 files changed

+331
-68
lines changed

doc/opencv-logo.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
OpenCV logo has been originally designed and contributed to OpenCV by Adi Shavit in 2006. The graphical part consists of three stylized letters O, C, V, colored in the primary R, G, B color components, used by humans and computers to perceive the world. It is shaped in a way to mimic the famous [Kanizsa's triangle](https://en.wikipedia.org/wiki/Illusory_contours) to emphasize that the prior knowledge and internal processing are at least as important as the actually acquired "raw" data.
2+
3+
The restyled version of the logo has been designed and contributed by [xperience.ai](https://xperience.ai/) in July 2020 for the [20th anniversary](https://opencv.org/anniversary/) of OpenCV.
4+
5+
The logo uses [Exo 2](https://fonts.google.com/specimen/Exo+2#about) font by Natanael Gama distributed under OFL license.
6+
7+
Higher-resolution version of the logo, as well as SVG version of it, can be obtained at OpenCV [Media Kit](https://opencv.org/resources/media-kit/).
8+
9+
![](./opencv-logo2.png)

doc/opencv.bib

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,3 +1238,10 @@ @Article{Wu2009
12381238
number={2},
12391239
pages={117-135},
12401240
}
1241+
@inproceedings{forstner1987fast,
1242+
title={A fast operator for detection and precise location of distincs points, corners and center of circular features},
1243+
author={FORSTNER, W},
1244+
booktitle={Proc. of the Intercommission Conference on Fast Processing of Photogrammetric Data, Interlaken, Switzerland, 1987},
1245+
pages={281--305},
1246+
year={1987}
1247+
}

modules/core/src/trace.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ static bool getParameterTraceEnable()
8282
static int param_maxRegionDepthOpenCV = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_DEPTH_OPENCV", 1);
8383
static int param_maxRegionChildrenOpenCV = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_MAX_CHILDREN_OPENCV", 1000);
8484
static int param_maxRegionChildren = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_MAX_CHILDREN", 10000);
85-
static cv::String param_traceLocation = utils::getConfigurationParameterString("OPENCV_TRACE_LOCATION", "OpenCVTrace");
85+
86+
static const cv::String& getParameterTraceLocation()
87+
{
88+
static cv::String param_traceLocation = utils::getConfigurationParameterString("OPENCV_TRACE_LOCATION", "OpenCVTrace");
89+
return param_traceLocation;
90+
}
8691

8792
#ifdef HAVE_OPENCL
8893
static bool param_synchronizeOpenCL = utils::getConfigurationParameterBool("OPENCV_TRACE_SYNC_OPENCL", false);
@@ -813,7 +818,7 @@ TraceStorage* TraceManagerThreadLocal::getStorage() const
813818
TraceStorage* global = getTraceManager().trace_storage.get();
814819
if (global)
815820
{
816-
const std::string filepath = cv::format("%s-%03d.txt", param_traceLocation.c_str(), threadID).c_str();
821+
const std::string filepath = cv::format("%s-%03d.txt", getParameterTraceLocation().c_str(), threadID).c_str();
817822
TraceMessage msg;
818823
const char* pos = strrchr(filepath.c_str(), '/'); // extract filename
819824
#ifdef _WIN32
@@ -848,7 +853,7 @@ TraceManager::TraceManager()
848853
activated = getParameterTraceEnable();
849854

850855
if (activated)
851-
trace_storage.reset(new SyncTraceStorage(std::string(param_traceLocation) + ".txt"));
856+
trace_storage.reset(new SyncTraceStorage(std::string(getParameterTraceLocation()) + ".txt"));
852857

853858
#ifdef OPENCV_WITH_ITT
854859
if (isITTEnabled())

modules/core/src/umatrix.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ UMatData::~UMatData()
8080
CV_Assert(mapcount == 0);
8181
data = origdata = 0;
8282
size = 0;
83+
bool isAsyncCleanup = !!(flags & UMatData::ASYNC_CLEANUP);
8384
flags = static_cast<UMatData::MemoryFlag>(0);
8485
handle = 0;
8586
userdata = 0;
@@ -106,7 +107,7 @@ UMatData::~UMatData()
106107
showWarn = true;
107108
if (zero_Ref && zero_URef) // oops, we need to free resources
108109
{
109-
showWarn = true;
110+
showWarn = !isAsyncCleanup;
110111
// simulate UMat::deallocate
111112
u->currAllocator->deallocate(u);
112113
}

modules/core/test/test_umat.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,30 @@ TEST(UMat, map_unmap_counting)
11541154
}
11551155

11561156

1157+
static void process_with_async_cleanup(Mat& frame)
1158+
{
1159+
UMat blurResult;
1160+
{
1161+
UMat umat_buffer = frame.getUMat(ACCESS_READ);
1162+
cv::blur(umat_buffer, blurResult, Size(3, 3)); // UMat doesn't support inplace, this call is not synchronized
1163+
}
1164+
Mat result;
1165+
blurResult.copyTo(result);
1166+
swap(result, frame);
1167+
// umat_buffer cleanup is done asynchronously, silence warning about original 'frame' cleanup here (through 'result')
1168+
// - release input 'frame' (as 'result')
1169+
// - release 'umat_buffer' asynchronously and silence warning about "parent" buffer (in debug builds)
1170+
}
1171+
TEST(UMat, async_cleanup_without_call_chain_warning)
1172+
{
1173+
Mat frame(Size(640, 480), CV_8UC1, Scalar::all(128));
1174+
for (int i = 0; i < 10; i++)
1175+
{
1176+
process_with_async_cleanup(frame);
1177+
}
1178+
}
1179+
1180+
11571181
///////////// oclCleanupCallback threadsafe check (#5062) /////////////////////
11581182

11591183
// Case 1: reuse of old src Mat in OCL pipe. Hard to catch!

modules/features2d/src/brisk.cpp

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,30 @@ BRISK_Impl::generateKernel(const std::vector<float> &radiusList,
373373
const int rings = (int)radiusList.size();
374374
CV_Assert(radiusList.size() != 0 && radiusList.size() == numberList.size());
375375
points_ = 0; // remember the total number of points
376+
double sineThetaLookupTable[n_rot_];
377+
double cosThetaLookupTable[n_rot_];
376378
for (int ring = 0; ring < rings; ring++)
377379
{
378380
points_ += numberList[ring];
379381
}
382+
383+
// using a sine/cosine approximation for the lookup table
384+
// utilizes the trig identities:
385+
// sin(a + b) = sin(a)cos(b) + cos(a)sin(b)
386+
// cos(a + b) = cos(a)cos(b) - sin(a)sin(b)
387+
// and the fact that sin(0) = 0, cos(0) = 1
388+
double cosval = 1., sinval = 0.;
389+
double dcos = cos(2*CV_PI/double(n_rot_)), dsin = sin(2*CV_PI/double(n_rot_));
390+
for( size_t rot = 0; rot < n_rot_; ++rot)
391+
{
392+
sineThetaLookupTable[rot] = sinval;
393+
cosThetaLookupTable[rot] = cosval;
394+
double t = sinval*dcos + cosval*dsin;
395+
cosval = cosval*dcos - sinval*dsin;
396+
sinval = t;
397+
}
380398
// set up the patterns
381399
patternPoints_ = new BriskPatternPoint[points_ * scales_ * n_rot_];
382-
BriskPatternPoint* patternIterator = patternPoints_;
383400

384401
// define the scale discretization:
385402
static const float lb_scale = (float)(std::log(scalerange_) / std::log(2.0));
@@ -390,46 +407,51 @@ BRISK_Impl::generateKernel(const std::vector<float> &radiusList,
390407

391408
const float sigma_scale = 1.3f;
392409

393-
for (unsigned int scale = 0; scale < scales_; ++scale)
394-
{
395-
scaleList_[scale] = (float)std::pow((double) 2.0, (double) (scale * lb_scale_step));
396-
sizeList_[scale] = 0;
397-
398-
// generate the pattern points look-up
399-
double alpha, theta;
400-
for (size_t rot = 0; rot < n_rot_; ++rot)
401-
{
402-
theta = double(rot) * 2 * CV_PI / double(n_rot_); // this is the rotation of the feature
403-
for (int ring = 0; ring < rings; ++ring)
404-
{
405-
for (int num = 0; num < numberList[ring]; ++num)
406-
{
407-
// the actual coordinates on the circle
408-
alpha = (double(num)) * 2 * CV_PI / double(numberList[ring]);
409-
patternIterator->x = (float)(scaleList_[scale] * radiusList[ring] * cos(alpha + theta)); // feature rotation plus angle of the point
410-
patternIterator->y = (float)(scaleList_[scale] * radiusList[ring] * sin(alpha + theta));
411-
// and the gaussian kernel sigma
412-
if (ring == 0)
413-
{
414-
patternIterator->sigma = sigma_scale * scaleList_[scale] * 0.5f;
415-
}
416-
else
417-
{
418-
patternIterator->sigma = (float)(sigma_scale * scaleList_[scale] * (double(radiusList[ring]))
419-
* sin(CV_PI / numberList[ring]));
410+
for (unsigned int scale = 0; scale < scales_; ++scale) {
411+
scaleList_[scale] = (float) std::pow((double) 2.0, (double) (scale * lb_scale_step));
412+
sizeList_[scale] = 0;
413+
BriskPatternPoint *patternIteratorOuter = patternPoints_ + (scale * n_rot_ * points_);
414+
// generate the pattern points look-up
415+
for (int ring = 0; ring < rings; ++ring) {
416+
double scaleRadiusProduct = scaleList_[scale] * radiusList[ring];
417+
float patternSigma = 0.0f;
418+
if (ring == 0) {
419+
patternSigma = sigma_scale * scaleList_[scale] * 0.5f;
420+
} else {
421+
patternSigma = (float) (sigma_scale * scaleList_[scale] * (double(radiusList[ring]))
422+
* sin(CV_PI / numberList[ring]));
420423
}
421424
// adapt the sizeList if necessary
422-
const unsigned int size = cvCeil(((scaleList_[scale] * radiusList[ring]) + patternIterator->sigma)) + 1;
423-
if (sizeList_[scale] < size)
424-
{
425-
sizeList_[scale] = size;
425+
const unsigned int size = cvCeil(((scaleList_[scale] * radiusList[ring]) + patternSigma)) + 1;
426+
if (sizeList_[scale] < size) {
427+
sizeList_[scale] = size;
428+
}
429+
for (int num = 0; num < numberList[ring]; ++num) {
430+
BriskPatternPoint *patternIterator = patternIteratorOuter;
431+
double alpha = (double(num)) * 2 * CV_PI / double(numberList[ring]);
432+
double sine_alpha = sin(alpha);
433+
double cosine_alpha = cos(alpha);
434+
435+
for (size_t rot = 0; rot < n_rot_; ++rot) {
436+
double cosine_theta = cosThetaLookupTable[rot];
437+
double sine_theta = sineThetaLookupTable[rot];
438+
439+
// the actual coordinates on the circle
440+
// sin(a + b) = sin(a) cos(b) + cos(a) sin(b)
441+
// cos(a + b) = cos(a) cos(b) - sin(a) sin(b)
442+
patternIterator->x = (float) (scaleRadiusProduct *
443+
(cosine_theta * cosine_alpha -
444+
sine_theta * sine_alpha)); // feature rotation plus angle of the point
445+
patternIterator->y = (float) (scaleRadiusProduct *
446+
(sine_theta * cosine_alpha + cosine_theta * sine_alpha));
447+
patternIterator->sigma = patternSigma;
448+
// and the gaussian kernel sigma
449+
// increment the iterator
450+
patternIterator += points_;
451+
}
452+
++patternIteratorOuter;
426453
}
427-
428-
// increment the iterator
429-
++patternIterator;
430-
}
431454
}
432-
}
433455
}
434456

435457
// now also generate pairings

modules/flann/include/opencv2/flann.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ using ::cvflann::MaxDistance;
9595
using ::cvflann::HammingLUT;
9696
using ::cvflann::Hamming;
9797
using ::cvflann::Hamming2;
98+
using ::cvflann::DNAmmingLUT;
99+
using ::cvflann::DNAmming2;
98100
using ::cvflann::HistIntersectionDistance;
99101
using ::cvflann::HellingerDistance;
100102
using ::cvflann::ChiSquareDistance;
@@ -131,6 +133,14 @@ performed using library calls, if available. Lookup table implementation is used
131133
cv::flann::Hamming2 - %Hamming distance functor. Population count is
132134
implemented in 12 arithmetic operations (one of which is multiplication).
133135
136+
cv::flann::DNAmmingLUT - %Adaptation of the Hamming distance functor to DNA comparison.
137+
As the four bases A, C, G, T of the DNA (or A, G, C, U for RNA) can be coded on 2 bits,
138+
it counts the bits pairs differences between two sequences using a lookup table implementation.
139+
140+
cv::flann::DNAmming2 - %Adaptation of the Hamming distance functor to DNA comparison.
141+
Bases differences count are vectorised thanks to arithmetic operations using standard
142+
registers (AVX2 and AVX-512 should come in a near future).
143+
134144
cv::flann::HistIntersectionDistance - The histogram
135145
intersection distance functor.
136146

modules/flann/include/opencv2/flann/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ enum flann_distance_t
128128
FLANN_DIST_KULLBACK_LEIBLER = 8,
129129
FLANN_DIST_KL = 8,
130130
FLANN_DIST_HAMMING = 9,
131+
FLANN_DIST_DNAMMING = 10,
131132

132133
// deprecated constants, should use the FLANN_DIST_* ones instead
133134
EUCLIDEAN = 1,

0 commit comments

Comments
 (0)