class ImageEmbeddingController extends Controller

Traits

AuthorizesRequests
ValidatesRequests

Methods

bool
isAutomatedRequest(Request $request = null)

Determines if the request was done by an automated script (with API token or ajax).

RedirectResponse
fuzzyRedirect()

Redirects to the _redirect URL, to a route or else back.

Response
store(StoreImageEmbeddingRequest $request)

Request a SAM image embedding.

array|null
findCoveringEmbedding(Image $image, mixed $disk, array|null $originalBbox, array|null $expandedBbox)

Find an existing embedding that covers the requested bbox with resolution similar to the target expanded bbox.

array|null
expandBbox(Image $image, array $bbox)

Expand bbox to a square with at least the minimum model input size.

array
getResolutionRange(int $width, int $height)

Calculate resolution range for matching embeddings within threshold.

Details

in Controller at line 21
bool isAutomatedRequest(Request $request = null)

Determines if the request was done by an automated script (with API token or ajax).

Parameters

Request $request

Return Value

bool

in Controller at line 15
protected RedirectResponse fuzzyRedirect()

Redirects to the _redirect URL, to a route or else back.

Return Value

RedirectResponse

at line 40
Response store(StoreImageEmbeddingRequest $request)

Request a SAM image embedding.

Parameters

StoreImageEmbeddingRequest $request

Return Value

Response

at line 107
protected array|null findCoveringEmbedding(Image $image, mixed $disk, array|null $originalBbox, array|null $expandedBbox)

Find an existing embedding that covers the requested bbox with resolution similar to the target expanded bbox.

Parameters

Image $image
mixed $disk

Storage disk

array|null $originalBbox

The original requested bbox

array|null $expandedBbox

The expanded bbox (target resolution), or null if full image should be used

Return Value

array|null

['filename' => string, 'bbox' => array|null]

at line 175
protected array|null expandBbox(Image $image, array $bbox)

Expand bbox to a square with at least the minimum model input size.

Returns null if the expanded bbox would be almost as large as the full image.

Parameters

Image $image
array $bbox

Return Value

array|null

at line 229
protected array getResolutionRange(int $width, int $height)

Calculate resolution range for matching embeddings within threshold.

Parameters

int $width
int $height

Return Value

array

['minWidth' => float, 'maxWidth' => float, 'minHeight' => float, 'maxHeight' => float]