Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Pokedex
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
michael.divia
Pokedex
Commits
962ffb8f
Commit
962ffb8f
authored
3 weeks ago
by
michael.divia
Browse files
Options
Downloads
Patches
Plain Diff
Error on size of image
parent
10d74a43
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/pokedex_rpi.py
+12
-4
12 additions, 4 deletions
python/pokedex_rpi.py
with
12 additions
and
4 deletions
python/pokedex_rpi.py
+
12
−
4
View file @
962ffb8f
...
...
@@ -28,20 +28,28 @@ with open(json_path, "r") as f:
# --- Inference ---
with
Hailo
(
hef_path
)
as
hailo
:
model_h
,
model_w
,
_
=
hailo
.
get_input_shape
()
print
(
f
"
-- Hailo model input size:
{
model_w
}
x
{
model_h
}
"
)
# Initialize camera and configure MAIN output only (no preview)
picam2
=
Picamera2
()
# Use *raw* capture configuration with correct size
config
=
picam2
.
create_still_configuration
(
main
=
{
"
size
"
:
(
model_w
,
model_h
),
"
format
"
:
"
RGB888
"
},
display
=
None
# Disable preview stream to avoid tiny resolution
lores
=
None
,
display
=
None
)
picam2
.
configure
(
config
)
picam2
.
start
()
print
(
"
-- Capturing image...
"
)
frame
=
picam2
.
capture_array
()
print
(
f
"
-- Captured frame shape:
{
frame
.
shape
}
"
)
if
frame
.
shape
[
0
]
!=
model_h
or
frame
.
shape
[
1
]
!=
model_w
:
print
(
"
-- Frame shape doesn
'
t match model input size. Aborting.
"
)
exit
(
1
)
# Optional:
Show the captured
image
# Optional:
display
image
try
:
cv2
.
imshow
(
"
Captured Image
"
,
frame
)
print
(
"
-- Press any key to continue...
"
)
...
...
@@ -58,4 +66,4 @@ with Hailo(hef_path) as hailo:
predicted_idx
=
int
(
np
.
argmax
(
inference_results
))
predicted_name
=
class_names
[
predicted_idx
]
print
(
f
"
-- Predicted Pokémon:
{
predicted_name
}
"
)
\ No newline at end of file
print
(
f
"
-- Predicted Pokémon:
{
predicted_name
}
"
)
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