> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contextualize 360° images in asset-centric and hybrid projects

> Use the Vision API for text detection on 360° images. The bounding boxes with detected text can then be contextualized towards assets.

## Contextualize

For **asset-centric (legacy)** or **hybrid** projects, you can contextualize 360° images in two ways:

* **Use your own tooling** to read 360° images, run text detection, and create contextualization approvals.
* **Use the Vision API** to detect text regions from your 360° images and then create annotations with the [Annotations API](/api-reference/concepts/20230101/annotations).

For user interface-based contextualization of 360° images, see [Contextualize 360° images](/cdf/3d/guides/360images_contextualize).

<Warning>
  The **Vision API** is deprecated. See [Deprecated features in CDF](/cdf/deprecated) for details. We recommend migrating to a **data modeling** project.
</Warning>

The following steps use the Vision API for text detection and the Annotations API to create asset contextualization annotations.

<Steps>
  <Step title="Run text detection">
    Use the [Vision API](/api-reference/concepts/20230101/vision) text detection to get text regions from your 360° images.

    Trigger text detection with the Cognite Python SDK:

    ```python theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
    from cognite.client.data_classes.contextualization import (
        FeatureParameters,
        TextDetectionParameters,
        VisionFeature,
    )

    extract_job = client.vision.extract(
        features=[VisionFeature.TEXT_DETECTION],
        file_ids=file_ids,
        parameters=FeatureParameters(
            text_detection_parameters=TextDetectionParameters(threshold=text_detection_threshold)
        ),
    )
    ```

    `file_ids`: List of CDF file IDs for your 360° images.
  </Step>

  <Step title="Match text to CogniteAssets">
    To link detections to core data model <span translate="no">CogniteAsset</span>s, match the detected text to the right asset.

    <AccordionGroup>
      <Accordion title="Exact matching">
        Retrieve the <span translate="no">CogniteAsset</span>s of your interest, then match detected text to asset properties such as `name` or `externalId` using exact string match.
      </Accordion>

      <Accordion title="Fuzzy matching">
        Use fuzzy matching (for example, trigram similarity using Python's `difflib` library) so that optical character recognition (OCR) issues still match the correct asset. Fuzzy matching helps when detected text has typos, spaces, or misread characters.
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Create annotations">
    To contextualize 360° images with the matched text, create annotations with the [Annotations API](/api-reference/concepts/20230101/annotations). Use the annotation type **`images.AssetLink`** (legacy) or **`images.InstanceLink`** (hybrid) in the request `items` → `data`. Each annotation links one 360° image (file) to one asset and can include the spatial region where the text was detected.

    **Create annotations URL:** `https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations`

    **Example request body (hybrid — `images.InstanceLink`):**

    ```json theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
    {
      "items": [
        {
          "annotatedResourceId": 123456789,
          "annotationType": "images.InstanceLink",
          "data": {
            "text": "PUMP-01",
            "objectRegion": {
              "polygon": {
                "vertices": [
                  { "x": 0, "y": 0.4891 },
                  { "x": 0.1099, "y": 0.4947 },
                  { "x": 0, "y": 0.5459 }
                ]
              }
            },
            "textRegion": {
              "xMax": 0.1099,
              "xMin": 0,
              "yMax": 0.5459,
              "yMin": 0.4891
            },
            "instanceRef": {
              "externalId": "asset-external-id",
              "space": "cdf_cdm",
              "instanceType": "node",
              "sources": [
                {
                  "type": "view",
                  "externalId": "CogniteAsset",
                  "space": "cdf_cdm",
                  "version": "v1"
                }
              ]
            }
          },
          "status": "approved",
          "annotatedResourceType": "file",
          "creatingApp": "my-app",
          "creatingAppVersion": "1.0.0",
          "creatingUser": "user@example.com"
        }
      ]
    }
    ```
  </Step>
</Steps>
