Jump to content

Is there a way to perform partial image matching (finding an image within another image)?


Go to solution Solved by smbape,

Recommended Posts

Posted

Hi guys! Could you please tell me if there is a library that supports partial image matching (i.e., finding a smaller image inside a larger one with some tolerance)?

I am currently using ImageSearchDLL_UDF.au3, but it does not support this functionality. I need a way to specify a similarity threshold (percentage match).

I would greatly appreciate any help!

Sorry for my English.

Posted
22 minutes ago, ahmet said:

There is an opencv udf. I am not sure if it has that functionality. There is also a yolo udf.

Yeah, I agree. I’m trying to learn how to use this library!

  • Solution
Posted

@SEKOMD If I am correct, there is an example of image searching in the opencvudf

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "autoit-opencv-com\udf\opencv_udf_utils.au3"

_OpenCV_Open("opencv-4.12.0-windows\opencv\build\x64\vc16\bin\opencv_world4120.dll", "autoit-opencv-com\autoit_opencv_com4120.dll")
OnAutoItExitRegister("_OnAutoItExit")
Example()

Func Example()
    Local $cv = _OpenCV_get()
    If Not IsObj($cv) Then Return

    Local $img = _OpenCV_imread_and_check(_OpenCV_FindFile("samples\data\mario.png"))
    Local $tmpl = _OpenCV_imread_and_check(_OpenCV_FindFile("samples\data\mario_coin.png"))

    ; The higher the value, the higher the match is exact
    Local $threshold = 0.8

    Local $aMatches = _OpenCV_FindTemplate($img, $tmpl, $threshold)

    Local $aRedColor = _OpenCV_RGB(255, 0, 0)
    Local $aMatchRect[4] = [0, 0, $tmpl.width, $tmpl.height]

    For $i = 0 To UBound($aMatches) - 1
        $aMatchRect[0] = $aMatches[$i][0]
        $aMatchRect[1] = $aMatches[$i][1]

        ; Draw a red rectangle around the matched position
        $cv.rectangle($img, $aMatchRect, $aRedColor)
    Next

    $cv.imshow("Find template example", $img)
    $cv.waitKey()

    $cv.destroyAllWindows()
EndFunc   ;==>Example

Func _OnAutoItExit()
  _OpenCV_Close()
EndFunc   ;==>_OnAutoItExit

 

Posted
5 hours ago, smbape said:

 If I am correct, there is an example of image searching in the opencvudf

Thank you for the example!!!!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...