mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: getAssetOcr endpoint (#23331)
* feat: getAssetOcr endpoint * pr feedback
This commit is contained in:
@@ -2491,6 +2491,53 @@
|
||||
"description": "This endpoint requires the `asset.read` permission."
|
||||
}
|
||||
},
|
||||
"/assets/{id}/ocr": {
|
||||
"get": {
|
||||
"operationId": "getAssetOcr",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/AssetOcrResponseDto"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Assets"
|
||||
],
|
||||
"x-immich-permission": "asset.read",
|
||||
"description": "This endpoint requires the `asset.read` permission."
|
||||
}
|
||||
},
|
||||
"/assets/{id}/original": {
|
||||
"get": {
|
||||
"operationId": "downloadAsset",
|
||||
@@ -11117,6 +11164,88 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"AssetOcrResponseDto": {
|
||||
"properties": {
|
||||
"assetId": {
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
},
|
||||
"boxScore": {
|
||||
"description": "Confidence score for text detection box",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"id": {
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
},
|
||||
"text": {
|
||||
"description": "Recognized text",
|
||||
"type": "string"
|
||||
},
|
||||
"textScore": {
|
||||
"description": "Confidence score for text recognition",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"x1": {
|
||||
"description": "Normalized x coordinate of box corner 1 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"x2": {
|
||||
"description": "Normalized x coordinate of box corner 2 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"x3": {
|
||||
"description": "Normalized x coordinate of box corner 3 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"x4": {
|
||||
"description": "Normalized x coordinate of box corner 4 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"y1": {
|
||||
"description": "Normalized y coordinate of box corner 1 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"y2": {
|
||||
"description": "Normalized y coordinate of box corner 2 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"y3": {
|
||||
"description": "Normalized y coordinate of box corner 3 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"y4": {
|
||||
"description": "Normalized y coordinate of box corner 4 (0-1)",
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"assetId",
|
||||
"boxScore",
|
||||
"id",
|
||||
"text",
|
||||
"textScore",
|
||||
"x1",
|
||||
"x2",
|
||||
"x3",
|
||||
"x4",
|
||||
"y1",
|
||||
"y2",
|
||||
"y3",
|
||||
"y4"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"AssetOrder": {
|
||||
"enum": [
|
||||
"asc",
|
||||
|
||||
@@ -546,6 +546,32 @@ export type AssetMetadataResponseDto = {
|
||||
export type AssetMetadataUpsertDto = {
|
||||
items: AssetMetadataUpsertItemDto[];
|
||||
};
|
||||
export type AssetOcrResponseDto = {
|
||||
assetId: string;
|
||||
/** Confidence score for text detection box */
|
||||
boxScore: number;
|
||||
id: string;
|
||||
/** Recognized text */
|
||||
text: string;
|
||||
/** Confidence score for text recognition */
|
||||
textScore: number;
|
||||
/** Normalized x coordinate of box corner 1 (0-1) */
|
||||
x1: number;
|
||||
/** Normalized x coordinate of box corner 2 (0-1) */
|
||||
x2: number;
|
||||
/** Normalized x coordinate of box corner 3 (0-1) */
|
||||
x3: number;
|
||||
/** Normalized x coordinate of box corner 4 (0-1) */
|
||||
x4: number;
|
||||
/** Normalized y coordinate of box corner 1 (0-1) */
|
||||
y1: number;
|
||||
/** Normalized y coordinate of box corner 2 (0-1) */
|
||||
y2: number;
|
||||
/** Normalized y coordinate of box corner 3 (0-1) */
|
||||
y3: number;
|
||||
/** Normalized y coordinate of box corner 4 (0-1) */
|
||||
y4: number;
|
||||
};
|
||||
export type AssetMediaReplaceDto = {
|
||||
assetData: Blob;
|
||||
deviceAssetId: string;
|
||||
@@ -2390,6 +2416,19 @@ export function getAssetMetadataByKey({ id, key }: {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* This endpoint requires the `asset.read` permission.
|
||||
*/
|
||||
export function getAssetOcr({ id }: {
|
||||
id: string;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: AssetOcrResponseDto[];
|
||||
}>(`/assets/${encodeURIComponent(id)}/ocr`, {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* This endpoint requires the `asset.download` permission.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user