2023-08-03 12:35:45 来源 : 面包芯语
(资料图片)
#pragmaonce#ifdef_DLL_EXPORTS#defineDLL_API_declspec(dllexport)#else#defineDLL_API_declspec(dllimport)#endif#include //=========导出函数C++调用接口============classDLL_APIMyTestDLL{public:intaddData(inta,intb);~MyTestDLL();};
#define_DLL_EXPORTS#include MyTestDLL::~MyTestDLL(){std::cout<<"destoryinstancedone!"<
#include"opencv2/opencv.hpp"#include"mytest.h"intmain(intargc,char**argv){std::cout<<"testmydll..."<mydll(newMyTestDLL());intsum=mydll->addData(3,5);std::cout<<"DLLinvokeresult:"<
#include"yolov8_infer.h"#include#includestd::stringlabel_map="D:/python/yolov5-7.0/classes.txt";intmain(intargc,char**argv){std::stringnames="10:bike";intpos=names.find_first_of(":");std::cout<>"<classNames;std::ifstreamfp(label_map);std::stringname;while(!fp.eof()){getline(fp,name);if(name.length()){classNames.push_back(name);}}fp.close();//std::shared_ptrdetector(newYOLOv5ORTDetector()); std::shared_ptrdetector(newYOLOv8ORTDetector());detector->initConfig("D:/python/my_yolov8_train_demo/yolov8n.onnx",640,640,0.25f,0.5);cv::VideoCapturecapture("D:/images/video/sample.mp4");cv::Matframe;std::vectorresults;while(true){boolret=capture.read(frame);if(frame.empty()){break;}int64start=cv::getTickCount();detector->detect(frame,results);floatfps=static_cast(cv::getTickFrequency())/(cv::getTickCount()-start);cv::putText(frame,cv::format("FPS:%.2f",fps),cv::Point(50,50),cv::FONT_HERSHEY_SIMPLEX,1.0,cv::Scalar(255,0,255),2,8);for(DetectResultdr:results){cv::Rectbox=dr.box;cv::putText(frame,classNames[dr.classId],cv::Point(box.tl().x,box.tl().y-10),cv::FONT_HERSHEY_SIMPLEX,.5,cv::Scalar(0,0,0));}cv::imshow("YOLOv8+ONNXRUNTIME-DLL导出演示",frame);charc=cv::waitKey(1);if(c==27){//ESC退出break;}//resetfornextframeresults.clear();}return0;}
扫码查看 CV系统化学习路线图(OpenCV+Pytorch)