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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user