class InitializeFeatureVectorChunk extends GenerateFeatureVectors

Traits

InteractsWithQueue
Queueable
Dispatchable

Constants

DINO_PATCH_SIZE

Size of a square input patch for generating feature vectors with DINO.

Methods

array
getAnnotationBoundingBox(array $points, Shape $shape, int $pointPadding = self::DINO_PATCH_SIZE / 2, int $boxPadding = 0, int $minSize = 32)

Get the bounding box of an annotation

array
ensureBoxAspectRatio(array $box, int $aspectWidth, int $aspectHeight)

Modify a bounding box so it adheres to the aspect ratio given by width and height.

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.

array
getPointBoundingBox(array $points, int $padding)

Get the bounding box of a point annotation.

array
getCircleBoundingBox(array $points)

Get the bounding box of a circle annotation.

array
getPolygonBoundingBox(array $points)

Get the bounding box of an annotation that is no point, circle or whole frame.

array
makeBoxIntegers(array $box)

Round and cast box values to int.

array
generateAnnotationBoxes(VolumeFile $file, Collection $annotations)

No description

string
getCropBufferForPyworker(Image $image, array $box)

Get the byte string of the cropped and resized patch for the Python worker.

array
sendPyworkerRequest(string $buffer)

Send the PNG image crop to the Python worker and return the feature vector array.

__construct(array $imageAnnotationIds, array $videoAnnotationIds)

No description

handle()

No description

Collection
getInsertData(Collection $models)

Get the array to insert new feature vector models into the DB.

getFeatureVectors(Collection $models)

Generate feature vectors from the thumbnails of many annotations.

getVipsImageForPyworker(string $buffer)

Get the vips image instance for submission to the Python worker for feature vectors.

Details

array getAnnotationBoundingBox(array $points, Shape $shape, int $pointPadding = self::DINO_PATCH_SIZE / 2, int $boxPadding = 0, int $minSize = 32)

Get the bounding box of an annotation

Parameters

array $points
Shape $shape
int $pointPadding

The default is half the patch size of 224 that is expected by DINO.

int $boxPadding
int $minSize

Each side of the box should have at least this number of pixels. Must be divisible by 2.

Return Value

array

array ensureBoxAspectRatio(array $box, int $aspectWidth, int $aspectHeight)

Modify a bounding box so it adheres to the aspect ratio given by width and height.

Parameters

array $box
int $aspectWidth
int $aspectHeight

Return Value

array

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.

Parameters

array $box
int|null $maxWidth
int|null $maxHeight

protected array getPointBoundingBox(array $points, int $padding)

Get the bounding box of a point annotation.

Parameters

array $points
int $padding

Return Value

array

protected array getCircleBoundingBox(array $points)

Get the bounding box of a circle annotation.

Parameters

array $points

Return Value

array

protected array getPolygonBoundingBox(array $points)

Get the bounding box of an annotation that is no point, circle or whole frame.

Parameters

array $points

Return Value

array

protected array makeBoxIntegers(array $box)

Round and cast box values to int.

Parameters

array $box

Return Value

array

protected array generateAnnotationBoxes(VolumeFile $file, Collection $annotations)

No description

Parameters

VolumeFile $file
Collection $annotations

Return Value

array

protected string getCropBufferForPyworker(Image $image, array $box)

Get the byte string of the cropped and resized patch for the Python worker.

Parameters

Image $image
array $box

Return Value

string

protected array sendPyworkerRequest(string $buffer)

Send the PNG image crop to the Python worker and return the feature vector array.

Parameters

string $buffer

Return Value

array

at line 22
__construct(array $imageAnnotationIds, array $videoAnnotationIds)

No description

Parameters

array $imageAnnotationIds
array $videoAnnotationIds

at line 29
handle()

No description

at line 69
Collection getInsertData(Collection $models)

Get the array to insert new feature vector models into the DB.

Parameters

Collection $models

Return Value

Collection

at line 96
Generator getFeatureVectors(Collection $models)

Generate feature vectors from the thumbnails of many annotations.

Parameters

Collection $models

Annotation models

Return Value

Generator

at line 175
protected getVipsImageForPyworker(string $buffer)

Get the vips image instance for submission to the Python worker for feature vectors.

Parameters

string $buffer