mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Add test for Scalar arguments at CommandLineParser
This commit is contained in:
parent
130546e1d9
commit
538fd42363
@ -37,7 +37,7 @@ Execute with image or video file:
|
||||
|
||||
@code{.bash}
|
||||
|
||||
$ example_dnn_object_detection --config=[PATH-TO-DARKNET]/cfg/yolo.cfg --model=[PATH-TO-DARKNET]/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392 --input[PATH-TO-IMAGE-OR-VIDEO-FILE]
|
||||
$ example_dnn_object_detection --config=[PATH-TO-DARKNET]/cfg/yolo.cfg --model=[PATH-TO-DARKNET]/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392 --input=[PATH-TO-IMAGE-OR-VIDEO-FILE]
|
||||
|
||||
@endcode
|
||||
|
||||
|
@ -261,4 +261,26 @@ TEST(AutoBuffer, allocate_test)
|
||||
EXPECT_EQ(6u, abuf.size());
|
||||
}
|
||||
|
||||
TEST(CommandLineParser, testScalar)
|
||||
{
|
||||
static const char * const keys3 =
|
||||
"{ s0 | 3 4 5 | default scalar }"
|
||||
"{ s1 | | single value scalar }"
|
||||
"{ s2 | | two values scalar (default with zeros) }"
|
||||
"{ s3 | | three values scalar }"
|
||||
"{ s4 | | four values scalar }"
|
||||
"{ s5 | | five values scalar }";
|
||||
|
||||
const char* argv[] = {"<bin>", "--s1=1.1", "--s3=1.1 2.2 3",
|
||||
"--s4=-4.2 1 0 3", "--s5=5 -4 3 2 1"};
|
||||
const int argc = 5;
|
||||
CommandLineParser parser(argc, argv, keys3);
|
||||
EXPECT_EQ(parser.get<Scalar>("s0"), Scalar(3, 4, 5));
|
||||
EXPECT_EQ(parser.get<Scalar>("s1"), Scalar(1.1));
|
||||
EXPECT_EQ(parser.get<Scalar>("s2"), Scalar(0));
|
||||
EXPECT_EQ(parser.get<Scalar>("s3"), Scalar(1.1, 2.2, 3));
|
||||
EXPECT_EQ(parser.get<Scalar>("s4"), Scalar(-4.2, 1, 0, 3));
|
||||
EXPECT_EQ(parser.get<Scalar>("s5"), Scalar(5, -4, 3, 2));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
@ -153,7 +153,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
*/
|
||||
|
||||
int inputNameToIndex(String inputName);
|
||||
int outputNameToIndex(String outputName);
|
||||
int outputNameToIndex(const String& outputName);
|
||||
};
|
||||
|
||||
/** @brief Classical recurrent layer
|
||||
|
@ -222,7 +222,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
/** @brief Returns index of output blob in output array.
|
||||
* @see inputNameToIndex()
|
||||
*/
|
||||
CV_WRAP virtual int outputNameToIndex(String outputName);
|
||||
CV_WRAP virtual int outputNameToIndex(const String& outputName);
|
||||
|
||||
/**
|
||||
* @brief Ask layer if it support specific backend for doing computations.
|
||||
@ -704,7 +704,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
* @ref readNetFromTorch or @ref readNetFromDarknet. An order of @p model and @p config
|
||||
* arguments does not matter.
|
||||
*/
|
||||
CV_EXPORTS_W Net readNet(String model, String config = "", String framework = "");
|
||||
CV_EXPORTS_W Net readNet(const String& model, const String& config = "", const String& framework = "");
|
||||
|
||||
/** @brief Loads blob which was serialized as torch.Tensor object of Torch7 framework.
|
||||
* @warning This function has the same limitations as readNetFromTorch().
|
||||
|
@ -398,7 +398,7 @@ struct DataLayer : public Layer
|
||||
void forward(std::vector<Mat*>&, std::vector<Mat>&, std::vector<Mat> &) {}
|
||||
void forward(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals) {}
|
||||
|
||||
int outputNameToIndex(String tgtName)
|
||||
int outputNameToIndex(const String& tgtName)
|
||||
{
|
||||
int idx = (int)(std::find(outNames.begin(), outNames.end(), tgtName) - outNames.begin());
|
||||
return (idx < (int)outNames.size()) ? idx : -1;
|
||||
@ -2513,7 +2513,7 @@ int Layer::inputNameToIndex(String)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Layer::outputNameToIndex(String)
|
||||
int Layer::outputNameToIndex(const String&)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -2805,9 +2805,11 @@ BackendWrapper::BackendWrapper(const Ptr<BackendWrapper>& base, const MatShape&
|
||||
|
||||
BackendWrapper::~BackendWrapper() {}
|
||||
|
||||
Net readNet(String model, String config, String framework)
|
||||
Net readNet(const String& _model, const String& _config, const String& _framework)
|
||||
{
|
||||
framework = framework.toLowerCase();
|
||||
String framework = _framework.toLowerCase();
|
||||
String model = _model;
|
||||
String config = _config;
|
||||
const std::string modelExt = model.substr(model.rfind('.') + 1);
|
||||
const std::string configExt = config.substr(config.rfind('.') + 1);
|
||||
if (framework == "caffe" || modelExt == "caffemodel" || configExt == "caffemodel" ||
|
||||
|
@ -355,7 +355,7 @@ int LSTMLayer::inputNameToIndex(String inputName)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int LSTMLayer::outputNameToIndex(String outputName)
|
||||
int LSTMLayer::outputNameToIndex(const String& outputName)
|
||||
{
|
||||
if (outputName.toLowerCase() == "h")
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user