[OpenR8 solution] Image_FindBlob2 (Find objects in the image)
  1. Chapter1: Image_FindBlob2 Introduction

 

Image_FindBlob2 is an example of a solution that frames objects of a specified size and can be used interchangeably with another “Image_FindBlob.doc” file.

 

The process of Image_FindBlob2 is shown in Fig. 1. Each step is described in detail in the chapter 4 of this document.

 

Fig. 1. Image_FindBlob2 process.png

Fig. 1. Image_FindBlob2 process

 

 

  1. Chapter2: Image_FindBlob2 Folder Introduction

 

Image_FindBlob2 is in the solution folder of OpenR8 and contains:

  1. data folder: sample2.png.
  2. flow file: FindBlob_Example2.flow solution.

 

Fig. 2. Image_FindBlob2 location.png

Fig. 2. Image_FindBlob2 location.

 

Fig. 3. Image_FindBlob2 folder.png

Fig. 3. Image_FindBlob2 folder.

 

 

  1. Chapter3: Open FindBlob_Example2.flow

 

There is a “R8.exe” executable file under OpenR8 folder. See Fig. 4. Double-click to execute R8.exe.

 

Fig. 4. Run R8.png

Fig. 4. Run R8.exe.

 

Please click "File" => "Open" => "to enter the solution folder under OpenR8" => "Select Image_FindBlob2 folder" => "Select FindBlob_Example2.flow", such as Fig. 5, Fig. 6.

 

Fig. 5. Select FindBlob_Example2.flow.png

Fig. 5. Select FindBlob_Example2.flow.

 

Fig. 6. Open FindBlob_Example2.flow.png

Fig. 6. Open FindBlob_Example2.flow.

 

The process of FindBlob_Example2 will be introduced and explained in the next chapter.

 

 

  1. Chapter4: FindBlob_Example2.flow process

 

As shown in the flow of Fig. 1, the main process is “open image” => “binarization” => “find objects” => “show result”.

 

The image prepared in this document is Fig. 7. The target is marked with a pattern other than the cross pattern, as shown in Fig. 8.

 

Fig. 7. FindBlob_Example2.flow detection image.png

Fig. 7. FindBlob_Example2.flow detection image.

 

Fig. 8. Frame patterns other than the cross.png

Fig. 8. Frame patterns other than the cross.

 

Fig. 9. FindBlob_Example2.flow process.png

Fig. 9. FindBlob_Example2.flow process.

 

  1. Image_Open

 In the field of the image file name, fill in the name of the image file you want to test.imageFileName: The image file location you want to read in adds the file name, as shown in Fig. 10.

image: The read image is output.

 

Fig. 10. Select the image you want to test.png

Fig. 10. Select the image you want to test.

 

  1. Image_Binarize:

image binarization.

image: Select the image output by “Image_Open”.

threshold: Binarization threshold, fill in 128 here.

imageBinarize: Output a binarized image.

 

Fig. 11. FindBlob_Example2.flow - Image_Binarize.png

Fig. 11. FindBlob_Example2.flow - Image_Binarize.

 

Fig. 12. Using the binarization result with a threshold of 128 for Fig. 7.jpg

Fig. 12. Using the binarization result with a threshold of 128 for Fig. 7

 

  1. Image_FindBlob:

Filter out the larger object of Fig. 7 as shown in Fig. 13, so set objects width than 30 pixel and height than 60 pixel to filter out.

image:

Select the image output by “Image_Binarize”.

enableMnX:

Since you need to catch more than 60 pixel, you should fill in True here.

minx:

Since you need to catch more than 60 pixel, you should fill in 60 here.

enableMaxX:

Do not fill in here.

maxX:

Do not fill in here.

enableMinY:

Since you need to catch more than 30 pixel, you should fill in True here.

minY:

Since you need to catch more than 30 pixel, you should fill in 30 here.

enableMaxY:

Do not fill in here.

maxY:

Do not fill in here.

enableMinArea:

Do not fill in here.

minArea:

Do not fill in here.

enableMaxArea:

Do not fill in here.

maxArea:

Do not fill in here.

enableMinFillRate:

Do not fill in here.

minFillRate:

Do not fill in here.

enableMaxFillRate:

Do not fill in here.

maxFillRate:

Do not fill in here.

json:

The output of json.

imageFrom:

Do not fill in here.

imageTo:

Do not fill in here.

type:

When packaged into json, the name displayed is shown in Fig. 28.

 

Fig. 13. Grab large objects first.png

Fig. 13. Grab large objects first.

 

Fig. 14. FindBlob_Example2.flow - Image_FindBlob.png

Fig. 14. FindBlob_Example2.flow - Image_FindBlob.

 

  1. Image_FindBlob:

Unlike the “Image_FindBlob” at point 3, it is changed to grab an object with a width of more than 30 pixels. The target is as shown in Fig. 15.

image:

Select the image output by “Image_Binarize”.

enableMnX:

Since the minimum value is not set here, it is not filled out.

minx:

Since the minimum value is not set this time, it is not filled in. If it is not filled in, the default is 0.

enableMaxX:

Do not fill in here.

maxX:

Do not fill in here.

enableMinY:

Since you need to catch more than 30 pixel, you should fill in True here.

minY:

