Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pt2d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
QIM
Tools
pt2d
Commits
fe1915fe
Commit
fe1915fe
authored
2 months ago
by
Christian
Browse files
Options
Downloads
Patches
Plain Diff
Now exports path as csv with correct labelling of points
parent
b50c1a85
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GUI_draft_live.py
+40
-7
40 additions, 7 deletions
GUI_draft_live.py
with
40 additions
and
7 deletions
GUI_draft_live.py
+
40
−
7
View file @
fe1915fe
import
sys
import
math
import
csv
# <-- Added
import
numpy
as
np
# For smoothing the path
...
...
@@ -778,8 +779,6 @@ class AdvancedSettingsWidget(QWidget):
Shows toggle rainbow, circle editor, line smoothing slider, contrast slider,
plus two image previews (contrasted-blurred and cost).
The images should maintain aspect ratio upon resize.
Now displays the images stacked vertically with labels above them.
"""
def
__init__
(
self
,
main_window
,
parent
=
None
):
super
().
__init__
(
parent
)
...
...
@@ -1114,21 +1113,55 @@ class MainWindow(QMainWindow):
return
gray
def
export_path
(
self
):
"""
Exports the path as a CSV in the format: x, y, TYPE,
ensuring that each anchor influences exactly one path point.
"""
full_xy
=
self
.
image_view
.
get_full_path_xy
()
if
not
full_xy
:
print
(
"
No path to export.
"
)
return
# We'll consider each anchor point as "USER-PLACED".
# But unlike a distance-threshold approach, we assign each anchor
# to exactly one closest path point.
anchor_points
=
self
.
image_view
.
anchor_points
# For each anchor, find the index of the closest path point
user_placed_indices
=
set
()
for
ax
,
ay
in
anchor_points
:
min_dist
=
float
(
'
inf
'
)
closest_idx
=
None
for
i
,
(
px
,
py
)
in
enumerate
(
full_xy
):
dist
=
math
.
hypot
(
px
-
ax
,
py
-
ay
)
if
dist
<
min_dist
:
min_dist
=
dist
closest_idx
=
i
if
closest_idx
is
not
None
:
user_placed_indices
.
add
(
closest_idx
)
# Ask user for the CSV filename
options
=
QFileDialog
.
Options
()
file_path
,
_
=
QFileDialog
.
getSaveFileName
(
self
,
"
Export Path
"
,
""
,
"
NumPy
Files (*.
npy
);;All Files (*)
"
,
"
CSV
Files (*.
csv
);;All Files (*)
"
,
options
=
options
)
if
file_path
:
arr
=
np
.
array
(
full_xy
)
np
.
save
(
file_path
,
arr
)
print
(
f
"
Exported path with
{
len
(
arr
)
}
points to
{
file_path
}
"
)
if
not
file_path
:
return
import
csv
with
open
(
file_path
,
'
w
'
,
newline
=
''
)
as
csvfile
:
writer
=
csv
.
writer
(
csvfile
)
writer
.
writerow
([
"
x
"
,
"
y
"
,
"
TYPE
"
])
for
i
,
(
x
,
y
)
in
enumerate
(
full_xy
):
ptype
=
"
USER-PLACED
"
if
i
in
user_placed_indices
else
"
PATH
"
writer
.
writerow
([
x
,
y
,
ptype
])
print
(
f
"
Exported path with
{
len
(
full_xy
)
}
points to
{
file_path
}
"
)
def
clear_points
(
self
):
self
.
image_view
.
clear_guide_points
()
...
...
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