Skip to content

Commit 583bd1a

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 9da9e82 + 53eda42 commit 583bd1a

File tree

17 files changed

+340
-94
lines changed

17 files changed

+340
-94
lines changed

doc/js_tutorials/js_setup/js_usage/js_usage.markdown

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,14 @@ imgElement.onload = function() {
122122
mat.delete();
123123
};
124124

125-
function onOpenCvReady() {
126-
document.getElementById('status').innerHTML = 'OpenCV.js is ready.';
127-
}
125+
var Module = {
126+
// https://emscripten.org/docs/api_reference/module.html#Module.onRuntimeInitialized
127+
onRuntimeInitialized() {
128+
document.getElementById('status').innerHTML = 'OpenCV.js is ready.';
129+
}
130+
};
128131
</script>
129-
<script async src="opencv.js" onload="onOpenCvReady();" type="text/javascript"></script>
132+
<script async src="opencv.js" type="text/javascript"></script>
130133
</body>
131134
</html>
132135
@endcode

doc/opencv.bib

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,13 @@ @article{umeyama1991least
13481348
year={1991},
13491349
publisher={IEEE Computer Society}
13501350
}
1351+
@article{Kannala2006,
1352+
author = {Kannala, Juho and Brandt, Sami},
1353+
year = {2006},
1354+
month = {09},
1355+
pages = {1335-40},
1356+
title = {A Generic Camera Model and Calibration Method for Conventional, Wide-Angle, and Fish-Eye Lenses},
1357+
volume = {28},
1358+
journal = {IEEE transactions on pattern analysis and machine intelligence},
1359+
doi = {10.1109/TPAMI.2006.153}
1360+
}

modules/calib3d/include/opencv2/calib3d.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ R & t \\
430430
\f[u = f_x (x' + \alpha y') + c_x \\
431431
v = f_y y' + c_y\f]
432432
433+
Summary:
434+
Generic camera model @cite Kannala2006 with perspective projection and without distortion correction
435+
433436
@defgroup calib3d_c C API
434437
435438
@}
@@ -3883,7 +3886,7 @@ namespace fisheye
38833886
CV_EXPORTS_W void estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R,
38843887
OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0);
38853888

