RegionResource
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
|
create_new
Creates a new region resource. A region is a region of interest (ROI) in a StillImageRepresentation.
Exactly one geometry shape has to be added to the resource with one of the following methods:
add_rectangle
, add_polygon
, add_circle
(see documentation below for more information).
See XML documentation for details
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res_id
|
str
|
ID of this region resource |
required |
label
|
str
|
label of this region resource |
required |
region_of
|
str
|
ID of the image resource that this region refers to (cardinality 1) |
required |
permissions
|
Permissions
|
permissions of this region resource |
PROJECT_SPECIFIC_PERMISSIONS
|
Returns:
Type | Description |
---|---|
RegionResource
|
A region resource |
Examples:
region = xmllib.RegionResource.create_new(
res_id="ID",
label="label",
region_of="image_id",
)
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
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 |
|
add_rectangle
Add a rectangle shape to the region.
For a visual example see the XML documentation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point1
|
tuple[float, float]
|
first point of the rectangle represented as two numbers between 0 and 1 in the format (x, y) |
required |
point2
|
tuple[float, float]
|
second point of the rectangle represented as two numbers between 0 and 1 in the format (x, y) |
required |
line_width
|
float
|
A number in pixels between 1 - 5 |
2
|
color
|
str
|
A hexadecimal color value which starts with a |
'#5b24bf'
|
active
|
bool
|
If set to |
True
|
Returns:
Type | Description |
---|---|
RegionResource
|
Region with added rectangle |
Examples:
region = region.add_rectangle(
point1=(0.1, 0.1),
point2=(0.2, 0.2),
)
# with custom display values
region = region.add_rectangle(
point1=(0.1, 0.1),
point2=(0.2, 0.2),
line_width=3,
color="#32a873",
)
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
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 |
|
add_polygon
Add a polygon shape to the region.
A polygon should have at least three points.
If you wish to create a rectangle, please use the designated add_rectangle
method.
For a visual example see the XML documentation
Please note that this cannot currently be displayed in the dsp-app.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
list[tuple[float, float]]
|
list of tuples containing two numbers between 0 and 1 in the format (x, y) |
required |
line_width
|
float
|
A number in pixels between 1 - 5 |
2
|
color
|
str
|
A hexadecimal color value which starts with a |
'#5b24bf'
|
active
|
bool
|
If set to |
True
|
Returns:
Type | Description |
---|---|
RegionResource
|
Region with added polygon |
Examples:
region = region.add_polygon(
points=[(0.1, 0.1), (0.2, 0.2), (0.3, 0.3)],
)
# with custom display values
region = region.add_polygon(
points=[(0.1, 0.1), (0.2, 0.2), (0.3, 0.3)],
line_width=3,
color="#32a873",
)
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
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 |
|
add_circle
Add a circle shape to the region.
For a visual example see the XML documentation
Please note that this cannot currently be displayed in the dsp-app.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center
|
tuple[float, float]
|
center of the circle, represented as two numbers between 0 and 1 in the format (x, y) |
required |
radius
|
tuple[float, float]
|
radius of the circle, represented as a 2-dimensional vector, i.e. two numbers between 0 and 1 in the format (x, y) |
required |
line_width
|
float
|
A number in pixels between 1 - 5 |
2
|
color
|
str
|
A hexadecimal color value which starts with a |
'#5b24bf'
|
active
|
bool
|
If set to |
True
|
Returns:
Type | Description |
---|---|
RegionResource
|
Region with added circle |
Examples:
region = region.add_circle(
center=(0.1, 0.1),
radius=(0.2, 0.2),
)
# with custom display values
region = region.add_circle(
center=(0.1, 0.1),
radius=(0.2, 0.2),
line_width=3,
color="#32a873",
)
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
add_comment
Add a comment to the region
Parameters:
Name | Type | Description | Default |
---|---|---|---|
comment
|
str
|
text |
required |
Returns:
Type | Description |
---|---|
RegionResource
|
The original region, with the added comment |
Examples:
region = region.add_comment("comment text")
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
add_comment_multiple
Add several comments to the region
Parameters:
Name | Type | Description | Default |
---|---|---|---|
comments
|
Collection[str]
|
list of texts |
required |
Returns:
Type | Description |
---|---|
RegionResource
|
The original region, with the added comments |
Examples:
region = region.add_comment_multiple(["comment 1", "comment 2"])
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
add_comment_optional
If the value is not empty, add it as comment, otherwise return the region unchanged.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
comment
|
Any
|
text or empty value |
required |
Returns:
Type | Description |
---|---|
RegionResource
|
The original region, with the added comment |
Examples:
region = region.add_comment_optional("comment text")
region = region.add_comment_optional(None)
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
add_migration_metadata
Add metadata from a SALSAH migration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
creation_date
|
str | None
|
creation date of the region in SALSAH |
required |
iri
|
str | None
|
Original IRI in SALSAH |
None
|
ark
|
str | None
|
Original ARK in SALSAH |
None
|
Returns:
Type | Description |
---|---|
RegionResource
|
The original region, with the added metadata |
Examples:
region = region.add_migration_metadata(
iri="http://rdfh.ch/4123/DiAmYQzQSzC7cdTo6OJMYA",
creation_date="1999-12-31T23:59:59.9999999+01:00"
)
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/dsp_base_resources.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|