Merge remote-tracking branch 'upstream/3.4' into merge-3.4

pull/18531/head
Alexander Alekhin 4 years ago
commit 39d5e14c1f
  1. 2
      modules/calib3d/include/opencv2/calib3d.hpp
  2. 6
      modules/core/include/opencv2/core/eigen.hpp
  3. 15
      modules/core/src/matrix.cpp
  4. 3
      modules/core/src/parallel.cpp
  5. 28
      modules/core/test/test_mat.cpp
  6. 24
      modules/dnn/src/dnn.cpp
  7. 9
      modules/dnn/test/test_misc.cpp
  8. 1
      modules/java/generator/gen_java.py
  9. 41
      modules/videoio/src/cap_dc1394_v2.cpp

@ -2607,7 +2607,7 @@ final fundamental matrix. It can be set to something like 1-3, depending on the
point localization, image resolution, and the image noise.
@param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
of confidence (probability) that the estimated matrix is correct.
@param mask
@param[out] mask optional output mask
@param maxIters The maximum number of robust method iterations.
The epipolar geometry is described by the following equation:

@ -58,11 +58,13 @@
#pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data
#endif
#if !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT)
#if EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3 \
&& defined(CV_CXX11) && defined(CV_CXX_STD_ARRAY)
#include <unsupported/Eigen/CXX11/Tensor>
#define OPENCV_EIGEN_TENSOR_SUPPORT
#endif // EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3
#define OPENCV_EIGEN_TENSOR_SUPPORT 1
#endif // EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3
#endif // !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT)
namespace cv
{

@ -237,12 +237,19 @@ void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool auto
if( _steps )
{
if (_steps[i] % esz1 != 0)
if (i < _dims-1)
{
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
}
if (_steps[i] % esz1 != 0)
{
CV_Error_(Error::BadStep, ("Step %zu for dimension %d must be a multiple of esz1 %zu", _steps[i], i, esz1));
}
m.step.p[i] = i < _dims-1 ? _steps[i] : esz;
m.step.p[i] = _steps[i];
}
else
{
m.step.p[i] = esz;
}
}
else if( autoSteps )
{

@ -54,7 +54,8 @@
#endif
#if defined __linux__ || defined __APPLE__ || defined __GLIBC__ \
|| defined __HAIKU__ || defined __EMSCRIPTEN__ || defined __FreeBSD__
|| defined __HAIKU__ || defined __EMSCRIPTEN__ || defined __FreeBSD__ \
|| defined __OpenBSD__
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>

@ -2175,4 +2175,32 @@ TEST(Mat, empty_iterator_16855)
EXPECT_TRUE(m.begin<uchar>() == m.end<uchar>());
}
TEST(Mat, regression_18473)
{
std::vector<int> sizes(3);
sizes[0] = 20;
sizes[1] = 50;
sizes[2] = 100;
#if 1 // with the fix
std::vector<size_t> steps(2);
steps[0] = 50*100*2;
steps[1] = 100*2;
#else // without the fix
std::vector<size_t> steps(3);
steps[0] = 50*100*2;
steps[1] = 100*2;
steps[2] = 2;
#endif
std::vector<short> data(20*50*100, 0); // 1Mb
data[data.size() - 1] = 5;
// param steps Array of ndims-1 steps
Mat m(sizes, CV_16SC1, (void*)data.data(), (const size_t*)steps.data());
ASSERT_FALSE(m.empty());
EXPECT_EQ((int)5, (int)m.at<short>(19, 49, 99));
}
}} // namespace

