#include #include #include #include #include #include int main() { // 创建YOLOV5检测器 migraphxSamples::DetectorYOLOV5 detector; migraphxSamples::InitializationParameterOfDetector initParamOfDetectorYOLOV5; initParamOfDetectorYOLOV5.configFilePath = CONFIG_FILE; migraphxSamples::ErrorCode errorCode=detector.Initialize(initParamOfDetectorYOLOV5); if(errorCode!=migraphxSamples::SUCCESS) { LOG_ERROR(stdout, "fail to initialize detector!\n"); exit(-1); } LOG_INFO(stdout, "succeed to initialize detector\n"); // 读取测试图像 std::vector srcImages; cv::String folder = "../Resource/Images/DynamicPics"; std::vector imagePathList; cv::glob(folder,imagePathList); for (int i = 0; i < imagePathList.size(); ++i) { cv:: Mat srcImage=cv::imread(imagePathList[i], 1); srcImages.push_back(srcImage); } // 设置动态推理shape std::vector> inputShapes; inputShapes.push_back({1,3,416,416}); inputShapes.push_back({1,3,608,608}); for (int i = 0; i < srcImages.size(); ++i) { // 推理 std::vector predictions; double time1 = cv::getTickCount(); detector.Detect(srcImages[i], inputShapes[i], predictions); double time2 = cv::getTickCount(); double elapsedTime = (time2 - time1)*1000 / cv::getTickFrequency(); LOG_INFO(stdout, "inference image%d time:%f ms\n", i, elapsedTime); // 获取推理结果 LOG_INFO(stdout,"========== Detection Image%d Results ==========\n", i); for(int j=0;j