3886-
/** @brief Performs camera calibaration
3889+
/** @brief Performs camera calibration
38873890
38883891
@param objectPoints vector of vectors of calibration pattern points in the calibration pattern
38893892
coordinate space.

modules/core/src/precomp.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ extern CV_EXPORTS
365365
bool __termination; // skip some cleanups, because process is terminating
366366
// (for example, if ExitProcess() was already called)
367367

368+
CV_EXPORTS
368369
cv::Mutex& getInitializationMutex();
369370

370371
/// @brief Returns timestamp in nanoseconds since program launch

modules/dnn/src/darknet/darknet_importer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Net readNetFromDarknet(const String &cfgFile, const String &darknetModel /*= Str
207207
std::ifstream cfgStream(cfgFile.c_str());
208208
if (!cfgStream.is_open())
209209
{
210-
CV_Error(cv::Error::StsParseError, "Failed to parse NetParameter file: " + std::string(cfgFile));
210+
CV_Error(cv::Error::StsParseError, "Failed to open NetParameter file: " + std::string(cfgFile));
211211
}
212212
if (darknetModel != String())
213213
{

modules/dnn/src/tensorflow/tf_graph_simplifier.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ void sortByExecutionOrder(tensorflow::GraphDef& net)
990990
nodesMap.insert(std::make_pair(node.name(), i));
991991
}
992992

993+
CV_CheckEQ(nodesMap.size(), (size_t)net.node_size(), "Node names must be unique");
993994
// Indices of nodes which use specific node as input.
994995
std::vector<std::vector<int> > edges(nodesMap.size());
995996
std::vector<int> numRefsToAdd(nodesMap.size(), 0);
@@ -1007,7 +1008,7 @@ void sortByExecutionOrder(tensorflow::GraphDef& net)
10071008
nodesMapIt = nodesMap.find(inpName);
10081009
if (nodesMapIt != nodesMap.end())
10091010
{
1010-
edges[nodesMapIt->second].push_back(i);
1011+
edges.at(nodesMapIt->second).push_back(i);
10111012
numInputsInGraph += 1;
10121013
}
10131014
}
@@ -1019,11 +1020,11 @@ void sortByExecutionOrder(tensorflow::GraphDef& net)
10191020
{
10201021
int numControlEdges = 0;
10211022
for (int j = 0; j < numInputsInGraph; ++j)
1022-
numControlEdges += node.input(j)[0] == '^';
1023-
numRefsToAdd[i] = numControlEdges + 1;
1023+
numControlEdges += node.input(j).at(0) == '^';
1024+
numRefsToAdd.at(i) = numControlEdges + 1;
10241025
}
10251026
else
1026-
numRefsToAdd[i] = numInputsInGraph;
1027+
numRefsToAdd.at(i) = numInputsInGraph;
10271028
}
10281029
}
10291030

@@ -1035,17 +1036,16 @@ void sortByExecutionOrder(tensorflow::GraphDef& net)
10351036
nodesToAdd.pop_back();
10361037

10371038
permIds.push_back(nodeToAdd);
1038-
CV_Assert(nodeToAdd < edges.size());
1039-
for (int i = 0; i < edges[nodeToAdd].size(); ++i)
1039+
for (int i = 0; i < edges.at(nodeToAdd).size(); ++i)
10401040
{
1041-
int consumerId = edges[nodeToAdd][i];
1042-
if (numRefsToAdd[consumerId] > 0)
1041+
int consumerId = edges.at(nodeToAdd).at(i);
1042+
if (numRefsToAdd.at(consumerId) > 0)
10431043
{
1044-
if (numRefsToAdd[consumerId] == 1)
1044+
if (numRefsToAdd.at(consumerId) == 1)
10451045
nodesToAdd.push_back(consumerId);
10461046
else
1047-
CV_Assert(numRefsToAdd[consumerId] >= 0);
1048-
numRefsToAdd[consumerId] -= 1;
1047+
CV_Assert(numRefsToAdd.at(consumerId) >= 0);
1048+
numRefsToAdd.at(consumerId) -= 1;
10491049
}
10501050
}
10511051
}

modules/dnn/test/test_tf_importer.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,13 +1719,6 @@ TEST_P(Test_TensorFlow_layers, tf2_permute_nhwc_ncwh)
17191719
runTensorFlowNet("tf2_permute_nhwc_ncwh");
17201720
}
17211721

1722-
// issue #21852
1723-
TEST_P(Test_TensorFlow_layers, tf_graph_simplifier_buffer_overflow)
1724-
{
1725-
// This just shouldn't segfault, otherwise it's fine
1726-
EXPECT_ANY_THROW(readNetFromTensorflow(path("tf_graph_simplifier_buffer_overflow_net.pb")));
1727-
}
1728-
17291722
TEST_P(Test_TensorFlow_layers, squeeze)
17301723
{
17311724
#if defined(INF_ENGINE_RELEASE)
@@ -1899,4 +1892,25 @@ TEST_P(Test_TensorFlow_nets, EfficientDet)
18991892
expectNoFallbacksFromIE(net);
19001893
}
19011894

1895+
TEST(Test_TensorFlow_Importer, tf_graph_simplifier_buffer_overflow_21852)
1896+
{
1897+
uint8_t payload[] = {0x08, 0x08, 0x0a, 0x00, 0x0a, 0x00};
1898+
EXPECT_ANY_THROW(readNetFromTensorflow(reinterpret_cast<const char*>(payload), sizeof(payload) / sizeof(payload[0])));
1899+
}
1900+
1901+
// can be triggered with -fsanitize=address
1902+
TEST(Test_TensorFlow_Importer, tf_graph_simplifier_buffer_overflow_21947)
1903+
{
1904+
uint8_t payload[] = {0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00,
1905+
0xba, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00,
1906+
0x0a, 0xbd, 0x00, 0x1a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0xba,
1907+
0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00,
1908+
0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0xba, 0x0a, 0x00,
1909+
0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0xba,
1910+
0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00,
1911+
0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x2a, 0x00, 0xba, 0x0a, 0x00,
1912+
0x0a, 0x00, 0x5d, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x40};
1913+
EXPECT_ANY_THROW(readNetFromTensorflow(reinterpret_cast<const char*>(payload), sizeof(payload) / sizeof(payload[0])));
1914+
}
1915+
19021916
}

modules/flann/include/opencv2/flann.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ cv::flann::L2 - Squared Euclidean distance functor, optimized version.
116116
117117
cv::flann::L1 - Manhattan distance functor, optimized version.
118118
119-
cv::flann::MinkowskiDistance - The Minkowsky distance functor.
119+
cv::flann::MinkowskiDistance - The Minkowski distance functor.
120120
This is highly optimised with loop unrolling.
121121
The computation of squared root at the end is omitted for efficiency.
122122

modules/flann/include/opencv2/flann/dist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ struct MinkowskiDistance
375375
MinkowskiDistance(int order_) : order(order_) {}
376376

377377
/**
378-
* Compute the Minkowsky (L_p) distance between two vectors.
378+
* Compute the Minkowski (L_p) distance between two vectors.
379379
*
380380
* This is highly optimised, with loop unrolling, as it is one
381381
* of the most expensive inner loops.

modules/highgui/src/window_QT.cpp

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,23 +2198,58 @@ void CvWindow::displayPropertiesWin()
21982198
global_control_panel->hide();
21992199
}
22002200

2201+
static bool isTranslatableKey(Qt::Key key)
2202+
{
2203+
// https://github.com/opencv/opencv/issues/21899
2204+
// https://doc.qt.io/qt-5/qt.html#Key-enum
2205+
// https://doc.qt.io/qt-6/qt.html#Key-enum
2206+
// https://github.com/qt/qtbase/blob/dev/src/testlib/qasciikey.cpp
2207+
2208+
bool ret = false;
2209+
2210+
switch ( key )
2211+
{
2212+
// Special keys
2213+
case Qt::Key_Escape:
2214+
case Qt::Key_Tab:
2215+
case Qt::Key_Backtab:
2216+
case Qt::Key_Backspace:
2217+
case Qt::Key_Enter:
2218+
case Qt::Key_Return:
2219+
ret = true;
2220+
break;
2221+
2222+
// latin-1 keys.
2223+
default:
2224+
ret = (
2225+
( ( Qt::Key_Space <= key ) && ( key <= Qt::Key_AsciiTilde ) ) // 0x20--0x7e
2226+
||
2227+
( ( Qt::Key_nobreakspace <= key ) && ( key <= Qt::Key_ssharp ) ) // 0x0a0--0x0de
2228+
||
2229+
( key == Qt::Key_division ) // 0x0f7
2230+
||
2231+
( key == Qt::Key_ydiaeresis ) // 0x0ff
2232+
);
2233+
break;
2234+
}
2235+
2236+
return ret;
2237+
}
22012238

22022239
//Need more test here !
22032240
void CvWindow::keyPressEvent(QKeyEvent *evnt)
22042241
{
2205-
//see http://doc.trolltech.com/4.6/qt.html#Key-enum
22062242
int key = evnt->key();
2243+
const Qt::Key qtkey = static_cast<Qt::Key>(key);
22072244

2208-
Qt::Key qtkey = static_cast<Qt::Key>(key);
2209-
char asciiCode = QTest::keyToAscii(qtkey);
2210-
if (asciiCode != 0)
2211-
key = static_cast<int>(asciiCode);
2212-
else
2213-
key = evnt->nativeVirtualKey(); //same codes as returned by GTK-based backend
2245+
if ( isTranslatableKey( qtkey ) )
2246+
key = static_cast<int>( QTest::keyToAscii( qtkey ) );
2247+
else
2248+
key = evnt->nativeVirtualKey(); //same codes as returned by GTK-based backend
22142249

22152250
//control plus (Z, +, -, up, down, left, right) are used for zoom/panning functions
2216-
if (evnt->modifiers() != Qt::ControlModifier)
2217-
{
2251+
if (evnt->modifiers() != Qt::ControlModifier)
2252+
{
22182253
mutexKey.lock();
22192254
last_key = key;
22202255
mutexKey.unlock();

0 commit comments

Comments
 (0)