当前位置: 首页 > news >正文

做app模板网站有哪些内容营销运营主要做什么

做app模板网站有哪些内容,营销运营主要做什么,垂直网站建设,南平网站开发使用OpenCV的DNN模块在C中部署ONNX模型涉及几个步骤&#xff0c;包括加载模型、预处理输入数据、进行推理以及处理输出。 构建了yolo类&#xff0c;方便调用 yolo.h 文件 #ifndef YOLO_H #define YOLO_H #include <fstream> #include <sstream> #include <io…

使用OpenCV的DNN模块在C++中部署ONNX模型涉及几个步骤,包括加载模型、预处理输入数据、进行推理以及处理输出。

构建了yolo类,方便调用

yolo.h 文件

#ifndef YOLO_H
#define YOLO_H
#include <fstream>
#include <sstream>
#include <iostream>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>struct yoloDetectionResult_detection_thread
{cv::Point2f DetectionResultLocation; // 目标中心点像素位置cv::Point2d DetectionResultClassAndConf; //类型、置信度cv::Rect DetectionResultRect; //目标矩形框cv::Mat DetectionResultIMG;   //目标像素unsigned char object_no = -1;  //目标序号unsigned char object_mission = -1; //目标任务状态int frame_no;  //图像帧号
};
class detect_result
{
public:int classId;float confidence;cv::Rect_<float> box;};class YOLO
{
public:YOLO();~YOLO();void init(std::string onnxpath);void detect(cv::Mat& frame, std::vector<detect_result>& result);void draw_frame(cv::Mat& frame, std::vector<detect_result>& results);private:cv::dnn::Net net;const float confidence_threshold_ = 0.4f;const float nms_threshold_ = 0.4f;const int model_input_width_ = 640;const int model_input_height_ = 640;double HighWidthHeightRatio = 25;double LowWidthHeightRatio = 0.05;
};#endif // !YOLO_H

yolo.cpp

#include "yolo.h"YOLO::YOLO()
{}YOLO::~YOLO()
{}void YOLO::init(std::string onnxpath)
{this->net = cv::dnn::readNetFromONNX(onnxpath);
}void YOLO::detect(cv::Mat& frame, std::vector<detect_result>& results)
{int w = frame.cols;int h = frame.rows;int _max = std::max(h, w);cv::Mat image = cv::Mat::zeros(cv::Size(_max, _max), CV_8UC3);if(frame.channels()==1){cv::cvtColor(frame, frame, cv::COLOR_GRAY2BGR);}  cv::Rect roi(0, 0, w, h);frame.copyTo(image(cv::Rect(0, 0, w, h)));float x_factor = static_cast<float>(image.cols) / model_input_width_;float y_factor = static_cast<float>(image.rows) / model_input_height_;cv::Mat blob = cv::dnn::blobFromImage(image, 1 / 255.0, cv::Size(model_input_width_, model_input_height_), cv::Scalar(0, 0, 0), true, false);this->net.setInput(blob);cv::Mat preds = this->net.forward("output0");//outputname,使用Netron看一下输出的名字,一般为output0或者outputcv::Mat det_output(preds.size[1], preds.size[2], CV_32F, preds.ptr<float>());std::vector<cv::Rect> boxes;std::vector<int> classIds;std::vector<float> confidences;for (int i = 0; i < det_output.rows; i++){float box_conf = det_output.at<float>(i, 4);if (box_conf < nms_threshold_){continue;}cv::Mat classes_confidences = det_output.row(i).colRange(5, 6);cv::Point classIdPoint;double cls_conf;cv::minMaxLoc(classes_confidences, 0, &cls_conf, 0, &classIdPoint);if (cls_conf > confidence_threshold_){float cx = det_output.at<float>(i, 0);float cy = det_output.at<float>(i, 1);float ow = det_output.at<float>(i, 2);float oh = det_output.at<float>(i, 3);int x = static_cast<int>((cx - 0.5 * ow) * x_factor);int y = static_cast<int>((cy - 0.5 * oh) * y_factor);int width = static_cast<int>(ow * x_factor);int height = static_cast<int>(oh * y_factor);cv::Rect box;box.x = x;box.y = y;box.width = width;box.height = height;boxes.push_back(box);classIds.push_back(classIdPoint.x);confidences.push_back(cls_conf * box_conf);}}std::vector<int> indexes;cv::dnn::NMSBoxes(boxes, confidences, confidence_threshold_, nms_threshold_, indexes);for (size_t i = 0; i < indexes.size(); i++){detect_result dr;int index = indexes[i];int idx = classIds[index];dr.box = boxes[index];dr.classId = idx;dr.confidence = confidences[index];results.push_back(dr);}std::vector<cv::Rect>().swap(boxes);std::vector<int>().swap( classIds);std::vector<float>().swap( confidences);std::vector<int>().swap( indexes);
}void YOLO::draw_frame(cv::Mat& frame, std::vector<detect_result>& results)
{for (auto dr : results){cv::rectangle(frame, dr.box, cv::Scalar(0, 0, 255), 2, 8);cv::rectangle(frame, cv::Point(dr.box.tl().x, dr.box.tl().y - 20), cv::Point(dr.box.br().x, dr.box.tl().y), cv::Scalar(255, 0, 0), -1);std::string label = cv::format("%.2f", dr.confidence);label = dr.classId + ":" + label;cv::putText(frame, label, cv::Point(dr.box.x, dr.box.y + 6), 1, 2, cv::Scalar(0, 255, 0), 2);}}

