Jump to content

Real-Time Object Detection using YOLOv3 wrapper


smartee
 Share

Recommended Posts

Based on the number of objects this version is detecting (80?) you could probably get better results writing a python wrapper to interface with an autoit script and use opencv dnn module to load tensorflow inception with a pretrained classifier that can detect 1000 different objects instead, it even gives you specific dog breeds. The speed is negligible in difference I'd assume.

Edited by Skitty
Link to comment
Share on other sites

13 minutes ago, bazanski said:

SkittyI don't need 1000 objects. I don't need 80 objects. I need one photoobject for this program to detect it in the photo.

... wat

that wasn't an answer to your question, but since we're here, the op had already provided you with a relevant link which will answer your previous question.

 

Link to comment
Share on other sites

  • 3 months later...
  • 4 weeks later...
  • Developers

Of course...  look at the many _Array* options in the helpfile, which also has _ArraySort() in the list.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Anything is possible .... but you have to try it yourself first.....  sort the array, loop through it and format it in wahtever way you want. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Added your UDF to the Graphics and Image section in the wiki.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 4 weeks later...

Hello, my English is not very good, I wanted to share this code is the application to detect in real time on a selected window. I have a question and it is if the detection time could be optimized in any way other than just using the GPU and CUDA API, since the interesting thing about this is being able to run models based on vision by computer with hardware that does not have so many resources available. Thank you

My code

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <FaceDetection.au3>
#include <Array.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include <WinAPIHObj.au3>
#include <File.au3>
#include <AutoYOLO3.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Global $nPic = 1
Global $nWin = ""
Global $aFacesDB[100][142]

$nWin = win_select($nWin)
$hWnd = WinGetHandle($nWin)
WinActivate($hWnd)
WinSetState($hWnd, "", @SW_SHOWNA)
Global $aPos = WinGetPos($hWnd)
Global $hHBmp = _ScreenCapture_CaptureWnd("", $hWnd, $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3])

Global $g_hGUI = GUICreate("YOLO - CAPTURE SCREEN LIVE", $aPos[2], $aPos[3], -1, -1)
GUISetState(@SW_SHOWNA, $g_hGUI) ;@SW_SHOWNA


_GDIPlus_Startup()
Global $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)

Global $dir = @ScriptDir & "\ImageCrop_" & @MDAY & "_" & @MON & "_" & @YEAR
If Not FileExists($dir) Then
    MsgBox(0,  "Folder creation ","ImageCrop folder does not exist, creating ...", 3) ; El mensaje está 3 segundos.
    DirCreate($dir)
EndIf
Global $dir_train = @ScriptDir & "\Train_dataset_" & @MDAY & "_" & @MON & "_" & @YEAR
If Not FileExists($dir_train) Then
    MsgBox(0, "Folder creation ","The train_dataset folder does not exist, creating ...", 3) ; El mensaje está 3 segundos.
    DirCreate($dir_train)
EndIf

general_ refresh()

_GDIPlus_Shutdown()


Func general_ refresh()
    Local $tDelta = TimerInit()
    Do
        If TimerDiff($tDelta) >= 67 Then ; => 67=30 FPS; 32=60 FPS
            $tDelta = TimerInit()
            RefreshImage()
            ConsoleWrite(TimerDiff($tDelta) & @CRLF)
;~             OnAutoItExitRegister("CleanupResources")
        EndIf
    Until GUIGetMsg() == $GUI_EVENT_CLOSE
EndFunc

Func RefreshImage()
    $hWnd = WinGetHandle($nWin)
    WinSetState($hWnd, "", @SW_SHOWNA)
    Local $aPos = WinGetPos($hWnd)
    Local $sFilePath
    Local $sDestination = @ScriptDir & "\face_detected_1.bmp"
    Local $aClientSize = WinGetClientSize($hWnd)
    Local $iPicW=$aClientSize[0]
    Local $iPicH=$aClientSize[1]
    Local $hHBmp = _ScreenCapture_CaptureWnd("", $hWnd, $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3])
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp)
    Local $rG = _GDIPlus_GraphicsDrawImage($g_hGraphics, $hBitmap, 0, 0)
;~     ==========================================================================================================================
;~ Resize square image for intro in objetcs detector
    Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap)
    Local $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
    Local $sFactor = 1
    If $iWidth > $iPicW Then
        $sFactor = $iPicW / $iWidth
    EndIf
    If $iHeight > $iPicH And ($iHeight * $sFactor) > $iPicH Then
        $sFactor = $iPicH / $iHeight
    EndIf
    $iHeight = $iHeight * $sFactor
    $iWidth = $iWidth * $sFactor
    $hResizedImage = _GDIPlus_ImageResize($hBitmap, $iWidth, $iHeight)
