ProcessAnnotatedFile
abstract class ProcessAnnotatedFile extends GenerateFeatureVectors
Traits
Properties
int | $maxRedispatchTries | The maximum number of times the job may be redispatched. |
|
int | $tries | The number of times the job may be attempted. |
|
protected bool | $deleteWhenMissingModels | Ignore this job if the annotation does not exist any more. |
Methods
Get the bounding box of an annotation
Modify a bounding box so it adheres to the aspect ratio given by width and height.
Adjust the position and size of the box so it is contained in a box with the given dimensions.
Get the bounding box of a point annotation.
Get the bounding box of a circle annotation.
Get the bounding box of an annotation that is no point, circle or whole frame.
Generate the input for the python script.
Generator to read the output CSV row by row.
Create a new job instance.
Assemble the target path for an annotation patch.
Execute the job.
Determine if the job should give up trying because the error will likely not be fixed the next time.
Determine if this job should retry instead of fail after an exception
Generate and upload annotation SVGs for the file.
Generates feature vectors for the specified annotations belonging to the file of this job. This method either creates new feature vector models or updates the existing ones for the annotations.
Create the feature vectors based on the Python script output.
Get the query builder for the annotations (maybe filtered by IDs).
Get an SVG rectangle element.
Get an SVG ellipse element.
Computes angle between two vectors
Dispatch a copy of this job with a delay.
Details
in
GenerateFeatureVectors at line 21
array
getAnnotationBoundingBox(array $points, Shape $shape, int $pointPadding = 112, int $boxPadding = 0, int $minSize = 32)
Get the bounding box of an annotation
in
GenerateFeatureVectors at line 70
array
ensureBoxAspectRatio(array $box, int $aspectWidth, int $aspectHeight)
Modify a bounding box so it adheres to the aspect ratio given by width and height.
in
GenerateFeatureVectors at line 108
makeBoxContained(array $box, int|null $maxWidth, int|null $maxHeight)
Adjust the position and size of the box so it is contained in a box with the given dimensions.
in
GenerateFeatureVectors at line 134
protected array
getPointBoundingBox(array $points, int $padding)
Get the bounding box of a point annotation.
in
GenerateFeatureVectors at line 147
protected array
getCircleBoundingBox(array $points)
Get the bounding box of a circle annotation.
in
GenerateFeatureVectors at line 160
protected array
getPolygonBoundingBox(array $points)
Get the bounding box of an annotation that is no point, circle or whole frame.
in
GenerateFeatureVectors at line 180
protected array
makeBoxIntegers(array $box)
Round and cast box values to int.
in
GenerateFeatureVectors at line 194
protected array
generateInput(array $files, array $paths, Collection $annotations)
Generate the input for the python script.
in
GenerateFeatureVectors at line 211
protected array
generateFileInput(VolumeFile $file, Collection $annotations)
No description
in
GenerateFeatureVectors at line 246
protected
python(string $inputPath, string $outputPath)
Run the Python command.
in
GenerateFeatureVectors at line 262
protected Generator
readOutputCsv(string $path)
Generator to read the output CSV row by row.
at line 78
__construct(VolumeFile $file, array $only = [], bool $skipPatches = false, bool $skipFeatureVectors = false, bool $skipSvgs = false, string|null $targetDisk = null, int $redispatchTries = 0)
Create a new job instance.
at line 93
static string
getTargetPath(Annotation $annotation, string|null $format = null)
Assemble the target path for an annotation patch.
at line 113
void
handle()
Execute the job.
at line 157
abstract
handleFile(VolumeFile $file, string $path)
Handle a single file.
at line 165
protected bool
shouldGiveUpAfterException(Exception $e)
Determine if the job should give up trying because the error will likely not be fixed the next time.
at line 196
protected bool
shouldRetryAfterException(Exception $e)
Determine if this job should retry instead of fail after an exception
at line 216
void
createSvgs()
Generate and upload annotation SVGs for the file.
at line 227
protected void
createSvg(Annotation $annotation)
Generate and upload an SVG for the annotation.
at line 267
protected string
getAnnotationPatch(Image $image, array $points, Shape $shape)
Get the annotation patch as buffer.
at line 299
protected void
generateFeatureVectors(Collection $annotations, array|string $filePath)
Generates feature vectors for the specified annotations belonging to the file of this job. This method either creates new feature vector models or updates the existing ones for the annotations.
at line 359
abstract protected void
updateOrCreateFeatureVectors(Collection $annotations, Generator $output)
Create the feature vectors based on the Python script output.
at line 366
abstract protected Builder
getAnnotationQuery(VolumeFile $file)
Get the query builder for the annotations (maybe filtered by IDs).
at line 377
protected SVGNodeContainer
getSVGAnnotation(array $points, Shape $shape)
Draw annotation as SVG
at line 432
protected SVGRect
getRectangleSvgAnnotation(array $tuples)
Get an SVG rectangle element.
at line 453
protected SVGEllipse
getEllipseSvgAnnotation(array $tuples)
Get an SVG ellipse element.
at line 481
protected float
computeRotationAngle(array $v, array $u)
Computes angle between two vectors
at line 512
protected array
getOrientedCoordinates(array $tuples, Shape $shape)
Determines position of coordinate
at line 538
protected void
redispatch()
Dispatch a copy of this job with a delay.