ProcessAnnotatedImage
class ProcessAnnotatedImage extends ProcessAnnotatedFile
Traits
Constants
CROP_MAX_EDGE_PX |
Python PIL accepts images with at most 178956970 pixels. We set this arbitrary
maximum dimension so the limit is not reached and feature vector computation
does not consume a ridiculous amount of memory. |
Properties
int | $maxRedispatchTries | The maximum number of times the job may be redispatched. |
from ProcessAnnotatedFile |
int | $tries | The number of times the job may be attempted. |
from ProcessAnnotatedFile |
protected bool | $deleteWhenMissingModels | Ignore this job if the annotation does not exist any more. |
from ProcessAnnotatedFile |
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.
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
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
Get the vips image instance.
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.
in
ProcessAnnotatedFile 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.
in
ProcessAnnotatedFile at line 93
static string
getTargetPath(Annotation $annotation, string|null $format = null)
Assemble the target path for an annotation patch.
in
ProcessAnnotatedFile at line 113
void
handle()
Execute the job.
at line 30
handleFile(VolumeFile $file, string $path)
Handle a single file.
in
ProcessAnnotatedFile 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.
in
ProcessAnnotatedFile at line 196
protected bool
shouldRetryAfterException(Exception $e)
Determine if this job should retry instead of fail after an exception
in
ProcessAnnotatedFile at line 216
void
createSvgs()
Generate and upload annotation SVGs for the file.
in
ProcessAnnotatedFile at line 227
protected void
createSvg(Annotation $annotation)
Generate and upload an SVG for the annotation.
in
ProcessAnnotatedFile at line 267
protected string
getAnnotationPatch(Image $image, array $points, Shape $shape)
Get the annotation patch as buffer.
at line 92
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 68
protected void
updateOrCreateFeatureVectors(Collection $annotations, Generator $output)
Create the feature vectors based on the Python script output.
at line 187
protected Builder
getAnnotationQuery(VolumeFile $file)
Get the query builder for the annotations (maybe filtered by IDs).
in
ProcessAnnotatedFile at line 377
protected SVGNodeContainer
getSVGAnnotation(array $points, Shape $shape)
Draw annotation as SVG
in
ProcessAnnotatedFile at line 432
protected SVGRect
getRectangleSvgAnnotation(array $tuples)
Get an SVG rectangle element.
in
ProcessAnnotatedFile at line 453
protected SVGEllipse
getEllipseSvgAnnotation(array $tuples)
Get an SVG ellipse element.
in
ProcessAnnotatedFile at line 481
protected float
computeRotationAngle(array $v, array $u)
Computes angle between two vectors
in
ProcessAnnotatedFile at line 512
protected array
getOrientedCoordinates(array $tuples, Shape $shape)
Determines position of coordinate
in
ProcessAnnotatedFile at line 538
protected void
redispatch()
Dispatch a copy of this job with a delay.
at line 176
protected
getVipsImage(string $path, array $options = [])
Get the vips image instance.