;~     _GDIPlus_BitmapDispose($hBitmap)
    Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResizedImage, 0x00000000)
;~     ====================objetcs detector======================================================================================================
    Global $aRes = _AutoYolo3_GetObjInHBitmap($hHBITMAP)
;~     _ArrayDisplay($aRes)
    If $aRes[0][0] <> 0 Then
        If @error Then
            Local $iErr = @error
            Local $asDllErrors[6] = ["No error", "unable to use the DLL file", "unknown ""return type""", """function"" not found in the DLL file", "bad number of parameters", "bad parameter"]
            If $iErr < 6 Then
                MsgBox(32, @ScriptName, "DLL Error, " & $asDllErrors[$iErr])
            Else
                MsgBox(32, @ScriptName, "DLL Error, " & _AutoYolo3_GetLastError())
            EndIf
        ElseIf _AutoYolo3_GetLastError() <> "" Then
            MsgBox(32, @ScriptName, _AutoYolo3_GetLastError())
        Else
            ;nice thick green boxes
                Local $hPen = _GDIPlus_PenCreate(0xFF00FF00, 2, 2)
                Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
                Local $hFormat = _GDIPlus_StringFormatCreate()
                Local $hFamily = _GDIPlus_FontFamilyCreate("Calibri")
                Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 0)
                Local $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    ;~         Local $hBrushBack = _GDIPlus_BrushCreateSolid(0x7FFFFFFF) ;color format AARRGGBB (hex)
    ;~         $hGraphics = _GDIPlus_ImageGetGraphicsContext($hHBmp)
    ;~         _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
            For $i = 1 To $aRes[0][0]
                $sTempImg = $dir & "\face_" & @HOUR & "_" & @MIN & "_" & @SEC & "-" & $aRes[$i][0] & ".jpg"
                $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $aRes[$i][2], $aRes[$i][3] , $aRes[$i][4], $aRes[$i][5], $GDIP_PXF24RGB)
                _GDIPlus_ImageSaveToFile($hClone, $sTempImg)
                _GDIPlus_ImageDispose($hClone)
                _WinAPI_DeleteObject($hBitmap)
                    ; Draw a frame around the object
                    _GDIPlus_GraphicsDrawRect($g_hGraphics, $aRes[$i][2], $aRes[$i][3] , ($aRes[$i][4] - $aRes[$i][2]), ($aRes[$i][5] - $aRes[$i][3]) , $hPen)
                ; Label it
                    $sLabel = $aRes[$i][0] & " " & StringLeft($aRes[$i][1], 6)
                    $tLayout = _GDIPlus_RectFCreate($aRes[$i][2] , $aRes[$i][3] , 200, 20)
    ;~             $iBackLen = 0
    ;~             If (StringLen($sLabel) * 😎 > $iBackLen Then
    ;~                 $iBackLen = StringLen($sLabel) * 8
    ;~             EndIf
    ;~             _GDIPlus_GraphicsFillRect($hGraphics, $aRes[$i][2] , $aRes[$i][3], $iBackLen, 20, $hBrushBack)
    ;~             _    GDIPlus_GraphicsDrawStringEx($g_hGraphics, $sLabel, $hFont, $tLayout, $hFormat, $hBrush)

            Next
        EndIf

;~         $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp, 0x00000000)
;~         GUICtrlSendMsg($g_hGUI , $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP)
             _GDIPlus_PenDispose($hPen)
             _GDIPlus_FontDispose($hFont)
             _GDIPlus_FontFamilyDispose($hFamily)
             _GDIPlus_StringFormatDispose($hFormat)
;~              _GDIPlus_ImageDispose($hClone)
;~         _GDIPlus_BrushDispose($hBrush)
;~         _GDIPlus_BrushDispose($hBrushBack)
             _GDIPlus_GraphicsDispose($g_hGraphics)
    EndIf
;~ ================================================================================================================================
EndFunc   ;==>RefreshImage

Func win_select($nWin)

    Local $stPoint = DllStructCreate($tagPOINT), $aPos, $hControl, $hWin, $aLastPos[2] = [-1, -1], $sLastStr = '', $sStr

    TrayTip ("YOLO - CAPTURE SCREEN LIVE", "Select the window to detect", 5)
    While Not _IsPressed('01') ;Right mouse button
        $aPos = MouseGetPos()
        If $aPos[0] <> $aLastPos[0] Or $aPos[1] <> $aLastPos[1] Then
            DllStructSetData($stPoint, 1, $aPos[0])
            DllStructSetData($stPoint, 2, $aPos[1])
            $hControl = _WinAPI_WindowFromPoint($stPoint)
            $hWin = _WinAPI_GetAncestor($hControl, 2)
            $sStr = 'Window at ' & $aPos[0] & ',' & $aPos[1] & ': "' & WinGetTitle($hWin) & '"'
            If $sLastStr <> $sStr Then
                ToolTip($sStr, $aPos[0] + 10, $aPos[1] + 20)

                $sLastStr = $sStr
            EndIf
            $aLastPos = $aPos
        EndIf
        Sleep(15)
    WEnd
    ToolTip("")
         #Region --- CodeWizard generated code Start ---
        ;MsgBox features: Title=Yes, Text=Yes, Buttons=Cancel, Try Again, Continue, Icon=Info
        If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
        $iMsgBoxAnswer = MsgBox(70,"YOLO - CAPTURE SCREEN LIVE","La ventana seleccionada es " & WinGetTitle($hWin))
        Select
            Case $iMsgBoxAnswer = 2 ;Cancel

            Case $iMsgBoxAnswer = 10 ;Try Again
                win_select($nWin)

            Case $iMsgBoxAnswer = 11 ;Continue
        #EndRegion --- CodeWizard generated code End ---
        EndSelect
    Return WinGetTitle($hWin)
EndFunc   ;==>win_select


Func _LoadImage($Input1, $Pic1, $hImage, $iPicW, $iPicH)
    If $hImage <> 0 Then
        _GDIPlus_ImageDispose($hImage)
    EndIf

    Local $sImagePath = GUICtrlRead($Input1)
    $hImage = _GDIPlus_ImageLoadFromFile($sImagePath)

    Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage)

    Local $sFactor = 1
    If $iWidth > $iPicW Then
        $sFactor = $iPicW / $iWidth
    EndIf
    If $iHeight > $iPicH And ($iHeight * $sFactor) > $iPicH Then
        $sFactor = $iPicH / $iHeight
    EndIf
    $iHeight = $iHeight * $sFactor
    $iWidth = $iWidth * $sFactor

    $hResizedImage = _GDIPlus_ImageResize($hImage, $iWidth, $iHeight)

    _GDIPlus_BitmapDispose($hImage)

    Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResizedImage, 0x00000000)
    GUICtrlSendMsg($Pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP)
    Return $hResizedImage
EndFunc   ;==>_LoadImage

 

AUTOIT_PUBLICATION_YOLO_v1.0.au3

Edited by Jos
added codebox
Link to comment
Share on other sites

1 hour ago, Pellit said:

My code


#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <FaceDetection.au3>
#include <Array.au3>

please edit your post with this guidelines:

How to post code on the forum *

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <Array.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include <WinAPIHObj.au3>
#include <File.au3>
#include "AutoYOLO3.au3"
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>



Global $nPic = 1
Global $nWin = ""
Global $aFacesDB[100][142]



$nWin = win_select($nWin)
$hWnd = WinGetHandle($nWin)
WinActivate($hWnd)
WinSetState($hWnd, "", @SW_SHOWNA)
Global $aPos = WinGetPos($hWnd)
Global $hHBmp = _ScreenCapture_CaptureWnd("", $hWnd, $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3])

Global $g_hGUI = GUICreate("YOLO - CAPTURE SCREEN LIVE", $aPos[2], $aPos[3], -1, -1)
GUISetState(@SW_SHOWNA, $g_hGUI) ;@SW_SHOWNA


_GDIPlus_Startup()
Global $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)

Global $dir = @ScriptDir & "\ImageCrop_" & @MDAY & "_" & @MON & "_" & @YEAR
If Not FileExists($dir) Then
    MsgBox(0,  "Folder creation ","ImageCrop folder does not exist, creating ...", 3) ; El mensaje está 3 segundos.
    DirCreate($dir)
EndIf
Global $dir_train = @ScriptDir & "\Train_dataset_" & @MDAY & "_" & @MON & "_" & @YEAR
If Not FileExists($dir_train) Then
    MsgBox(0, "Folder creation ","The train_dataset folder does not exist, creating ...", 3) ; El mensaje está 3 segundos.
    DirCreate($dir_train)
EndIf

general_refresh()

_GDIPlus_Shutdown()

;~ ============================================================================================================================================



Func general_refresh()
    Local $tDelta = TimerInit()
    Do
        If TimerDiff($tDelta) >= 67 Then ; => 67=30 FPS; 32=60 FPS
            $tDelta = TimerInit()
            RefreshImage()
            ConsoleWrite(TimerDiff($tDelta) & @CRLF)
;~          OnAutoItExitRegister("CleanupResources")
        EndIf
    Until GUIGetMsg() == $GUI_EVENT_CLOSE
EndFunc



Func RefreshImage()
    $hWnd = WinGetHandle($nWin)
    WinSetState($hWnd, "", @SW_SHOWNA)
    Local $aPos = WinGetPos($hWnd)
    Local $sFilePath
    Local $sDestination = @ScriptDir & "\face_detected_1.bmp"
    Local $aClientSize = WinGetClientSize($hWnd)
    Local $iPicW=$aClientSize[0]
    Local $iPicH=$aClientSize[1]
    Local $hHBmp = _ScreenCapture_CaptureWnd("", $hWnd, $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3])
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp)
    Local $rG = _GDIPlus_GraphicsDrawImage($g_hGraphics, $hBitmap, 0, 0)
;~     ==========================================================================================================================
;~ Resize square image for intro in objetcs detector
    Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap)
    Local $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
    Local $sFactor = 1
    If $iWidth > $iPicW Then
        $sFactor = $iPicW / $iWidth
    EndIf
    If $iHeight > $iPicH And ($iHeight * $sFactor) > $iPicH Then
        $sFactor = $iPicH / $iHeight
    EndIf
    $iHeight = $iHeight * $sFactor
    $iWidth = $iWidth * $sFactor
    $hResizedImage = _GDIPlus_ImageResize($hBitmap, $iWidth, $iHeight)
;~  _GDIPlus_BitmapDispose($hBitmap)
    Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResizedImage, 0x00000000)
;~     ====================objetcs detector======================================================================================================
    Global $aRes = _AutoYolo3_GetObjInHBitmap($hHBITMAP)
;~  _ArrayDisplay($aRes)
    If $aRes[0][0] <> 0 Then
        If @error Then
            Local $iErr = @error
            Local $asDllErrors[6] = ["No error", "unable to use the DLL file", "unknown ""return type""", """function"" not found in the DLL file", "bad number of parameters", "bad parameter"]
            If $iErr < 6 Then
                MsgBox(32, @ScriptName, "DLL Error, " & $asDllErrors[$iErr])
            Else
                MsgBox(32, @ScriptName, "DLL Error, " & _AutoYolo3_GetLastError())
            EndIf
        ElseIf _AutoYolo3_GetLastError() <> "" Then
            MsgBox(32, @ScriptName, _AutoYolo3_GetLastError())
        Else
            ;nice thick green boxes
                Local $hPen = _GDIPlus_PenCreate(0xFF00FF00, 2, 2)
                Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
                Local $hFormat = _GDIPlus_StringFormatCreate()
                Local $hFamily = _GDIPlus_FontFamilyCreate("Calibri")
                Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 0)
                Local $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    ;~      Local $hBrushBack = _GDIPlus_BrushCreateSolid(0x7FFFFFFF) ;color format AARRGGBB (hex)
    ;~      $hGraphics = _GDIPlus_ImageGetGraphicsContext($hHBmp)
    ;~      _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
            For $i = 1 To $aRes[0][0]
                $sTempImg = $dir & "\face_" & @HOUR & "_" & @MIN & "_" & @SEC & "-" & $aRes[$i][0] & ".jpg"
                $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $aRes[$i][2], $aRes[$i][3] , $aRes[$i][4], $aRes[$i][5], $GDIP_PXF24RGB)
                _GDIPlus_ImageSaveToFile($hClone, $sTempImg)
                _GDIPlus_ImageDispose($hClone)
                _WinAPI_DeleteObject($hBitmap)
                    ; Draw a frame around the object
                    _GDIPlus_GraphicsDrawRect($g_hGraphics, $aRes[$i][2], $aRes[$i][3] , ($aRes[$i][4] - $aRes[$i][2]), ($aRes[$i][5] - $aRes[$i][3]) , $hPen)
                ; Label it
                    $sLabel = $aRes[$i][0] & " " & StringLeft($aRes[$i][1], 6)
                    $tLayout = _GDIPlus_RectFCreate($aRes[$i][2] , $aRes[$i][3] , 200, 20)
    ;~          $iBackLen = 0
    ;~          If (StringLen($sLabel) * 8) > $iBackLen Then
    ;~              $iBackLen = StringLen($sLabel) * 8
    ;~          EndIf
    ;~          _GDIPlus_GraphicsFillRect($hGraphics, $aRes[$i][2] , $aRes[$i][3], $iBackLen, 20, $hBrushBack)
    ;~          _   GDIPlus_GraphicsDrawStringEx($g_hGraphics, $sLabel, $hFont, $tLayout, $hFormat, $hBrush)

            Next
        EndIf

;~      $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp, 0x00000000)
;~      GUICtrlSendMsg($g_hGUI , $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP)
            _GDIPlus_PenDispose($hPen)
            _GDIPlus_FontDispose($hFont)
            _GDIPlus_FontFamilyDispose($hFamily)
            _GDIPlus_StringFormatDispose($hFormat)
;~          _GDIPlus_ImageDispose($hClone)
;~      _GDIPlus_BrushDispose($hBrush)
;~      _GDIPlus_BrushDispose($hBrushBack)
            _GDIPlus_GraphicsDispose($g_hGraphics)
    EndIf
;~ ================================================================================================================================
EndFunc   ;==>RefreshImage



Func win_select($nWin)

    Local $stPoint = DllStructCreate($tagPOINT), $aPos, $hControl, $hWin, $aLastPos[2] = [-1, -1], $sLastStr = '', $sStr

    TrayTip ("YOLO - CAPTURE SCREEN LIVE", "Select the window to detect", 5)
    While Not _IsPressed('01') ;Right mouse button
        $aPos = MouseGetPos()
        If $aPos[0] <> $aLastPos[0] Or $aPos[1] <> $aLastPos[1] Then
            DllStructSetData($stPoint, 1, $aPos[0])
            DllStructSetData($stPoint, 2, $aPos[1])
            $hControl = _WinAPI_WindowFromPoint($stPoint)
            $hWin = _WinAPI_GetAncestor($hControl, 2)
            $sStr = 'Window at ' & $aPos[0] & ',' & $aPos[1] & ': "' & WinGetTitle($hWin) & '"'
            If $sLastStr <> $sStr Then
                ToolTip($sStr, $aPos[0] + 10, $aPos[1] + 20)

                $sLastStr = $sStr
            EndIf
            $aLastPos = $aPos
        EndIf
        Sleep(15)
    WEnd
    ToolTip("")
         #Region --- CodeWizard generated code Start ---
        ;MsgBox features: Title=Yes, Text=Yes, Buttons=Cancel, Try Again, Continue, Icon=Info
        If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
        $iMsgBoxAnswer = MsgBox(70,"YOLO - CAPTURE SCREEN LIVE","La ventana seleccionada es " & WinGetTitle($hWin))
        Select
            Case $iMsgBoxAnswer = 2 ;Cancel

            Case $iMsgBoxAnswer = 10 ;Try Again
                win_select($nWin)

            Case $iMsgBoxAnswer = 11 ;Continue
        #EndRegion --- CodeWizard generated code End ---
        EndSelect
    Return WinGetTitle($hWin)
EndFunc   ;==>win_select

Hello, my apologies for not respecting the format of the publications, regarding FaceDetection.au3 if it corresponds to the publication of https://autoit.de/thread/86499-facedetection-udf/ in this case that library is not used but The Yolov3 model also works as in this case, since the root to make the detection is the same, the only thing that changes the detector. I republish my code with the required libraries.

 

Dependency folder structure to run script

1 - AUTOIT_PUBLICATION_YOLO_v1.0.au3

2 - autoyolo.dll

3 - AutoYOLO3.au3

4 - opencv_videoio_ffmpeg430_64.dll

5 - opencv_world430.dll

6 - opencv_world430d.dll

 

 

 

The requirements are those shown by smartee, to which I thank for the excellent contribution.

https://www.autoitscript.com/forum/topic/202987-real-time-object-detection-using-yolov3-wrapper

 

 

 

 

 

 

 

 

 

AUTOIT_PUBLICATION_YOLO_v1.0.au3

Link to comment
Share on other sites

  • 3 months later...

Hello,

I have downloaded the DLL with the AutoIT library and the examples, plus everything needed to make it work.

But I would like to know if there is a 32-bit version of the DLL for AutoIT from Yolo3. And in case it does not exist, if it would be possible that its author compiles it for 32 bits; or that he provides the code, with the instructions to make the compilation (I do not know if to compile the DLL for 32 bits will suppose much work of adaptation of the code).

In case of being able to have the version of 32 bits of the DLL, would the same Yolo3 files that I already have work, or would I have to download others for 32 bits? And with those of OpenCV; would those that I already have work, or would I have to look for the equivalent ones for 32 bits?

Best regards

Link to comment
Share on other sites

  • 3 years later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...