> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/getting-started/your-very-first-project/detection.md).

# 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.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-82e7b55abc017f022a5952b857e52a7e9bf0e2f1%2Fimage-det-1.png?alt=media)
{% endstep %}

{% step %}

### Add Show Image

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

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-0b6f8f823d408e10908e7bcf3b91e6c30a3e2a07%2Fimage-det.png?alt=media)
{% endstep %}

{% step %}

### Connect the detector

Connect the blocks as shown below.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-c1bd23b761af62c4671e5e3bba179d85d812489b%2Fimage-det-2.png?alt=media)

Click <img src="https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-a3f52ba493c19aeed3ed51442d5a3a9713df61ff%2Fplay_step.png?alt=media" alt="run step" data-size="line">*Run Step*. You should see the detected golf ball inside a red box in **Show Image**.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-c7e32bf491995b24c125d3ffd3cced634de7762e%2Fimage-det-3.png?alt=media)
{% endstep %}

{% step %}

### Test continuous detection

Click <img src="https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-336c18484aa93d35401e4cf66bff9e99257fee93%2Fplay.png?alt=media" 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.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-311883ec708cc21eb5003b847af553507ab3e3d0%2Fimage-det-memory.png?alt=media)
{% endstep %}

{% step %}

### Add Logic Input

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

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-fa9fabd7a65b1af440034d252aa94e57bc92f9f0%2Fimage-det-logic.png?alt=media)
{% endstep %}

{% step %}

### Rearrange crowded blocks

Move one block by clicking and dragging it.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-4c374e057396b21afeefe38675a542c206e87ff6%2Fvideo-single-block-move.webp?alt=media)

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

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-c760a3e5ca7c40168cfd4daf3901ee1638c366a8%2Fvideo-multiple-block-move.webp?alt=media)
{% endstep %}

{% step %}

### Connect Image Memory

Connect the new blocks as shown below.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-6af9b5da7e3e5c3843e56023be61c8dc9ffb10b8%2Fimage-det-memory2.png?alt=media)

**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**.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-3e840cab9e11495b83e0a0e65e00e82abab9e08c%2Fvideo-image-memory-save.webp?alt=media)
{% endstep %}

{% step %}

### Tune Find Object

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

<figure><img src="https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-e9c1faacaf06c868c73ca7067b3fc106052f8157%2Fimage-find-object-threshold.png?alt=media" 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.

![](https://63608322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbH8gla5D8g5pQAK8IzR8%2Fuploads%2Fgit-blob-9d391ca21d42434743e68bf12ddca73c259eb55e%2Fvideo-run-detection.webp?alt=media)
{% 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.