Since you need to catch more than 30 pixel, you should fill in 30 here.

enableMaxY:

Do not fill in here.

maxY:

Do not fill in here.

enableMinArea:

Do not fill in here.

minArea:

Do not fill in here.

enableMaxArea:

Do not fill in here.

maxArea:

Do not fill in here.

enableMinFillRate:

Do not fill in here.

minFillRate:

Do not fill in here.

enableMaxFillRate:

Do not fill in here.

maxFillRate:

Do not fill in here.

json:

The output of json.

imageFrom:

Do not fill in here.

imageTo:

Do not fill in here.

type:

When packaged into json, the name displayed is shown in Fig. 28.

 

Fig. 15. Find objects with a height more than 30 pixel.png

Fig. 15. Find objects with a height more than 30 pixel.

 

Fig. 16. FindBlob_Example2.flow -Image_FindBlob.png

Fig. 16. FindBlob_Example2.flow -Image_FindBlob.

 

  1. Image_FindBlob:

The smaller object of Fig. 7is filtered out, as shown in Fig. 17, so objects with a width less than 30 pixels and a height less than 30 pixels are filtered out.

image:

Select the image output by “Image_Binarize”.

enableMnX:

Since you need to catch more than 3 pixels, you should fill in here.

minx:

Since you need to catch more than 3 pixels, you should fill in here.

enableMaxX:

Since you need to the maximum catch 30 pixels, you should fill in here.

maxX:

Since you need to the maximum catch 30 pixels, you should fill in here.

enableMinY:

Since you need to catch more than 3 pixels, you should fill in here.

minY:

Since you need to catch more than 3 pixels, you should fill in here.

enableMaxY:

Since you need to the maximum catch 30 pixels, you should fill in here.

maxY:

Since you need to the maximum catch 30 pixels, you should fill in here.

enableMinArea:

Do not fill in here.

minArea:

Do not fill in here.

enableMaxArea:

Do not fill in here.

maxArea:

Do not fill in here.

enableMinFillRate:

Do not fill in here.

minFillRate:

Do not fill in here.

enableMaxFillRate:

Do not fill in here.

maxFillRate:

Do not fill in here.

json:

The output of json.

imageFrom:

Do not fill in here.

imageTo:

Do not fill in here.

type:

When packaged into json, the name displayed is shown in Fig. 28.

 

Fig. 17. Find smaller objects.png

Fig. 17. Find smaller objects.

 

Fig. 18. FindBlob_Example2.flow - Image_FindBlob.png

Fig. 18. FindBlob_Example2.flow - Image_FindBlob.

 

  1. JsonArray_AppendNew:

Merge the json output of the fourth point “Image_FindBlob” into the json output of the “Image_FindBlob” at the third point.

 

Fig. 19. Merging json2 into json1.png

Fig. 19. Merging json2 into json1.

 

  1. JsonArray_AppendNew:

Merge the json output of the fifth point “Image_FindBlob” into the json output of the “Image_FindBlob” at the third point.

 

Fig. 20. Merging json3 into json1.png

Fig. 20. Merging json3 into json1.

 

  1. Json_ToString:

Convert the merged json1 from json format to string format.

 

Fig. 21. Convert json1 to a string.png

Fig. 21. Convert json1 to a string.

 

  1. Println:

The string of “Json_ToString” is output in the DOS window.

 

Fig. 22. Println.png

Fig. 22. Println.

 

  1. Image_DrawDefects:

Use a red box to draw in the image

Image:

Select the image you want to draw the box.

json:

Select the json you want to draw.

imageDrawDefects:

The image that is output after the box is drawn.

thickness:

The thickness of the box.

colorB:

Since you want to use the red box, fill in 0 here.

colorG:

Since you want to use the red box, fill in 0 here.

colorR:

Since you want to use the red box, fill in 255 here.

extraRange:

When the frame is drawn, how many pixels are expanded outside the position after the original json is parsed.

 

Fig. 23. FindBlob_Example2.flow - Image_DrawDefects.png

Fig. 23. FindBlob_Example2.flow - Image_DrawDefects.

 

  1.  Image_Show:

Display the image read by Image_Open.

 

Fig. 24. Display the image read by Image_Open..png

Fig. 24. Display the image read by Image_Open.

 

  1. Image_Show:

Display the image output by “Image_DrawDefects”.

 

Fig. 25. Display the image output by Image_DrawDefects.png

Fig. 25. Display the image output by Image_DrawDefects.

 

  1. WaitKey:

After Image_Show, you must add WaitKey to see the image, and how many microseconds the image stays.

keyCode: The output signal.

milliSencond: If you want the image to be turned off until any key is pressed, set 0. If you want the image to be displayed after 1 second, set 1000.

 

※1 Second = 1000 microsecond.

 

Fig. 26. FindBlob_Example2.flow - WaitKey.png

Fig. 26. FindBlob_Example2.flow - WaitKey.

 

  1. Image_DestoryAllWindows:

Close all image windows displayed by Image_Show.

  1. result:

 

Fig. 27. Print the results of json and box.png

Fig. 27. Print the results of json and box.

 

Fig. 28. Json description.png

Fig. 28. Json description.

 

 

 


Recommended Article

1.
OpenR8 Community Edition - AI Software for Everyone (Free Download)