Skip to content

Commit 8277ca6

Browse files
committed
opencv-core: avoid using of multi-argument CV_Assert()
replace to CV_Assert_N()
1 parent f368d83 commit 8277ca6

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

modules/ovis/src/meshes.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ void createPlaneMesh(const String& name, const Size2f& size, InputArray image)
3737
void createPointCloudMesh(const String& name, InputArray vertices, InputArray colors)
3838
{
3939
int color_type = colors.type();
40-
CV_Assert(_app, vertices.type() == CV_32FC3 && vertices.isContinuous(),
41-
colors.empty() || color_type == CV_8UC3 || color_type == CV_8UC4);
40+
CV_Assert(_app);
41+
CV_CheckTypeEQ(vertices.type(), CV_32FC3, "")
42+
CV_Assert(vertices.isContinuous());
43+
if (!colors.empty())
44+
CV_CheckType(color_type, color_type == CV_8UC3 || color_type == CV_8UC4);
4245

4346
// material
4447
MaterialPtr mat = MaterialManager::getSingleton().create(name, RESOURCEGROUP_NAME);
@@ -101,7 +104,7 @@ void createPointCloudMesh(const String& name, InputArray vertices, InputArray co
101104

102105
void createGridMesh(const String& name, const Size2f& size, const Size& segments)
103106
{
104-
CV_Assert(_app, !segments.empty());
107+
CV_Assert_N(_app, !segments.empty());
105108

106109
// material
107110
MaterialPtr mat = MaterialManager::getSingleton().create(name, RESOURCEGROUP_NAME);

modules/ovis/src/ovis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ void _createTexture(const String& name, Mat image)
6767

6868
static void _convertRT(InputArray rot, InputArray tvec, Quaternion& q, Vector3& t, bool invert = false)
6969
{
70-
CV_Assert(rot.empty() || rot.rows() == 3 || rot.size() == Size(3, 3),
71-
tvec.empty() || tvec.rows() == 3);
70+
CV_Assert_N(rot.empty() || rot.rows() == 3 || rot.size() == Size(3, 3),
71+
tvec.empty() || tvec.rows() == 3);
7272

7373
q = Quaternion::IDENTITY;
7474
t = Vector3::ZERO;
@@ -717,7 +717,7 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
717717

718718
void setMaterialProperty(const String& name, int prop, const String& value)
719719
{
720-
CV_Assert(prop >= MATERIAL_TEXTURE0, prop <= MATERIAL_TEXTURE3, _app);
720+
CV_Assert_N(prop >= MATERIAL_TEXTURE0, prop <= MATERIAL_TEXTURE3, _app);
721721

722722
MaterialPtr mat = MaterialManager::getSingleton().getByName(name, RESOURCEGROUP_NAME);
723723
CV_Assert(mat);

modules/text/src/text_detectorCNN.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class TextDetectorCNNImpl : public TextDetectorCNN
3535
float x_max = buffer[k*nCol + 5]*inputShape.width;
3636
float y_max = buffer[k*nCol + 6]*inputShape.height;
3737

38-
CV_Assert(x_min < x_max, y_min < y_max);
38+
CV_CheckLT(x_min, x_max, "");
39+
CV_CheckLT(y_min, y_max, "");
3940

4041
x_min = std::max(0.f, x_min);
4142
y_min = std::max(0.f, y_min);
@@ -62,7 +63,7 @@ class TextDetectorCNNImpl : public TextDetectorCNN
6263

6364
void detect(InputArray inputImage_, std::vector<Rect>& Bbox, std::vector<float>& confidence) CV_OVERRIDE
6465
{
65-
CV_Assert(inputImage_.channels() == inputChannelCount_);
66+
CV_CheckEQ(inputImage_.channels(), inputChannelCount_, "");
6667
Mat inputImage = inputImage_.getMat();
6768
Bbox.resize(0);
6869
confidence.resize(0);
@@ -75,7 +76,7 @@ class TextDetectorCNNImpl : public TextDetectorCNN
7576
int nbrTextBoxes = outputNet.size[2];
7677
int nCol = outputNet.size[3];
7778
int outputChannelCount = outputNet.size[1];
78-
CV_Assert(outputChannelCount == 1);
79+
CV_CheckEQ(outputChannelCount, 1, "");
7980
getOutputs((float*)(outputNet.data), nbrTextBoxes, nCol, Bbox, confidence, inputImage.size());
8081
}
8182
}

modules/tracking/src/tracking_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ using namespace cv;
88

99
double tracking_internal::computeNCC(const Mat& patch1, const Mat& patch2)
1010
{
11-
CV_Assert( patch1.rows == patch2.rows,
12-
patch1.cols == patch2.cols);
11+
CV_CheckEQ(patch1.rows, patch2.rows, "");
12+
CV_CheckEQ(patch1.cols, patch2.cols, "");
1313

1414
int N = patch1.rows * patch1.cols;
1515

0 commit comments

Comments
 (0)