-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextracted_script_calls.R
206 lines (160 loc) · 6.15 KB
/
extracted_script_calls.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
library(reticulate)
library(tesseract)
workingDir = "D:/dd/distribution_digitizer/"
outDir = "D:/test/output_2025-01-21_09-19-54/"
config <- read.csv(paste0(workingDir,"/config/config.csv"),header = TRUE, sep = ';')
outDir = config$dataOutputDir
fname=paste0(workingDir, "/", "src/matching/map_matching.py")
print("The processing template matching python script:")
print(fname)
source_python(fname)
print("Threshold:")
print(2)
print(outDir)
main_template_matching(workingDir, outDir, 0.2, config$sNumberPosition, config$matchingType)
# align
fname=paste0(workingDir, "/", "src/matching/map_align.py")
print("Processing align python script:")
print(fname)
source_python(fname)
align_images_directory(workingDir, outDir)
# point_matching
fname=paste0(workingDir, "/", "src/matching/point_matching.py")
print(" Processing point python script:")
print(fname)
source_python(fname)
map_points_matching(workingDir, outDir, 0.7)
#point_filtering
fname=paste0(workingDir, "/", "src/matching/point_filtering.py")
fname2 = paste0(workingDir, "/", "src/matching/coords_to_csv.py")
print(" Process pixel filtering python script:")
print(fname)
source_python(fname)
source_python(fname2)
main_point_filtering(workingDir, outDir, 5, 9)
# circle_detection
fname=paste0(workingDir, "/", "src/matching/circle_detection.py")
#fname2 = paste0(workingDir, "/", "src/matching/coords_to_csv.py")
print("Processing circle detection python script:")
print(fname)
source_python(fname)
#source_python(fname2)
print(outDir)
gaussian <- 9L
minDist <- 5L
thresholdEdge <- 50L
thresholdCircles <- 30L
minRadius <- 10L
maxRadius <- 40L
# Aufruf der Funktion
mainCircleDetection(workingDir, outDir, gaussian, minDist, thresholdEdge, thresholdCircles, minRadius, maxRadius)
# masking
fname=paste0(workingDir, "/", "src/masking/masking.py")
print(" Process masking normale python script:")
print(fname)
source_python(fname)
mainGeomask(workingDir, outDir, 5L)
fname=paste0(workingDir, "/", "src/masking/creating_masks.py")
print(" Process masking black python script:")
print(fname)
source_python(fname)
mainGeomaskB(workingDir, outDir, 5L)
# mask_centroids
fname=paste0(workingDir, "/", "src/masking/mask_centroids.py")
print(" Process masking Centroids python script:")
print(fname)
source_python(fname)
MainMaskCentroids(workingDir, outDir)
# Cropping
fname <- paste0(workingDir, "/", "src/read_species/map_read_species.R")
print("Croping the species names from the map botton R script:")
print(fname)
source(fname)
species <- read_legends(workingDir, outDir)
cat("\nSuccessfully executed")
# read Titles
fname <- paste0(workingDir, "/", "src/read_species/page_read_species.R")
print(paste0("Reading page species data and saving the results to a 'pageSpeciesData.csv' file in the ", outDir, " directory"))
source(fname)
if (length(config$keywordReadSpecies) > 0) {
species <- readPageSpecies(workingDir, outDir, config$keywordReadSpecies, config$keywordBefore, config$keywordThen, config$middle)
} else {
species <- readPageSpecies(workingDir, outDir, 'None', config$keywordBefore, config$keywordThen, config$middle)
}
# processing georeferencing
fname=paste0(workingDir, "/", "src/georeferencing/mask_georeferencing.py")
print(" Process georeferencing python script:")
print(fname)
source_python(fname)
# mainmaskgeoreferencingMaps(workingDir, outDir)
#mainmaskgeoreferencingMaps_CD(workingDir, outDir)
#mainmaskgeoreferencingMasks(workingDir, outDir)
#mainmaskgeoreferencingMasks_CD(workingDir, outDir)
mainmaskgeoreferencingMasks_PF(workingDir, outDir)
# processing rectifying
fname=paste0(workingDir, "/", "src/polygonize/rectifying.py")
print(" Process rectifying python script:")
print(fname)
source_python(fname)
#mainRectifying_Map_PF(workingDir, outDir)
#mainRectifying(workingDir, outDir)
#mainRectifying_CD(workingDir, outDir)
mainRectifying_PF(workingDir, outDir)
#outDir = "D:/test/output_2024-08-05_15-38-45/"
#findTemplateResult = paste0(outDir, "/georeferencing/maps/circleDetection/")
#files <- list.files(findTemplateResult, full.names = TRUE, recursive = FALSE)
#countFiles <- paste0(length(files), "")
# processing polygonize
fname=paste0(workingDir, "/", "src/polygonize/polygonize.py")
print(" Process polygonizing python script:")
print(fname)
source_python(fname)
#mainPolygonize(workingDir, outDir)
#mainPolygonize_Map_PF(workingDir, outDir)
#mainPolygonize_CD(workingDir, outDir)
mainPolygonize_PF(workingDir, outDir)
# merge_spatial
source(paste0(workingDir, "/src/spatial_view/merge_spatial_final_data.R"))
mergeFinalData(workingDir, outDir)
# Funktion zum Kombinieren der spatial_final_data.csv Dateien und Hinzufügen einer fortlaufenden ID-Spalte
combineAllMaps <- function(outDir1, outDir2, outputDir) {
tryCatch(
{
# Pfade zu den CSV-Dateien
csv_path1 <- file.path(outDir1, "spatial_final_data.csv")
csv_path2 <- file.path(outDir2, "spatial_final_data.csv")
output_csv_path <- file.path(outputDir, "final_all_maps.csv")
# CSV-Dateien einlesen
df1 <- read.csv2(csv_path1, stringsAsFactors = FALSE)
df2 <- read.csv2(csv_path2, stringsAsFactors = FALSE)
# Beide DataFrames zusammenfügen (einfaches Anhängen)
combined_df <- bind_rows(df1, df2)
# Fortlaufende ID-Spalte hinzufügen
combined_df <- combined_df %>%
mutate(ID = row_number())
# ID-Spalte an die erste Stelle verschieben
combined_df <- combined_df %>%
dplyr::select(ID, everything())
# Die neue CSV-Datei schreiben
write.csv2(combined_df, output_csv_path, row.names = FALSE)
print(paste("Final combined CSV file with ID created at:", output_csv_path))
},
error = function(e) {
print(e)
},
finally = {
cat("\nSuccessfully executed")
}
)
}
# Beispiel für den Aufruf der Funktion
# outDir1 <- "D:/test/output_2024-08-07_15-46-48"
# outDir2 <- "D:/test/output_2024-08-08_12-30-25"
# outputDir <- "D:/test/final_output"
# combineAllMaps(outDir1, outDir2, outputDir)
# Aufrufen der Funktion mit den angegebenen Arbeitsverzeichnissen
# Beispiel:
outDir1 <- "D:/test/output_2024-08-12_15-21-09/"
outDir2 <- "D:/test/map_1/"
outputDir <- "D:/test/"
combineAllMaps(outDir1, outDir2, outputDir)