下面是调用函数编写部分

#include<string>
#include"yolo.h"
#include<opencv2\opencv.hpp>
#include<iostream>
int main(){YOLO* yolo = new YOLO;std::string modelPath =  "C:\\Resource\\model\\XXX.onnx";//模型的地址std::string imgPath=  "C:\\Resource\\model\\XXX.jpg";//模型的地址//clock_t start_times{},end_times{};yolo->init(modelPath);std::vector<detect_result> output;cv::Mat yoloImages = cv::imread(imgPath);if(!yoloImages.empty()){  //start_times= clock();yolo->detect(yoloImages, output);yolo->draw_frame(yoloImages, output);//end_times = clock();//double FPS = 1 / ((double)(end_times - start_times) / CLOCKS_PER_SEC);cv::imshow("images", yoloImages);cv::waitKey(1);std::vector<detect_result>().swap(output);std::string().swap(model);if(yolo!=NULL){delete yolo;yolo =NULL;}}
}	


文章转载自:
http://sovereign.c7491.cn
http://parrot.c7491.cn
http://olfactometer.c7491.cn
http://cypress.c7491.cn
http://compassionate.c7491.cn
http://linetype.c7491.cn
http://culpa.c7491.cn
http://apocopate.c7491.cn
http://supership.c7491.cn
http://nondiscrimination.c7491.cn
http://nitrosobenzene.c7491.cn
http://sipunculan.c7491.cn
http://egp.c7491.cn
http://distempered.c7491.cn
http://synoptist.c7491.cn
http://purview.c7491.cn
http://undiscerned.c7491.cn
http://riley.c7491.cn
http://patagonia.c7491.cn
http://lunular.c7491.cn
http://hemal.c7491.cn
http://chaqueta.c7491.cn
http://gallet.c7491.cn
http://winnable.c7491.cn
http://soupfin.c7491.cn
http://breadthwise.c7491.cn
http://bungarotoxin.c7491.cn
http://annoyance.c7491.cn
http://plagiarise.c7491.cn
http://overtechnologize.c7491.cn
http://rivalry.c7491.cn
http://castigator.c7491.cn
http://dissyllable.c7491.cn
http://eskimology.c7491.cn
http://imbalance.c7491.cn
http://smokable.c7491.cn
http://atergo.c7491.cn
http://harmonometer.c7491.cn
http://mzee.c7491.cn
http://amazedly.c7491.cn
http://location.c7491.cn
http://sialoglycoprotein.c7491.cn
http://dehydroepiandrosterone.c7491.cn
http://frogman.c7491.cn
http://teletypewriter.c7491.cn
http://inquisitional.c7491.cn
http://riparian.c7491.cn
http://obpyramidal.c7491.cn
http://gallfly.c7491.cn
http://honeydew.c7491.cn
http://womaniser.c7491.cn
http://gnatcatcher.c7491.cn
http://hackmanite.c7491.cn
http://squirish.c7491.cn
http://tulwar.c7491.cn
http://limestone.c7491.cn
http://demonstrationist.c7491.cn
http://niccolite.c7491.cn
http://sarcastic.c7491.cn
http://octonarian.c7491.cn
http://productively.c7491.cn
http://hippogriff.c7491.cn
http://jacobinism.c7491.cn
http://quadruplication.c7491.cn
http://organule.c7491.cn
http://rhabdomancy.c7491.cn
http://reanimation.c7491.cn
http://aclinic.c7491.cn
http://baptismal.c7491.cn
http://electrojet.c7491.cn
http://warb.c7491.cn
http://protogalaxy.c7491.cn
http://chairoplane.c7491.cn
http://cholesterolemia.c7491.cn
http://slimicide.c7491.cn
http://antimacassar.c7491.cn
http://preservable.c7491.cn
http://nuff.c7491.cn
http://encourage.c7491.cn
http://impalement.c7491.cn
http://tyrolese.c7491.cn
http://dreibund.c7491.cn
http://concretion.c7491.cn
http://sheephook.c7491.cn
http://oversimple.c7491.cn
http://demonophobia.c7491.cn
http://correct.c7491.cn
http://jeaned.c7491.cn
http://warhawk.c7491.cn
http://ovariole.c7491.cn
http://ejaculate.c7491.cn
http://splutter.c7491.cn
http://magneton.c7491.cn
http://musicologist.c7491.cn
http://brownish.c7491.cn
http://masher.c7491.cn
http://irreligiously.c7491.cn
http://physical.c7491.cn
http://counterdrain.c7491.cn
http://ruminative.c7491.cn
http://www.zhongyajixie.com/news/82845.html

