class ImageAnnotationController 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.

StreamedJsonResponse
index(Request $request, int $id)

Shows a list of all annotations of the specified image.

show(int $id)

Displays the annotation.

store(StoreImageAnnotation $request)

Creates a new annotation in the specified image.

update(Request $request, int $id)

Updates the annotation including its points.

Response
destroy(int $id)

Removes the annotation.

array
getLabelTreeIds(mixed $user, int $volumeId)

Get all label trees that are used by all projects which are visible to the user.

array
performVectorSearch(vector $featureVector, int[] $trees, int[] $topNLabels)

Perform vector search using the Dynamic Index Switching (DIS) technique.

array
performAnnSearch(Vector $featureVector, int[] $trees)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW index with Post-Subquery Filtering (PSF).

array
performKnnSearch(Vector $featureVector, int[] $trees)

Perform exact KNN search using the B-Tree index for filtering.

dropHNSWIndex()

Drop the HNSW index if exists. This step is necessary to perform exact KNN search because the planner almost always prioritize the HNSW index to perform vector search.

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 74
StreamedJsonResponse index(Request $request, int $id)

Shows a list of all annotations of the specified image.

Parameters

Request $request
int $id

image id

Return Value

StreamedJsonResponse

at line 145
ImageAnnotation show(int $id)

Displays the annotation.

Parameters

int $id

Return Value

ImageAnnotation

at line 217
ImageAnnotation store(StoreImageAnnotation $request)

Creates a new annotation in the specified image.

Parameters

StoreImageAnnotation $request

Return Value

ImageAnnotation

at line 337
update(Request $request, int $id)

Updates the annotation including its points.

Parameters

Request $request
int $id

at line 383
Response destroy(int $id)

Removes the annotation.

Parameters

int $id

Return Value

Response

at line 401
protected array getLabelTreeIds(mixed $user, int $volumeId)

Get all label trees that are used by all projects which are visible to the user.

Parameters

mixed $user
int $volumeId

Return Value

array

at line 437
protected array performVectorSearch(vector $featureVector, int[] $trees, int[] $topNLabels)

Perform vector search using the Dynamic Index Switching (DIS) technique.

The search process first attempts to retrieve results using an Approximate Nearest Neighbor (ANN) search via the HNSW index. If the ANN search returns no results, it falls back to an exact KNN search using the B-Tree index for filtering, ensuring that results are always returned.

Parameters

vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

int[] $topNLabels

The array to store the top N labels based on the search results.

Return Value

array

The array of top N labels that are the closest to the input feature vector.

at line 463
protected array performAnnSearch(Vector $featureVector, int[] $trees)

Perform Approximate Nearest Neighbor (ANN) search using the HNSW index with Post-Subquery Filtering (PSF).

The search uses the HNSW index to find the top K nearest neighbors of the input feature vector, and then applies filtering based on the label_tree_id values. If no results are found or if the filtering removes all results, an empty array is returned.

Parameters

Vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

Return Value

array

The array of label IDs representing the top nearest neighbors.

at line 496
protected array performKnnSearch(Vector $featureVector, int[] $trees)

Perform exact KNN search using the B-Tree index for filtering.

This search filters the data based on label_tree_id using the B-Tree index, and then performs the vector search to find the nearest neighbors of the input feature vector. This method is used as a fallback when the ANN search does not return results.

Parameters

Vector $featureVector

The input feature vector to search for nearest neighbors.

int[] $trees

The label tree IDs to filter the data by.

Return Value

array

The array of label IDs representing the top nearest neighbors.

at line 526
protected dropHNSWIndex()

Drop the HNSW index if exists. This step is necessary to perform exact KNN search because the planner almost always prioritize the HNSW index to perform vector search.