From 9eb5e39ff30ef3f7357b7dfde335140bf58fbda4 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 21 Feb 2023 21:20:37 +0000 Subject: [PATCH] dnn(tflite): fix wrong axis normalization --- modules/dnn/src/tflite/tflite_importer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/dnn/src/tflite/tflite_importer.cpp b/modules/dnn/src/tflite/tflite_importer.cpp index bdd061cab8..d556bf6f6f 100644 --- a/modules/dnn/src/tflite/tflite_importer.cpp +++ b/modules/dnn/src/tflite/tflite_importer.cpp @@ -497,9 +497,8 @@ void TFLiteImporter::parseConcat(const Operator& op, const std::string& opcode, DataLayout inpLayout = layouts[op.inputs()->Get(0)]; if (inpLayout == DATA_LAYOUT_NHWC) { // OpenCV works in NCHW data layout. So change the axis correspondingly. - CV_Check(axis, -4 < axis && axis < 4, ""); - int remap[] = {0, 2, 3, 1}; - axis = axis > 0 ? axis : 4 + axis; + axis = normalize_axis(axis, 4); + static const int remap[] = {0, 2, 3, 1}; axis = remap[axis]; } layerParams.set("axis", axis);