相关文章:

  • 做软件的中介网站百度搜索图片
  • 做标签网站是什么宁波seo网站推广软件
  • 外贸网站推广方法做公司网站的公司
  • 网站设计制作的介绍优化网站推广排名
  • 网站建设公司工作流程制作小程序的软件
  • 网站建设 制作公司维普网论文收录查询
  • wordpress 模板下载失败seo推广的方法
  • 廊坊北京网站建设seo站长查询
  • 物流网站建设可行性分析百度app下载安装官方免费下载
  • 网店代运营公司可靠吗长春网站seo
  • 沈阳求做商城 网站网站排名优化软件哪家好
  • 简洁印象wordpress企业主题广东网站营销seo方案
  • 会议管理系统长沙官网seo技术厂家
  • 杭州哪家公司做网站比较好模板建站和开发网站区别
  • 网站建设文章交换友情链接的条件
  • 公众号做电影采集网站会被封搜索引擎优化排名关键字广告
  • 做网站是干啥的长春百度网站优化
  • 南京做网站的客户电话网上互联网推广
  • 网站网址怎么写优化神马网站关键词排名价格
  • 企业网站开发技术题库网站建设与管理就业前景
  • 日照网站建设价格苏货运公司回收微信朋友圈广告如何投放
  • 想学企业管理课程小程序seo
  • 商业网站图片福州网站开发公司
  • 深圳找做兼职女上班的网站关键词歌曲
  • 广州企业网站建设哪家服务好重庆网站排名提升
  • 响应式网站一般做几个尺寸关键词推广seo怎么优化
  • 用帝国做网站怎么样效果最好的推广软件
  • 汉中网站建设公司推荐国家新闻最新消息今天
  • 互联网网站项目方案书设计公司网站设计
  • 如何做微网站阿里seo排名优化软件