#include #include #include #include #include #include using namespace std; using namespace cv; using namespace cv::dnn; using namespace migraphx; using namespace migraphxSamples; void Sample_DetectorYOLOV5() { // 创建YOLOV5检测器 DetectorYOLOV5 detector; InitializationParameterOfDetector initParamOfDetectorYOLOV5; initParamOfDetectorYOLOV5.parentPath = ""; initParamOfDetectorYOLOV5.configFilePath = CONFIG_FILE; initParamOfDetectorYOLOV5.logName = ""; ErrorCode errorCode=detector.Initialize(initParamOfDetectorYOLOV5); if(errorCode!=SUCCESS) { LOG_ERROR(stdout, "fail to initialize detector!\n"); exit(-1); } LOG_INFO(stdout, "succeed to initialize detector\n"); // 读取测试图片 Mat srcImage=imread("../Resource/Images/bus.jpg",1); // 推理 std::vector predictions; double time1 = getTickCount(); detector.Detect(srcImage,predictions); double time2 = getTickCount(); double elapsedTime = (time2 - time1)*1000 / getTickFrequency(); LOG_INFO(stdout, "inference time:%f ms\n", elapsedTime); // 获取推理结果 LOG_INFO(stdout,"========== Detection Results ==========\n"); for(int i=0;i