@ -3934,11 +3934,16 @@ void Net::connect(String _outPin, String _inPin)
Mat Net::forward(const String& outputName)
{
CV_TRACE_FUNCTION();
CV_Assert(!empty());
String layerName = outputName;
if (layerName.empty())
layerName = getLayerNames().back();
{
std::vector<String> layerNames = getLayerNames();
CV_Assert(!layerNames.empty());
layerName = layerNames.back();
}
std::vector<LayerPin> pins(1, impl->getPinByAlias(layerName));
impl->setUpNet(pins);
@ -3950,11 +3955,17 @@ Mat Net::forward(const String& outputName)
AsyncArray Net::forwardAsync(const String& outputName)
{
CV_TRACE_FUNCTION();
CV_Assert(!empty());
#ifdef CV_CXX11
String layerName = outputName;
if (layerName.empty())
layerName = getLayerNames().back();
{
std::vector<String> layerNames = getLayerNames();
CV_Assert(!layerNames.empty());
layerName = layerNames.back();
}
std::vector<LayerPin> pins(1, impl->getPinByAlias(layerName));
impl->setUpNet(pins);
@ -3975,11 +3986,16 @@ AsyncArray Net::forwardAsync(const String& outputName)
void Net::forward(OutputArrayOfArrays outputBlobs, const String& outputName)
{
CV_TRACE_FUNCTION();
CV_Assert(!empty());
String layerName = outputName;
if (layerName.empty())
layerName = getLayerNames().back();
{
std::vector<String> layerNames = getLayerNames();
CV_Assert(!layerNames.empty());
layerName = layerNames.back();
}
std::vector<LayerPin> pins(1, impl->getPinByAlias(layerName));
impl->setUpNet(pins);
@ -4571,6 +4587,8 @@ std::vector<Ptr<Layer> > Net::getLayerInputs(LayerId layerId)
std::vector<String> Net::getLayerNames() const
{
CV_TRACE_FUNCTION();
std::vector<String> res;
res.reserve(impl->layers.size());

@ -99,6 +99,15 @@ TEST(readNet, do_not_call_setInput) // https://github.com/opencv/opencv/issues/
EXPECT_TRUE(res.empty()) << res.size;
}
TEST(Net, empty_forward_18392)
{
cv::dnn::Net net;
Mat image(Size(512, 512), CV_8UC3, Scalar::all(0));
Mat inputBlob = cv::dnn::blobFromImage(image, 1.0, Size(512, 512), Scalar(0,0,0), true, false);
net.setInput(inputBlob);
EXPECT_ANY_THROW(Mat output = net.forward());
}
#ifdef HAVE_INF_ENGINE
static
void test_readNet_IE_do_not_call_setInput(Backend backendId)

@ -787,6 +787,7 @@ class JavaWrapperGenerator(object):
inCode = True
if "</code>" in line:
inCode = False
line = line.replace('@result ', '@return ') # @result is valid in Doxygen, but invalid in Javadoc
if "@return " in line:
returnTag = True

@ -207,60 +207,57 @@ bool CvCaptureCAM_DC1394_v2_CPP::startCapture()
DC1394_ISO_SPEED_3200);
}
// should a specific mode be used
if (userMode >= 0)
dc1394video_modes_t videoModes;
dc1394_video_get_supported_modes(dcCam, &videoModes);
// should a specific mode be used
while (userMode >= 0) // 'if' semantic, no real loop here
{
dc1394video_mode_t wantedMode;
dc1394video_modes_t videoModes;
dc1394_video_get_supported_modes(dcCam, &videoModes);
//set mode from number, for example the second supported mode, i.e userMode = 1
if (userMode < (int)videoModes.num)
{
// set mode from number, for example the second supported mode, i.e userMode = 1
wantedMode = videoModes.modes[userMode];
}
//set modes directly from DC134 constants (from dc1394video_mode_t)
else if ((userMode >= DC1394_VIDEO_MODE_MIN) && (userMode <= DC1394_VIDEO_MODE_MAX ))
else if ((userMode >= DC1394_VIDEO_MODE_MIN) && (userMode <= DC1394_VIDEO_MODE_MAX))
{
// set modes directly from DC134 constants (from dc1394video_mode_t)
//search for wanted mode, to check if camera supports it
int j = 0;
while ((j< (int)videoModes.num) && videoModes.modes[j]!=userMode)
while ((j < (int)videoModes.num) && videoModes.modes[j] != userMode)
{
j++;
}
if ((int)videoModes.modes[j]==userMode)
{
wantedMode = videoModes.modes[j];
}
else
if (!(j < (int)videoModes.num))
{
userMode = -1; // wanted mode not supported, search for best mode
break;
}
wantedMode = videoModes.modes[j];
}
else
{
userMode = -1; // wanted mode not supported, search for best mode
userMode = -1; // wanted mode not supported, search for best mode
break;
}
//if userMode is available: set it and update size
if (userMode != -1)
{
code = dc1394_video_set_mode(dcCam, wantedMode);
uint32_t width, height;
uint32_t width = 0, height = 0;
dc1394_get_image_size_from_video_mode(dcCam, wantedMode, &width, &height);
frameWidth = (int)width;
frameHeight = (int)height;
}
break;
}
if (userMode == -1 && (frameWidth > 0 || frameHeight > 0))
{
dc1394video_mode_t bestMode = (dc1394video_mode_t) - 1;
dc1394video_modes_t videoModes;
dc1394_video_get_supported_modes(dcCam, &videoModes);
dc1394video_mode_t bestMode = (dc1394video_mode_t)(-1);
for (i = 0; i < (int)videoModes.num; i++)
{
dc1394video_mode_t mode = videoModes.modes[i];

Loading…
Cancel
Save