Commit 166a5139 authored by change's avatar change
Browse files

init

parents
#include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
Ort_DetectorYOLOV5();
return 0;
}
#include "main.h"
#include <sys/time.h>
#include "DetectorYOLOV5.h"
void Ort_DetectorYOLOV5()
{
const std::string modelPath = "../Resource/Models/Yolov5/yolov5s_b4.onnx";
const std::string keysPath = "../Resource/Models/Yolov5/coco.names";
DetectorYOLOV5 detector;
detector.setNumThread(1);
detector.setGpuIndex(0);
detector.initModel(modelPath, keysPath);
std::vector<int64_t> resize_shape = detector.getshape();
const int batch_size = 4;
// 注意路径后面的‘/’
std::string imagePath = "../Resource/Images/";
std::string _strPattern = imagePath + "*.jpg"; // test_images
std::vector<cv::String> imageNames;
cv::glob(_strPattern, imageNames);
std::vector<cv::Mat> imagebatch;
for (int i = 0; i < batch_size; i++)
{
cv::Mat image = cv::imread(imageNames[i], 1);
if (image.empty()) {
std::cout << "No image found.";
}
// cv::resize(image, image, cv::Size(width, height));
imagebatch.push_back(image);
}
double time1 = getTickCount();
detector.Detect(imagebatch, imageNames);
double time2 = getTickCount();
double elapsedTime = (time2 - time1)*1000 / getTickFrequency();
fprintf(stdout, "inference time: %.3f ms\n", elapsedTime);
return;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment