1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

replace Qualcomm yolov3.onnx with darknet-converted yolov3

This commit is contained in:
Prasadayus
2026-06-05 20:12:08 +05:30
parent 8fdf15e26e
commit 56ae1e603b
6 changed files with 84 additions and 168 deletions
-30
View File
@@ -551,31 +551,6 @@ void postprocess(Mat& frame, const vector<Mat>& outs, Net& net, vector<int>& cla
}
else if (postprocessing == "yolov4")
{
// boxes[b,N,1,4]+confs[b,N,classes] (normalized) or boxes[b,N,4]+scores[b,N]+classIdx[b,N] (model-px)
bool isBoxConfsFormat = (outs.size() == 2 && outs[0].dims == 4 && outs[0].size[outs[0].dims - 1] == 4);
bool isBoxScoresIdxFormat = (outs.size() == 3 && outs[0].dims == 3 && outs[0].size[2] == 4);
if (isBoxScoresIdxFormat)
{
int N = outs[0].size[1];
const float* boxesPtr = outs[0].ptr<float>(0);
const float* scoresPtr = outs[1].ptr<float>(0);
const float* classIdxPtr = outs[2].ptr<float>(0);
for (int j = 0; j < N; ++j)
{
float score = scoresPtr[j];
if (score > confThreshold)
{
float x1 = boxesPtr[j * 4 + 0];
float y1 = boxesPtr[j * 4 + 1];
float x2 = boxesPtr[j * 4 + 2];
float y2 = boxesPtr[j * 4 + 3];
boxes.push_back(Rect((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1)));
confidences.push_back(score);
classIds.push_back((int)classIdxPtr[j]);
}
}
}
else if (isBoxConfsFormat)
{
Mat boxesMat = outs[0];
Mat confsMat = outs[1];
@@ -597,11 +572,6 @@ void postprocess(Mat& frame, const vector<Mat>& outs, Net& net, vector<int>& cla
}
}
}
else
{
cout << "Unsupported YOLO ONNX output format" << endl;
exit(-1);
}
Image2BlobParams paramNet;
paramNet.scalefactor = Scalar::all(scale);
paramNet.size = Size(inpWidth, inpHeight);