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
video_migraphx
Commits
f694ee43
Commit
f694ee43
authored
Nov 15, 2024
by
lijian6
Browse files
Add yolov7 multi thread.
Signed-off-by:
lijian
<
lijian6@sugon.com
>
parent
b10952cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
src/YOLOV7.cpp
src/YOLOV7.cpp
+25
-8
No files found.
src/YOLOV7.cpp
View file @
f694ee43
...
...
@@ -96,7 +96,9 @@ static void DecoderThreadFunc(Queue* queue)
memcpy
(
srcImage
.
data
+
decoder
.
frame
->
width
*
decoder
.
frame
->
height
,
(
unsigned
char
*
)
decoder
.
frame
->
data
[
1
],
decoder
.
frame
->
width
*
decoder
.
frame
->
height
/
4
);
memcpy
(
srcImage
.
data
+
decoder
.
frame
->
width
*
decoder
.
frame
->
height
*
5
/
4
,
(
unsigned
char
*
)
decoder
.
frame
->
data
[
2
],
decoder
.
frame
->
width
*
decoder
.
frame
->
height
/
4
);
cvtColor
(
srcImage
,
srcImage
,
COLOR_YUV420p2RGB
);
fprintf
(
stdout
,
"Decode enQueue one frame start
\n
"
);
que
->
enQueue
(
srcImage
);
fprintf
(
stdout
,
"Decode enQueue one frame end
\n
"
);
}
if
(
que
->
device
==
_HW
||
que
->
device
==
_HW_DMA
)
{
...
...
@@ -309,16 +311,31 @@ static void DetectorThreadFunc(Queue* que)
void
Sample_DetectorYOLOV7
(
int
device
)
{
Queue
*
queue
=
new
Queue
(
1
);
queue
->
device
=
device
;
int
numThread
=
5
;
std
::
vector
<
Queue
*>
queues
;
std
::
vector
<
std
::
thread
>
threadsDecoder
;
std
::
vector
<
std
::
thread
>
threadsDetector
;
std
::
thread
ThreadDecoder
(
DecoderThreadFunc
,
queue
);
std
::
thread
ThreadDetector
(
DetectorThreadFunc
,
queue
);
for
(
int
i
=
0
;
i
<
numThread
;
++
i
)
{
Queue
*
queue
=
new
Queue
(
1
);
queues
.
push_back
(
queue
);
}
for
(
int
i
=
0
;
i
<
numThread
;
++
i
)
{
queues
[
i
]
->
device
=
device
;
threadsDecoder
.
emplace_back
(
DecoderThreadFunc
,
queues
[
i
]);
threadsDetector
.
emplace_back
(
DetectorThreadFunc
,
queues
[
i
]);
}
ThreadDecoder
.
join
();
ThreadDetector
.
join
();
for
(
auto
&
thread
:
threadsDecoder
)
{
thread
.
join
();
}
for
(
auto
&
thread
:
threadsDetector
)
{
thread
.
join
();
}
delete
queue
;
queue
=
NULL
;
for
(
auto
queue
:
queues
)
{
delete
queue
;
queue
=
NULL
;
}
return
;
}
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