Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
food-round2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joel Joseph
food-round2
Commits
87d9ca49
Unverified
Commit
87d9ca49
authored
5 years ago
by
Kai Chen
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add webcam demo (#1150)
parent
cd6d617e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GETTING_STARTED.md
+16
-1
16 additions, 1 deletion
GETTING_STARTED.md
tools/webcam_demo.py
+38
-0
38 additions, 0 deletions
tools/webcam_demo.py
with
54 additions
and
1 deletion
GETTING_STARTED.md
+
16
−
1
View file @
87d9ca49
...
...
@@ -57,7 +57,22 @@ python tools/test.py configs/mask_rcnn_r50_fpn_1x.py \
8
--out
results.pkl
--eval
bbox segm
```
### High-level APIs for testing images.
### Webcam demo
We provide a webcam demo to illustrate the results.
```
shell
python tools/webcam_demo.py
${
CONFIG_FILE
}
${
CHECKPOINT_FILE
}
[
--device
${
GPU_ID
}
]
[
--camera-id
${
CAMERA
-ID
}
]
[
--score-thr
${
CAMERA
-ID
}
]
```
Examples:
```
shell
python tools/webcam_demo.py configs/faster_rcnn_r50_fpn_1x.py
\
checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth
```
### High-level APIs for testing images
Here is an example of building the model and test given images.
...
...
This diff is collapsed.
Click to expand it.
tools/webcam_demo.py
0 → 100644
+
38
−
0
View file @
87d9ca49
import
argparse
import
cv2
import
torch
from
mmdet.apis
import
inference_detector
,
init_detector
,
show_result
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
'
MMDetection webcam demo
'
)
parser
.
add_argument
(
'
config
'
,
help
=
'
test config file path
'
)
parser
.
add_argument
(
'
checkpoint
'
,
help
=
'
checkpoint file
'
)
parser
.
add_argument
(
'
--device
'
,
type
=
int
,
default
=
0
,
help
=
'
CUDA device id
'
)
parser
.
add_argument
(
'
--camera-id
'
,
type
=
int
,
default
=
0
,
help
=
'
camera device id
'
)
parser
.
add_argument
(
'
--score-thr
'
,
type
=
float
,
default
=
0.5
,
help
=
'
bbox score threshold
'
)
args
=
parser
.
parse_args
()
return
args
def
main
():
args
=
parse_args
()
model
=
init_detector
(
args
.
config
,
args
.
checkpoint
,
device
=
torch
.
device
(
'
cuda
'
,
args
.
device
))
camera
=
cv2
.
VideoCapture
(
args
.
camera_id
)
while
True
:
ret_val
,
img
=
camera
.
read
()
result
=
inference_detector
(
model
,
img
)
show_result
(
img
,
result
,
model
.
CLASSES
,
score_thr
=
args
.
score_thr
,
wait_time
=
1
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment