Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soundofwood
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Geisler
soundofwood
Commits
be65da18
Commit
be65da18
authored
3 years ago
by
dronus
Browse files
Options
Downloads
Patches
Plain Diff
output roughness, more parameters configurable (cropping etc.)
parent
62a4dd44
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
conf.json
+5
-1
5 additions, 1 deletion
conf.json
linescan.py
+9
-9
9 additions, 9 deletions
linescan.py
with
14 additions
and
10 deletions
conf.json
+
5
−
1
View file @
be65da18
{
"camera_warmup_time"
:
2.5
,
"resolution"
:
[
640
,
480
],
"y_min"
:
300
,
"y_max"
:
465
,
"fps"
:
40
,
"shutter_milliseconds"
:
6
,
"contrast_limit"
:
3.0
,
...
...
@@ -9,7 +11,9 @@
"removed_top_bins"
:
3
,
"pitch_min"
:
0
,
"pitch_step"
:
1
,
"laser_threshold"
:
165
,
"height_scale"
:
5
,
"width_scale"
:
0.5
"width_scale"
:
0.5
,
"roughness_scale"
:
5.0
}
This diff is collapsed.
Click to expand it.
linescan.py
+
9
−
9
View file @
be65da18
...
...
@@ -66,12 +66,12 @@ while True:
# crop down to some rectangular bar used for processing
# cropped_frame=frame[100:280,0:640]
cropped_frame
=
frame
[
0
:
480
,
0
:
640
]
cropped_frame
=
frame
[
conf
[
'
y_min
'
]:
conf
[
'
y_max
'
],
5
:
-
5
]
# histogram output
# crop single line for color histogram output
line_frame
=
cropped_frame
[
140
:
141
,
5
:
635
]
# crop single line
near bottom
for color histogram output
line_frame
=
cropped_frame
[
-
2
:
-
1
,:
]
# compute b/w histogram
line_frame
=
cv2
.
cvtColor
(
line_frame
,
cv2
.
COLOR_BGR2GRAY
)
histogram
=
np
.
zeros
(
histogram_steps
,
dtype
=
np
.
uint16
)
...
...
@@ -93,10 +93,8 @@ while True:
# gather depth data from a laser line projection
gray
=
cv2
.
cvtColor
(
cropped_frame
,
cv2
.
COLOR_BGR2GRAY
)
grad_y
=
cv2
.
Sobel
(
gray
,
cv2
.
CV_8U
,
0
,
2
,
ksize
=
5
,
scale
=-
.
1
,
delta
=
0
,
borderType
=
cv2
.
BORDER_DEFAULT
)
_
,
laser
=
cv2
.
threshold
(
grad_y
,
165
,
255
,
cv2
.
THRESH_BINARY
)
_
,
laser
=
cv2
.
threshold
(
grad_y
,
conf
[
'
laser_threshold
'
]
,
255
,
cv2
.
THRESH_BINARY
)
weights
=
np
.
arange
(
laser
.
shape
[
0
],
dtype
=
float
)
laser
[
0
:
400
][
0
:
640
]
=
0
laser
[
478
:
480
][
0
:
640
]
=
0
weighted
=
np
.
tensordot
(
laser
,
weights
,[[
0
],[
0
]])
count
=
np
.
sum
(
laser
.
astype
(
float
),
0
)
...
...
@@ -108,16 +106,18 @@ while True:
baseline
=
np
.
percentile
(
depths
,
95
)
depths
=
depths
[
depths
<
baseline
-
2
]
depth_min
=
np
.
min
(
depths
)
depth_min
=
np
.
percentile
(
depths
,
5
)
depth_mean
=
np
.
mean
(
depths
)
depth_width
=
np
.
sum
(
depths
>
0
)
depth_height
=
baseline
-
depth_mean
depth_roughness
=
np
.
std
(
depths
)
print
(
"
baseline
"
+
str
(
baseline
)
+
"
min
"
+
str
(
depth_min
)
+
"
mean
"
+
str
(
depth_mean
)
+
"
width
"
+
str
(
depth_width
)
+
"
height
"
+
str
(
depth_height
)
)
print
(
"
baseline
"
+
str
(
baseline
)
+
"
min
"
+
str
(
depth_min
)
+
"
mean
"
+
str
(
depth_mean
)
+
"
width
"
+
str
(
depth_width
)
+
"
height
"
+
str
(
depth_height
)
+
"
roughness
"
+
str
(
depth_roughness
))
# send out mean width and height of the scanned pieces by MIDI CC 64 and 65.
midi_output_queue
.
append
(((
0xB
<<
4
),
64
,
int
(
depth_height
*
conf
[
'
height_scale
'
])))
midi_output_queue
.
append
(((
0xB
<<
4
),
65
,
int
(
depth_width
*
conf
[
'
width_scale
'
])))
midi_output_queue
.
append
(((
0xB
<<
4
),
66
,
int
(
depth_roughness
*
conf
[
'
roughness_scale
'
])))
# impaint max to laser image (preview)
laser
[
int
(
baseline
+
1
)][:]
=
100
...
...
@@ -127,7 +127,7 @@ while True:
cv2
.
imshow
(
"
laser
"
,
laser
)
# if the `q` key is pressed, break from the lop
key
=
cv2
.
waitKey
(
1
)
&
0xFF
key
=
cv2
.
waitKey
(
1
0
)
&
0xFF
if
key
==
ord
(
"
q
"
):
break
...
...
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