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

This commit is contained in:
Alexander Alekhin
2019-04-19 15:43:58 +03:00
40 changed files with 332 additions and 351 deletions
+5 -1
View File
@@ -1,2 +1,6 @@
set(the_description "Camera Calibration and 3D Reconstruction")
ocv_define_module(calib3d opencv_imgproc opencv_features2d opencv_flann WRAP java python)
set(debug_modules "")
if(DEBUG_opencv_calib3d)
list(APPEND debug_modules opencv_highgui)
endif()
ocv_define_module(calib3d opencv_imgproc opencv_features2d opencv_flann ${debug_modules} WRAP java python)
+1
View File
@@ -76,6 +76,7 @@
//#define ENABLE_TRIM_COL_ROW
// Requires CMake flag: DEBUG_opencv_calib3d=ON
//#define DEBUG_CHESSBOARD
#define DEBUG_CHESSBOARD_TIMEOUT 0 // 0 - wait for 'q'
+2
View File
@@ -43,6 +43,8 @@
#include "precomp.hpp"
#include "circlesgrid.hpp"
#include <limits>
// Requires CMake flag: DEBUG_opencv_calib3d=ON
//#define DEBUG_CIRCLES
#ifdef DEBUG_CIRCLES
+1 -1
View File
@@ -8,7 +8,7 @@
/// Use with major OpenCV version only.
#define OPENCV_DNN_API_VERSION 20190412
#if !defined CV_DOXYGEN && !defined CV_DNN_DONT_ADD_INLINE_NS
#if !defined CV_DOXYGEN && !defined CV_STATIC_ANALYSIS && !defined CV_DNN_DONT_ADD_INLINE_NS
#define CV__DNN_INLINE_NS __CV_CAT(dnn4_v, OPENCV_DNN_API_VERSION)
#define CV__DNN_INLINE_NS_BEGIN namespace CV__DNN_INLINE_NS {
#define CV__DNN_INLINE_NS_END }
+10
View File
@@ -105,6 +105,16 @@ public:
return true;
}
void finalize(InputArrayOfArrays inputs_arr, OutputArrayOfArrays) CV_OVERRIDE
{
std::vector<Mat> inputs;
inputs_arr.getMatVector(inputs);
int numAxes = inputs[0].dims;
_startAxis = clamp(_startAxis, numAxes);
_endAxis = clamp(_endAxis, numAxes);
}
#ifdef HAVE_OPENCL
bool forward_ocl(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr)
{
@@ -275,13 +275,13 @@ public:
InferenceEngine::Blob::Ptr weights;
if (blobs.empty())
{
auto onesBlob = InferenceEngine::make_shared_blob<float>(InferenceEngine::Precision::FP32,
InferenceEngine::Layout::C,
{(size_t)numChannels});
onesBlob->allocate();
std::vector<float> ones(numChannels, 1);
onesBlob->set(ones);
weights = onesBlob;
weights = InferenceEngine::make_shared_blob<float>(InferenceEngine::Precision::FP32,
InferenceEngine::Layout::C,
{(size_t)numChannels});
weights->allocate();
Mat weightsMat = infEngineBlobToMat(weights).reshape(1, numChannels);
Mat(numChannels, 1, CV_32F, Scalar(1)).copyTo(weightsMat);
l.getParameters()["channel_shared"] = false;
}
else
@@ -290,11 +290,7 @@ public:
weights = wrapToInfEngineBlob(blobs[0], {(size_t)numChannels}, InferenceEngine::Layout::C);
l.getParameters()["channel_shared"] = blobs[0].total() == 1;
}
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2019R1)
l.getParameters()["weights"] = weights;
#else
l.addConstantData("weights", weights);
#endif
addConstantData("weights", weights, l);
l.getParameters()["across_spatial"] = acrossSpatial;
return Ptr<BackendNode>(new InfEngineBackendNode(l));
}
+1 -5
View File
@@ -12,9 +12,6 @@
#ifdef HAVE_INF_ENGINE
#include <ie_extension.h>
#include <ie_plugin_dispatcher.hpp>
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R5)
#include <vpu/vpu_plugin_config.hpp>
#endif
#endif // HAVE_INF_ENGINE
#include <opencv2/core/utils/configuration.private.hpp>
@@ -737,8 +734,7 @@ static bool detectMyriadX_()
auto plugin = InferenceEngine::InferencePlugin(enginePtr);
try
{
auto netExec = plugin.LoadNetwork(cnn, {{InferenceEngine::VPUConfigParams::KEY_VPU_PLATFORM,
InferenceEngine::VPUConfigParams::VPU_2480}});
auto netExec = plugin.LoadNetwork(cnn, {{"VPU_PLATFORM", "VPU_2480"}});
auto infRequest = netExec.CreateInferRequest();
} catch(...) {
return false;
+20 -8
View File
@@ -15,14 +15,6 @@
#include "opencv2/dnn/utils/inference_engine.hpp"
#ifdef HAVE_INF_ENGINE
#if defined(__GNUC__) && __GNUC__ >= 5
//#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include <inference_engine.hpp>
#if defined(__GNUC__) && __GNUC__ >= 5
//#pragma GCC diagnostic pop
#endif
#define INF_ENGINE_RELEASE_2018R3 2018030000
#define INF_ENGINE_RELEASE_2018R4 2018040000
@@ -37,12 +29,32 @@
#define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000))
#define INF_ENGINE_VER_MAJOR_GE(ver) (((INF_ENGINE_RELEASE) / 10000) >= ((ver) / 10000))
#define INF_ENGINE_VER_MAJOR_LT(ver) (((INF_ENGINE_RELEASE) / 10000) < ((ver) / 10000))
#define INF_ENGINE_VER_MAJOR_LE(ver) (((INF_ENGINE_RELEASE) / 10000) <= ((ver) / 10000))
#define INF_ENGINE_VER_MAJOR_EQ(ver) (((INF_ENGINE_RELEASE) / 10000) == ((ver) / 10000))
#if defined(__GNUC__) && __GNUC__ >= 5
//#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1)
#pragma GCC visibility push(default)
#endif
#include <inference_engine.hpp>
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R5)
#include <ie_builders.hpp>
#endif
#if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R1)
#pragma GCC visibility pop
#endif
#if defined(__GNUC__) && __GNUC__ >= 5
//#pragma GCC diagnostic pop
#endif
#endif // HAVE_INF_ENGINE
namespace cv { namespace dnn {
@@ -646,6 +646,30 @@ public:
}
};
class SoftMaxSlimV2Subgraph : public Subgraph
{
public:
SoftMaxSlimV2Subgraph()
{
int input = addNodeToMatch("");
int shape = addNodeToMatch("Shape", input);
int shape_2 = addNodeToMatch("Shape", input);
int rank = addNodeToMatch("Const");
int y = addNodeToMatch("Const");
int sub = addNodeToMatch("Sub", rank, y);
int begin = addNodeToMatch("Pack", sub);
int size = addNodeToMatch("Const");
int slice = addNodeToMatch("Slice", shape, begin, size);
int values = addNodeToMatch("Const");
int axis = addNodeToMatch("Const");
int concat = addNodeToMatch("ConcatV2", values, slice, axis);
int reshape = addNodeToMatch("Reshape", input, concat);
int softmax = addNodeToMatch("Softmax", reshape);
addNodeToMatch("Reshape", softmax, shape_2);
setFusedNode("Softmax", input);
}
};
void simplifySubgraphs(tensorflow::GraphDef& net)
{
std::vector<Ptr<Subgraph> > subgraphs;
@@ -663,6 +687,7 @@ void simplifySubgraphs(tensorflow::GraphDef& net)
subgraphs.push_back(Ptr<Subgraph>(new UpsamplingKerasSubgraph()));
subgraphs.push_back(Ptr<Subgraph>(new ReshapeAsShapeSubgraph()));
subgraphs.push_back(Ptr<Subgraph>(new SoftMaxSlimSubgraph()));
subgraphs.push_back(Ptr<Subgraph>(new SoftMaxSlimV2Subgraph()));
int numNodes = net.node_size();
std::vector<int> matchedNodesIds;
+14 -7
View File
@@ -1125,18 +1125,25 @@ void TFImporter::populateNet(Net dstNet)
{
CV_Assert(hasLayerAttr(layer, "squeeze_dims"));
const tensorflow::AttrValue& dims = getLayerAttr(layer, "squeeze_dims");
if (inpLayout == DATA_LAYOUT_NHWC)
std::vector<int> dimsVector(dims.list().i_size());
for (int i = 0; i < dimsVector.size(); ++i)
dimsVector[i] = dims.list().i(i);
// Flatten layer can squeeze dimensions range into one.
std::sort(dimsVector.begin(), dimsVector.end());
for (int i = 1; i < dimsVector.size(); ++i)
{
if (dims.list().i_size() != 2 || dims.list().i(0) != 1 || dims.list().i(1) != 2)
if (dimsVector[i] != dimsVector[i - 1] + 1)
CV_Error(Error::StsNotImplemented, "Unsupported squeeze configuration");
}
else if (inpLayout == DATA_LAYOUT_NCHW)
int start = dimsVector.front() - 1, end = dimsVector.back();
if (start == -1 && end == 0) // squeeze 0th dimension
{
if (dims.list().i_size() != 2 || dims.list().i(0) != 2 || dims.list().i(1) != 3)
CV_Error(Error::StsNotImplemented, "Unsupported squeeze configuration");
start = 0;
end = 1;
}
else
CV_Error(Error::StsNotImplemented, "Unsupported squeeze configuration");
layerParams.set("axis", start);
layerParams.set("end_axis", end);
}
if (inpLayout == DATA_LAYOUT_NHWC)
{
+49
View File
@@ -637,6 +637,17 @@ TEST_P(Test_TensorFlow_layers, softmax)
runTensorFlowNet("slim_softmax");
}
TEST_P(Test_TensorFlow_layers, slim_softmax_v2)
{
#if defined(INF_ENGINE_RELEASE)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD &&
getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_2
)
throw SkipTestException("Test is disabled for Myriad2");
#endif
runTensorFlowNet("slim_softmax_v2");
}
TEST_P(Test_TensorFlow_layers, relu6)
{
runTensorFlowNet("keras_relu6");
@@ -654,6 +665,44 @@ TEST_P(Test_TensorFlow_layers, resize_bilinear)
runTensorFlowNet("resize_bilinear_factor");
}
TEST_P(Test_TensorFlow_layers, squeeze)
{
#if defined(INF_ENGINE_RELEASE)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_2
)
throw SkipTestException("Test is disabled for Myriad2");
#endif
int inpShapes[][4] = {{1, 3, 4, 2}, {1, 3, 1, 2}, {1, 3, 4, 1}, {1, 3, 4, 1}}; // TensorFlow's shape (NHWC)
int outShapes[][3] = {{3, 4, 2}, {1, 3, 2}, {1, 3, 4}, {1, 3, 4}};
int squeeze_dims[] = {0, 2, 3, -1};
for (int i = 0; i < 4; ++i)
{
SCOPED_TRACE(format("i=%d", i));
std::string pbtxt =
"node { name: \"input\" op: \"Placeholder\""
"attr { key: \"data_format\" value { s: \"NHWC\" } } }"
"node { name: \"squeeze\" op: \"Squeeze\" input: \"input\""
"attr { key: \"squeeze_dims\" value { list { i:" + format("%d", squeeze_dims[i]) + "}}}}";
Net net = readNetFromTensorflow(0, 0, pbtxt.c_str(), pbtxt.size());
net.setPreferableBackend(backend);
net.setPreferableTarget(target);
Mat tfInp(4, &inpShapes[i][0], CV_32F);
randu(tfInp, -1, 1);
// NHWC to NCHW
CV_Assert(inpShapes[i][0] == 1);
std::swap(inpShapes[i][2], inpShapes[i][3]);
std::swap(inpShapes[i][1], inpShapes[i][2]);
Mat cvInp = tfInp.reshape(1, tfInp.total() / inpShapes[i][1]).t();
cvInp = cvInp.reshape(1, 4, &inpShapes[i][0]);
net.setInput(cvInp);
Mat out = net.forward();
normAssert(tfInp.reshape(1, 3, &outShapes[i][0]), out, "", default_l1, default_lInf);
}
}
INSTANTIATE_TEST_CASE_P(/**/, Test_TensorFlow_layers, dnnBackendsAndTargets());
TEST(Test_TensorFlow, two_inputs)
+5 -1
View File
@@ -1,2 +1,6 @@
set(the_description "2D Features Framework")
ocv_define_module(features2d opencv_imgproc OPTIONAL opencv_flann opencv_highgui WRAP java python js)
set(debug_modules "")
if(DEBUG_opencv_features2d)
list(APPEND debug_modules opencv_highgui)
endif()
ocv_define_module(features2d opencv_imgproc ${debug_modules} OPTIONAL opencv_flann WRAP java python js)
+12 -16
View File
@@ -44,15 +44,11 @@
#include <iterator>
#include <limits>
// Requires CMake flag: DEBUG_opencv_features2d=ON
//#define DEBUG_BLOB_DETECTOR
#ifdef DEBUG_BLOB_DETECTOR
# include "opencv2/opencv_modules.hpp"
# ifdef HAVE_OPENCV_HIGHGUI
# include "opencv2/highgui.hpp"
# else
# undef DEBUG_BLOB_DETECTOR
# endif
#include "opencv2/highgui.hpp"
#endif
namespace cv
@@ -200,13 +196,13 @@ void SimpleBlobDetectorImpl::findBlobs(InputArray _image, InputArray _binaryImag
findContours(binaryImage, contours, RETR_LIST, CHAIN_APPROX_NONE);
#ifdef DEBUG_BLOB_DETECTOR
// Mat keypointsImage;
// cvtColor( binaryImage, keypointsImage, CV_GRAY2RGB );
//
// Mat contoursImage;
// cvtColor( binaryImage, contoursImage, CV_GRAY2RGB );
// drawContours( contoursImage, contours, -1, Scalar(0,255,0) );
// imshow("contours", contoursImage );
Mat keypointsImage;
cvtColor(binaryImage, keypointsImage, COLOR_GRAY2RGB);
Mat contoursImage;
cvtColor(binaryImage, contoursImage, COLOR_GRAY2RGB);
drawContours( contoursImage, contours, -1, Scalar(0,255,0) );
imshow("contours", contoursImage );
#endif
for (size_t contourIdx = 0; contourIdx < contours.size(); contourIdx++)
@@ -296,12 +292,12 @@ void SimpleBlobDetectorImpl::findBlobs(InputArray _image, InputArray _binaryImag
#ifdef DEBUG_BLOB_DETECTOR
// circle( keypointsImage, center.location, 1, Scalar(0,0,255), 1 );
circle( keypointsImage, center.location, 1, Scalar(0,0,255), 1 );
#endif
}
#ifdef DEBUG_BLOB_DETECTOR
// imshow("bk", keypointsImage );
// waitKey();
imshow("bk", keypointsImage );
waitKey();
#endif
}
+2 -2
View File
@@ -125,8 +125,8 @@ elseif(HAVE_COCOA)
list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa")
endif()
if(UNIX)
#these variables are set by CHECK_MODULE macro
if(TRUE)
# these variables are set by 'ocv_append_build_options(HIGHGUI ...)'
foreach(P ${HIGHGUI_INCLUDE_DIRS})
ocv_include_directories(${P})
endforeach()
+2 -2
View File
@@ -116,8 +116,8 @@ if(APPLE_FRAMEWORK)
list(APPEND IMGCODECS_LIBRARIES "-framework UIKit")
endif()
if(UNIX)
#these variables are set by CHECK_MODULE macro
if(TRUE)
# these variables are set by 'ocv_append_build_options(IMGCODECS ...)'
foreach(P ${IMGCODECS_INCLUDE_DIRS})
ocv_include_directories(${P})
endforeach()
-7
View File
@@ -75,8 +75,6 @@ CV_CannyTest::CV_CannyTest(bool custom_deriv)
aperture_size = 0;
use_true_gradient = false;
threshold1 = threshold2 = 0;
test_cpp = false;
test_custom_deriv = custom_deriv;
const char imgPath[] = "shared/fruits.png";
@@ -158,11 +156,6 @@ void CV_CannyTest::run_func()
cvtest::filter2D(src, dy, CV_16S, dykernel, anchor, 0, BORDER_REPLICATE);
cv::Canny(dx, dy, _out, threshold1, threshold2, use_true_gradient);
}
else if(!test_cpp)
{
cvCanny( test_array[INPUT][0], test_array[OUTPUT][0], threshold1, threshold2,
aperture_size + (use_true_gradient ? CV_CANNY_L2_GRADIENT : 0));
}
else
{
cv::Mat _out = cv::cvarrToMat(test_array[OUTPUT][0]);
-171
View File
@@ -245,176 +245,6 @@ int CV_DrawingTest_CPP::checkLineIterator( Mat& img )
return 0;
}
class CV_DrawingTest_C : public CV_DrawingTest
{
public:
CV_DrawingTest_C() {}
protected:
virtual void draw( Mat& img );
virtual int checkLineIterator( Mat& img);
};
void CV_DrawingTest_C::draw( Mat& _img )
{
CvSize imgSize = cvSize(600, 400);
_img.create( imgSize, CV_8UC3 );
CvMat img = cvMat(_img);
vector<CvPoint> polyline(4);
polyline[0] = cvPoint(0, 0);
polyline[1] = cvPoint(imgSize.width, 0);
polyline[2] = cvPoint(imgSize.width, imgSize.height);
polyline[3] = cvPoint(0, imgSize.height);
CvPoint* pts = &polyline[0];
int n = (int)polyline.size();
int actualSize = 0;
cvFillPoly( &img, &pts, &n, 1, cvScalar(255,255,255) );
CvPoint p1 = cvPoint(1,1), p2 = cvPoint(3,3);
if( cvClipLine(imgSize, &p1, &p2) )
cvCircle( &img, cvPoint(300,100), 40, cvScalar(0,0,255), 3 ); // draw
p1 = cvPoint(1,1), p2 = cvPoint(3,imgSize.height+1000);
if( cvClipLine(imgSize, &p1, &p2) )
cvCircle( &img, cvPoint(500,300), 50, cvScalar(255,0,0), 5, 8, 1 ); // draw
p1 = cvPoint(imgSize.width,1), p2 = cvPoint(imgSize.width,3);
if( cvClipLine(imgSize, &p1, &p2) )
cvCircle( &img, cvPoint(390,100), 10, cvScalar(0,0,255), 3 ); // not draw
p1 = cvPoint(imgSize.width-1,1), p2 = cvPoint(imgSize.width,3);
if( cvClipLine(imgSize, &p1, &p2) )
cvEllipse( &img, cvPoint(390,100), cvSize(20,30), 60, 0, 220.0, cvScalar(0,200,0), 4 ); //draw
CvBox2D box;
box.center.x = 100;
box.center.y = 200;
box.size.width = 200;
box.size.height = 100;
box.angle = 160;
cvEllipseBox( &img, box, cvScalar(200,200,255), 5 );
polyline.resize(9);
pts = &polyline[0];
n = (int)polyline.size();
actualSize = cvEllipse2Poly( cvPoint(430,180), cvSize(100,150), 30, 0, 150, &polyline[0], 20 );
CV_Assert(actualSize == n);
cvPolyLine( &img, &pts, &n, 1, false, cvScalar(0,0,150), 4, CV_AA );
n = 0;
for( vector<CvPoint>::const_iterator it = polyline.begin(); n < (int)polyline.size()-1; ++it, n++ )
{
cvLine( &img, *it, *(it+1), cvScalar(50,250,100) );
}
polyline.resize(19);
pts = &polyline[0];
n = (int)polyline.size();
actualSize = cvEllipse2Poly( cvPoint(500,300), cvSize(50,80), 0, 0, 180, &polyline[0], 10 );
CV_Assert(actualSize == n);
cvPolyLine( &img, &pts, &n, 1, true, cvScalar(100,200,100), 20 );
cvFillConvexPoly( &img, pts, n, cvScalar(0, 80, 0) );
polyline.resize(8);
// external rectengular
polyline[0] = cvPoint(500, 20);
polyline[1] = cvPoint(580, 20);
polyline[2] = cvPoint(580, 100);
polyline[3] = cvPoint(500, 100);
// internal rectangular
polyline[4] = cvPoint(520, 40);
polyline[5] = cvPoint(560, 40);
polyline[6] = cvPoint(560, 80);
polyline[7] = cvPoint(520, 80);
CvPoint* ppts[] = {&polyline[0], &polyline[0]+4};
int pn[] = {4, 4};
cvFillPoly( &img, ppts, pn, 2, cvScalar(100, 100, 0), 8, 0 );
cvRectangle( &img, cvPoint(0, 300), cvPoint(50, 398), cvScalar(0,0,255) );
string text1 = "OpenCV";
CvFont font;
cvInitFont( &font, FONT_HERSHEY_SCRIPT_SIMPLEX, 2, 2, 0, 3 );
int baseline = 0;
CvSize textSize = {0, 0};
cvGetTextSize( text1.c_str(), &font, &textSize, &baseline );
baseline += font.thickness;
CvPoint textOrg = cvPoint((imgSize.width - textSize.width)/2, (imgSize.height + textSize.height)/2);
cvRectangle( &img, cvPoint( textOrg.x, textOrg.y + baseline),
cvPoint(textOrg.x + textSize.width, textOrg.y - textSize.height), cvScalar(0,0,255));
cvLine( &img, cvPoint(textOrg.x, textOrg.y + font.thickness),
cvPoint(textOrg.x + textSize.width, textOrg.y + font.thickness), cvScalar(0, 0, 255));
cvPutText( &img, text1.c_str(), textOrg, &font, cvScalar(150,0,150) );
int dist = 5;
string text2 = "abcdefghijklmnopqrstuvwxyz1234567890";
CvScalar color = cvScalar(200,0,0);
cvInitFont( &font, FONT_HERSHEY_SIMPLEX, 0.5, 0.5, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(5, 5+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
cvInitFont( &font, FONT_HERSHEY_PLAIN, 1, 1, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
cvInitFont( &font, FONT_HERSHEY_DUPLEX, 0.5, 0.5, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
cvInitFont( &font, FONT_HERSHEY_COMPLEX, 0.5, 0.5, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
cvInitFont( &font, FONT_HERSHEY_TRIPLEX, 0.5, 0.5, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
cvInitFont( &font, FONT_HERSHEY_COMPLEX_SMALL, 1, 1, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist + 180);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
cvInitFont( &font, FONT_HERSHEY_SCRIPT_SIMPLEX, 1, 1, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
cvInitFont( &font, FONT_HERSHEY_SCRIPT_COMPLEX, 1, 1, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
dist = 15;
cvInitFont( &font, FONT_ITALIC, 0.5, 0.5, 0, 1, CV_AA );
cvGetTextSize( text2.c_str(), &font, &textSize, &baseline );
textOrg = cvPoint(textOrg.x,textOrg.y+textSize.height+dist);
cvPutText(&img, text2.c_str(), textOrg, &font, color );
}
int CV_DrawingTest_C::checkLineIterator( Mat& _img )
{
CvLineIterator it;
CvMat img = cvMat(_img);
int count = cvInitLineIterator( &img, cvPoint(0,300), cvPoint(1000, 300), &it );
for(int i = 0; i < count; i++ )
{
Vec3b v = (Vec3b)(*(it.ptr)) - _img.at<Vec3b>(300,i);
float err = (float)cvtest::norm( v, NORM_L2 );
if( err != 0 )
{
ts->printf( ts->LOG, "CvLineIterator works incorrect" );
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
}
CV_NEXT_LINE_POINT(it);
}
ts->set_failed_test_info(cvtest::TS::OK);
return 0;
}
class CV_DrawingTest_Far : public CV_DrawingTest_CPP
{
public:
@@ -549,7 +379,6 @@ void CV_DrawingTest_Far::draw(Mat& img)
}
TEST(Drawing, cpp_regression) { CV_DrawingTest_CPP test; test.safe_run(); }
TEST(Drawing, c_regression) { CV_DrawingTest_C test; test.safe_run(); }
TEST(Drawing, far_regression) { CV_DrawingTest_Far test; test.safe_run(); }
class CV_FillConvexPolyTest : public cvtest::BaseTest
+5 -6
View File
@@ -536,11 +536,9 @@ void CV_SobelTest::get_test_array_types_and_sizes( int test_case_idx,
void CV_SobelTest::run_func()
{
cvSobel( test_array[inplace ? OUTPUT : INPUT][0],
test_array[OUTPUT][0], dx, dy, _aperture_size );
/*cv::Sobel( test_mat[inplace ? OUTPUT : INPUT][0],
cv::Sobel( test_mat[inplace ? OUTPUT : INPUT][0],
test_mat[OUTPUT][0], test_mat[OUTPUT][0].depth(),
dx, dy, _aperture_size, 1, 0, border );*/
dx, dy, _aperture_size, 1, 0, border );
}
@@ -655,8 +653,9 @@ void CV_LaplaceTest::get_test_array_types_and_sizes( int test_case_idx,
void CV_LaplaceTest::run_func()
{
cvLaplace( test_array[inplace ? OUTPUT : INPUT][0],
test_array[OUTPUT][0], _aperture_size );
cv::Laplacian( test_mat[inplace ? OUTPUT : INPUT][0],
test_mat[OUTPUT][0],test_mat[OUTPUT][0].depth(),
_aperture_size, 1, 0, cv::BORDER_REPLICATE );
}
+1
View File
@@ -41,6 +41,7 @@
<junit printsummary="true" haltonfailure="false" haltonerror="false" showoutput="true" logfailedtests="true" maxmemory="256m">
<sysproperty key="java.library.path" path="${opencv.lib.path}"/>
<env key="PATH" path="${opencv.lib.path}:${env.PATH}:${env.Path}"/>
<env key="DYLD_LIBRARY_PATH" path="${env.OPENCV_SAVED_DYLD_LIBRARY_PATH}"/> <!-- https://github.com/opencv/opencv/issues/14353 -->
<classpath refid="master-classpath"/>
<classpath>
<pathelement location="build/classes"/>
+8
View File
@@ -505,6 +505,14 @@ public:
The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method.
*/
CV_WRAP static Ptr<KNearest> create();
/** @brief Loads and creates a serialized knearest from a file
*
* Use KNearest::save to serialize and store an KNearest to disk.
* Load the KNearest from this file again, by calling this function with the path to the file.
*
* @param filepath path to serialized KNearest
*/
CV_WRAP static Ptr<KNearest> load(const String& filepath);
};
/****************************************************************************************\
@@ -0,0 +1,13 @@
#!/usr/bin/env python
import cv2 as cv
from tests_common import NewOpenCVTests
class knearest_test(NewOpenCVTests):
def test_load(self):
k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
self.assertFalse(k_nearest.empty())
self.assertTrue(k_nearest.isTrained())
if __name__ == '__main__':
NewOpenCVTests.bootstrap()
+11
View File
@@ -515,6 +515,17 @@ Ptr<KNearest> KNearest::create()
return makePtr<KNearestImpl>();
}
Ptr<KNearest> KNearest::load(const String& filepath)
{
FileStorage fs;
fs.open(filepath, FileStorage::READ);
Ptr<KNearest> knearest = makePtr<KNearestImpl>();
((KNearestImpl*)knearest.get())->read(fs.getFirstTopLevelNode());
return knearest;
}
}
}
+7
View File
@@ -37,6 +37,13 @@ def execute(cmd, silent=False, cwd=".", env=None):
new_env = os.environ.copy()
new_env.update(env)
env = new_env
if sys.platform == 'darwin': # https://github.com/opencv/opencv/issues/14351
if env is None:
env = os.environ.copy()
if 'DYLD_LIBRARY_PATH' in env:
env['OPENCV_SAVED_DYLD_LIBRARY_PATH'] = env['DYLD_LIBRARY_PATH']
if silent:
return check_output(cmd, stderr=STDOUT, cwd=cwd, env=env).decode("latin-1")
else:
+1
View File
@@ -755,6 +755,7 @@ static uint64_t memory_usage_base_opencl = 0;
void testSetUp()
{
fflush(stdout); fflush(stderr);
cv::ipp::setIppStatus(0);
cv::theRNG().state = cvtest::param_seed;
cv::setNumThreads(cvtest::testThreads);
+1 -1
View File
@@ -1,6 +1,6 @@
# --- Aravis SDK ---
if(NOT HAVE_ARAVIS_API AND PKG_CONFIG_FOUND)
pkg_check_modules(ARAVIS aravis-0.6 QUIET)
ocv_check_modules(ARAVIS aravis-0.6 QUIET)
if(ARAVIS_FOUND)
set(HAVE_ARAVIS_API TRUE)
endif()
+1 -1
View File
@@ -1,6 +1,6 @@
# --- Dc1394 ---
if(NOT HAVE_DC1394_2 AND PKG_CONFIG_FOUND)
pkg_check_modules(DC1394_2 libdc1394-2 QUIET)
ocv_check_modules(DC1394_2 libdc1394-2)
if(DC1394_2_FOUND)
set(DC1394_2_VERSION "${DC1394_2_VERSION}" PARENT_SCOPE) # informational
set(HAVE_DC1394_2 TRUE)
+2 -13
View File
@@ -25,23 +25,12 @@ if(NOT HAVE_FFMPEG AND WIN32 AND NOT ARM AND NOT OPENCV_FFMPEG_SKIP_DOWNLOAD)
endif()
if(NOT HAVE_FFMPEG AND PKG_CONFIG_FOUND)
pkg_check_modules(FFMPEG libavcodec libavformat libavutil libswscale QUIET)
pkg_check_modules(FFMPEG_libavresample libavresample QUIET) # optional
ocv_check_modules(FFMPEG libavcodec libavformat libavutil libswscale)
if(FFMPEG_FOUND)
ocv_check_modules(FFMPEG_libavresample libavresample) # optional
if(FFMPEG_libavresample_FOUND)
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_libavresample_LIBRARIES})
endif()
# rewrite libraries to absolute paths
foreach(lib ${FFMPEG_LIBRARIES})
find_library(FFMPEG_ABSOLUTE_${lib} "${lib}" PATHS "${FFMPEG_lib${lib}_LIBDIR}" "${FFMPEG_LIBRARY_DIRS}" NO_DEFAULT_PATH)
if(FFMPEG_ABSOLUTE_${lib})
list(APPEND ffmpeg_abs_libs "${FFMPEG_ABSOLUTE_${lib}}")
else()
list(APPEND ffmpeg_abs_libs "${lib}")
endif()
endforeach()
set(FFMPEG_LIBRARIES "${ffmpeg_abs_libs}" CACHE INTERNAL "" FORCE)
set(HAVE_FFMPEG TRUE)
endif()
endif()
+1 -1
View File
@@ -1,6 +1,6 @@
# --- gPhoto2 ---
if(NOT HAVE_GPHOTO2 AND PKG_CONFIG_FOUND)
pkg_check_modules(GPHOTO2 libgphoto2 QUIET)
ocv_check_modules(GPHOTO2 libgphoto2)
if(GPHOTO2_FOUND)
set(HAVE_GPHOTO2 TRUE)
endif()
+4 -4
View File
@@ -82,10 +82,10 @@ if(NOT HAVE_GSTREAMER AND WIN32)
endif()
if(NOT HAVE_GSTREAMER AND PKG_CONFIG_FOUND)
pkg_check_modules(GSTREAMER_base gstreamer-base-1.0 QUIET)
pkg_check_modules(GSTREAMER_app gstreamer-app-1.0 QUIET)
pkg_check_modules(GSTREAMER_riff gstreamer-riff-1.0 QUIET)
pkg_check_modules(GSTREAMER_pbutils gstreamer-pbutils-1.0 QUIET)
ocv_check_modules(GSTREAMER_base gstreamer-base-1.0)
ocv_check_modules(GSTREAMER_app gstreamer-app-1.0)
ocv_check_modules(GSTREAMER_riff gstreamer-riff-1.0)
ocv_check_modules(GSTREAMER_pbutils gstreamer-pbutils-1.0)
if(GSTREAMER_base_FOUND AND GSTREAMER_app_FOUND AND GSTREAMER_riff_FOUND AND GSTREAMER_pbutils_FOUND)
set(HAVE_GSTREAMER TRUE)
set(GSTREAMER_VERSION ${GSTREAMER_base_VERSION} PARENT_SCOPE) # informational
+1 -4
View File
@@ -1,8 +1,5 @@
if(NOT HAVE_XINE AND PKG_CONFIG_FOUND)
pkg_check_modules(XINE libxine QUIET)
if(XINE_FOUND)
set(HAVE_XINE TRUE)
endif()
ocv_check_modules(XINE libxine QUIET)
endif()
if(HAVE_XINE)
+1
View File
@@ -1,5 +1,6 @@
#=============================================
# build with OpenCV
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVUtils.cmake")
function(ocv_create_builtin_videoio_plugin name target videoio_src_file)
+1 -1
View File
@@ -3,7 +3,7 @@
set -e
if [ -z $1 ] ; then
echo "<script> <destination directory>"
echo "$0 <destination directory>"
exit 1
fi