Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
yolov5s_onnxruntime
Commits
166a5139
Commit
166a5139
authored
Dec 31, 2024
by
change
Browse files
init
parents
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
src/main.cpp
src/main.cpp
+10
-0
src/yolov5s.cpp
src/yolov5s.cpp
+43
-0
No files found.
src/main.cpp
0 → 100644
View file @
166a5139
#include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main
(
int
argc
,
char
*
argv
[])
{
Ort_DetectorYOLOV5
();
return
0
;
}
src/yolov5s.cpp
0 → 100644
View file @
166a5139
#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
;
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment