Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RoboQualityController
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
RoboCT (Public)
RoboQuality
RoboQualityController
Commits
f29feedf
Commit
f29feedf
authored
8 months ago
by
Simon Wittl
Browse files
Options
Downloads
Patches
Plain Diff
roi nn bug fix
parent
6e5b633e
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
example/volume_example.py
+9
-0
9 additions, 0 deletions
example/volume_example.py
rq_controller/common/region_of_intrest.py
+32
-2
32 additions, 2 deletions
rq_controller/common/region_of_intrest.py
with
41 additions
and
2 deletions
example/volume_example.py
+
9
−
0
View file @
f29feedf
from
rq_controller.common
import
PyVolume
from
rq_controller.common.io.rq_json
import
RqJsonWriter
,
RqJsonLoader
from
pathlib
import
Path
import
numpy
as
np
FOLDER
=
Path
(
'
./example/data
'
)
...
...
@@ -22,6 +23,14 @@ def main():
volume_3
=
loader
.
load_volume
(
writer
.
get_volume_save_path_i
(
FOLDER
,
1
))
print
(
f
'
Shape (x / y / z):
{
volume_3
.
shape
}
'
)
grid
=
volume_3
.
roi
.
get_grid
()
print
(
f
'
grid shape:
{
grid
.
shape
}
'
)
pos
=
volume_3
.
roi
.
next_neighbor
(
grid
,
np
.
array
([
0.
,
0.
,
0.
]))
print
(
pos
)
value
=
volume_3
.
array
[
pos
[
0
],
pos
[
1
],
pos
[
2
]]
print
(
value
)
if
__name__
==
'
__main__
'
:
main
()
...
...
This diff is collapsed.
Click to expand it.
rq_controller/common/region_of_intrest.py
+
32
−
2
View file @
f29feedf
from
__future__
import
annotations
import
numpy
as
np
from
rq_interfaces.msg
import
RegionOfIntrest
...
...
@@ -49,8 +51,7 @@ class PyRegionOfIntrest():
def
shape
(
self
)
->
tuple
:
shape
=
self
.
dimensions_mm
[
0
]
//
self
.
resolution_mm
[
0
]
return
(
int
(
shape
[
0
]),
int
(
shape
[
1
]),
int
(
shape
[
2
]))
def
as_message
(
self
)
->
RegionOfIntrest
:
message
=
RegionOfIntrest
()
roi_list
=
list
()
...
...
@@ -77,3 +78,32 @@ class PyRegionOfIntrest():
message
.
resolution
.
z
=
float
(
self
.
resolution_mm
[
0
][
2
])
return
message
def
get_grid
(
self
,
indice
:
int
=
0
)
->
np
.
ndarray
:
start
=
self
.
center_points_mm
[
indice
]
-
(
self
.
dimensions_mm
[
indice
]
/
2.
)
end
=
self
.
center_points_mm
[
indice
]
+
(
self
.
dimensions_mm
[
indice
]
/
2.
)
x_
=
np
.
linspace
(
start
[
0
],
end
[
0
],
self
.
shape
[
0
])
y_
=
np
.
linspace
(
start
[
1
],
end
[
1
],
self
.
shape
[
1
])
z_
=
np
.
linspace
(
start
[
2
],
end
[
2
],
self
.
shape
[
2
])
x
,
y
,
z
=
np
.
meshgrid
(
x_
,
y_
,
z_
,
indexing
=
'
ij
'
)
return
np
.
concatenate
((
np
.
expand_dims
(
x
,
-
1
),
np
.
expand_dims
(
y
,
-
1
),
np
.
expand_dims
(
z
,
-
1
)),
-
1
)
@staticmethod
def
next_neighbor
(
grid_mm
:
np
.
ndarray
,
point_mm
:
np
.
ndarray
)
->
np
.
ndarray
:
x
=
grid_mm
[:,
0
,
0
,
0
]
y
=
grid_mm
[
0
,
:,
0
,
1
]
z
=
grid_mm
[
0
,
0
,
:,
2
]
xx
=
int
(
np
.
argmin
((
x
-
point_mm
[
0
])
**
2
))
yy
=
int
(
np
.
argmin
((
y
-
point_mm
[
1
])
**
2
))
zz
=
int
(
np
.
argmin
((
z
-
point_mm
[
2
])
**
2
))
return
np
.
array
([
xx
,
yy
,
zz
],
dtype
=
np
.
int32
)
\ No newline at end of file
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