// ReadOnnx.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<opencv2/opencv.hpp>
#include<opencv2/dnn/dnn.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<vector>
#include <time.h>
using namespace std;
using namespace cv;
using namespace dnn;
inline float sigmoid(float x)
{
return 1.f / (1.f + exp(-x));
}
void drawPred(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame,const std::vector<string>& classes)
{
cv::rectangle(frame, cv::Point(left, top), cv::Point(right, bottom), cv::Scalar(0, 255, 0), 3);
std::string label = cv::format("%.2f", conf);
if (!classes.empty()) {
CV_Assert(classId < (int)classes.size());
label = classes[classId] + ": " + label;
}
int baseLine;
cv::Size labelSize = cv::getTextSize(label, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
top = std::max(top, labelSize.height);
cv::rectangle(frame, cv::Point(left, top - round(1.5 * labelSize.height)), cv::Point(left + round(1.5 * labelSize.width), top + baseLine), cv::Scalar(0, 255, 0), cv::FILLED);
cv::putText(frame, label, cv::Point(left, top), cv::FONT_HERSHEY_SIMPLEX, 0.75, cv::Scalar(), 1);