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 | $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 23
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 73
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 111
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 137
protected array
getPointBoundingBox(array $points, int $padding)
Get the bounding box of a point annotation.
in
GenerateFeatureVectors at line 150
protected array
getCircleBoundingBox(array $points)
Get the bounding box of a circle annotation.
in
GenerateFeatureVectors at line 163
protected array
getPolygonBoundingBox(array $points)
Get the bounding box of an annotation that is no point, circle or whole frame.
in
GenerateFeatureVectors at line 183
protected array
makeBoxIntegers(array $box)
Round and cast box values to int.
in
GenerateFeatureVectors at line 197
protected array
generateInput(array $files, array $paths, Collection $annotations)
Generate the input for the python script.
in
GenerateFeatureVectors at line 214
protected array
generateFileInput(VolumeFile $file, Collection $annotations)
No description
in
GenerateFeatureVectors at line 248
protected
python(string $inputPath, string $outputPath)
Run the Python command.
in
GenerateFeatureVectors at line 264
protected Generator
readOutputCsv(string $path)
Generator to read the output CSV row by row.
in
ProcessAnnotatedFile at line 64
__construct(VolumeFile $file, array $only = [], bool $skipPatches = false, bool $skipFeatureVectors = false, bool $skipSvgs = false, string|null $targetDisk = null)
Create a new job instance.
in
ProcessAnnotatedFile at line 83
static string
getTargetPath(Annotation $annotation, string|null $format = null)
Assemble the target path for an annotation patch.
in
ProcessAnnotatedFile at line 103
void
handle()
Execute the job.
at line 32
handleFile(VolumeFile $file, string $path)
Handle a single file.
in
ProcessAnnotatedFile at line 148
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 179
protected bool
shouldRetryAfterException(Exception $e)
Determine if this job should retry instead of fail after an exception
in
ProcessAnnotatedFile at line 199
void
createSvgs()
Generate and upload annotation SVGs for the file.
in
ProcessAnnotatedFile at line 210
protected void
createSvg(Annotation $annotation)
Generate and upload an SVG for the annotation.
in
ProcessAnnotatedFile at line 250
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 184
protected Builder
getAnnotationQuery(VolumeFile $file)
Get the query builder for the annotations (maybe filtered by IDs).
in
ProcessAnnotatedFile at line 358
protected SVGNodeContainer
getSVGAnnotation(array $points, Shape $shape)
Draw annotation as SVG
in
ProcessAnnotatedFile at line 412
protected SVGRect
getRectangleSvgAnnotation(array $tuples)
Get an SVG rectangle element.
in
ProcessAnnotatedFile at line 433
protected SVGEllipse
getEllipseSvgAnnotation(array $tuples)
Get an SVG ellipse element.
in
ProcessAnnotatedFile at line 461
protected float
computeRotationAngle(array $v, array $u)
Computes angle between two vectors
in
ProcessAnnotatedFile at line 492
protected array
getOrientedCoordinates(array $tuples, Shape $shape)
Determines position of coordinate
in
ProcessAnnotatedFile at line 518
protected void
redispatch()
Dispatch a copy of this job with a delay.
at line 175
protected
getVipsImage(string $path, array $options = [])
Get the vips image instance.