Detection

Now, we'll learn how to detect the golf balls position!

We'll use two function blocks, Show Image and Find Object to detect the position of the golf ball and see the result.

Now:

  1. Go to the blocks bar,

  2. Under Detections/Shapes, go to the Detectors section and drag-drop the Find Object block into the scenario:

Just like before:

  1. Go to the blocks bar,

  2. Under Input/Output, go to the Outputs/Exports section and drag-drop the Show Image block into the scenario:

Lastly, connect them just like as below:

Click on Run Step to run the scenario a step and you should see the detection in a red box in the Show Image block:

Now, we are set! Go ahead and click Run and watch for 10 seconds how the detection works.

๐Ÿ’ฌ It seems the detection is not working properly. This is due to Image ROI Select's reference changes as the ball moves, and our reference becomes the grass.

To tackle this issue, we'll use the Image Memory and Logic Input block as shown below:

  1. Go to the blocks bar,

  2. Under Image Transformers, go to the Analysis section and drag-drop the Find Object block into the scenario:

Again:

  1. Go to the blocks bar,

  2. Under Input/Output, go to the Data Inputs section and drag-drop the Logic Input block into the scenario:

Our scenario is a little bit crowded. Let's rearrage the blocks by using our mouse. There are two methods:

  1. Clicking on a block and dragging it:

  2. Clicking on an empty space, selecting multiple blocks and dragging them:

Now, connect those two blocks just as shown below:

Image Memory block will memorize the frame we need and freeze it. This way, our reference will never change.

To freeze the image, run the scenario for a step, go to the Logic Input block and set it to True.

Lastly, move on to the Find Object block and set the Match Threshold to %100 just like below:

Singing-up

We are ready to detect the golf ball! Press Run and see the detection work:

Very good! We are about to be finished with our first project. Move on the next project and let's finish building our first scenario.

Last updated