# Detection

In this part, you will detect the golf ball position. You will first build a simple detector, then fix the reference so detection remains stable while the ball moves.

{% stepper %}
{% step %}

### Add Find Object

Go to the blocks bar. Under **Detections/Shapes**, open **Detectors** and drag **Find Object** into the scenario.

![](/files/Kz4QLPQfKYIagoHV4o8l)
{% endstep %}

{% step %}

### Add Show Image

Under **Input/Output**, open **Outputs/Exports** and drag **Show Image** into the scenario.

![](/files/zX2iS0cVeD4zdf9dXU9f)
{% endstep %}

{% step %}

### Connect the detector

Connect the blocks as shown below.

![](/files/n5HxQ6M0usu4qzTkSGPO)

Click <img src="/files/YAlVdoT2RjcfaRrTpP2p" alt="run step" data-size="line">*Run Step*. You should see the detected golf ball inside a red box in **Show Image**.

![](/files/O3oxWYKSjOQuxxgaxJ5d)
{% endstep %}

{% step %}

### Test continuous detection

Click <img src="/files/dEBSnHPh0rec7YKCQ54r" alt="run" data-size="line"> *Run* and watch the detection for about 10 seconds.

You may notice that detection becomes unstable. This happens because **Image ROI Select** keeps changing its reference as the ball moves, so the reference can become grass instead of the golf ball.
{% endstep %}

{% step %}

### Add Image Memory

To keep the reference stable, add **Image Memory**.

Go to the blocks bar. Under **Image Transformers**, open **Analysis** and drag **Image Memory** into the scenario.

![](/files/ZzwOo9oqAEL4EzPn4KPC)
{% endstep %}

{% step %}

### Add Logic Input

Under **Input/Output**, open **Data Inputs** and drag **Logic Input** into the scenario.

![](/files/9TZNPwBGATbeyEyblfhp)
{% endstep %}

{% step %}

### Rearrange crowded blocks

Move one block by clicking and dragging it.

![](/files/nyfAfYurtXQQzUbMUzAT)

Move multiple blocks by dragging a selection around them, then dragging the selected group.

![](/files/PXcgQO2dF19IAwcn6fnG)
{% endstep %}

{% step %}

### Connect Image Memory

Connect the new blocks as shown below.

![](/files/BgXCybBF5VZe4QJwTkCd)

**Image Memory** freezes the frame we need, so the reference does not change while the video runs.
{% endstep %}

{% step %}

### Save the reference frame

Run the scenario for one step. Then set **Logic Input** to **True** to save the image in **Image Memory**.

![](/files/B6z6NXne558KiqHtAYaL)
{% endstep %}

{% step %}

### Tune Find Object

Move to **Find Object** and set **Match Threshold** to `100%`.

<figure><img src="/files/C9Sq35pcXx6HnCEdLGFC" alt="Find Object match threshold" width="450"><figcaption><p>Find Object match threshold</p></figcaption></figure>
{% endstep %}

{% step %}

### Run detection

Press *Run* and check that the detector follows the golf ball.

![](/files/usmdy4wtqn8nffSNmxyt)
{% endstep %}
{% endstepper %}

The detector is now working with a stable reference. Continue to the final page to check whether the golf ball reaches the hole.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/getting-started/your-very-first-project/detection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
