Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/30/2020 in all areas

  1. Hi guys, here is a small dll wrapper I made geared at making YOLOv3 (Joseph Redmon, Ali Farhadi) more accessible to AutoIt users. Homepage of YOLO: https://pjreddie.com/darknet/yolo/ Technical overview: You only look once (YOLO) is a state-of-the-art, real-time object detection system. On a Pascal Titan X it processes images at 30 FPS and has a mAP of 57.9% on COCO test-dev. (from https://pjreddie.com/darknet/yolo/) Screenshots: Features: This UDF currently supports recognizing objects in images passed in as a HBITMAP Below is a complete list of the functions currently available in this library: ; #CURRENT# ===================================================================================================================== ;_AutoYolo3_GetLastError ;_AutoYolo3_GetObjInHBitmap ;_AutoYolo3_GetVersion ;_AutoYolo3_SetConfig ;_AutoYolo3_YoloTest ; =============================================================================================================================== The _AutoYolo3_GetObjInHBitmap function returns a 2D Array of detected objects as illustrated below: Examples: Example1: basic_example.au3 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <AutoYOLO3.au3> #include <GDIPlus.au3> ConsoleWrite("Using autoyolo version:" & _AutoYolo3_GetVersion() & @CRLF) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&"\people-2557408_1920.jpg") Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage, 0x00000000) Local $aRes = _AutoYolo3_GetObjInHBitmap($hHBITMAP) _ArrayDisplay($aRes) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Example 2: gui_example.au3 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoYOLO3.au3> #include <GDIPlus.au3> ConsoleWrite("Using autoyolo version:" & _AutoYolo3_GetVersion() & @CRLF) _GUIExample1() Func _GUIExample1()     _GDIPlus_Startup()     Local $iPicW=609     Local $iPicH=385     #Region ### START Koda GUI section ### Form=     GUICreate(@ScriptName&" - Object Detection with AutoIt!", 625, 506)     GUISetFont(14, 400, 0, "Calibri")     Local $Button1 = GUICtrlCreateButton("browse", 472, 8, 145, 33)     Local $Input1 = GUICtrlCreateInput(@ScriptDir & "\scooter-5180947_1920.jpg", 8, 8, 457, 31)     Local $Button2 = GUICtrlCreateButton("detect objects!", 228, 448, 169, 49)     Local $Pic1 = GUICtrlCreatePic("", 8, 48, $iPicW, $iPicH, $SS_BITMAP)     GUISetState(@SW_SHOW)     #EndRegion ### END Koda GUI section ###     Local $hImage = _LoadImage($Input1, $Pic1, 0, $iPicW,$iPicH)     While 1         $nMsg = GUIGetMsg()         Switch $nMsg             Case $GUI_EVENT_CLOSE                 Exit             Case $Button1                 GUICtrlSetData($Input1, FileOpenDialog("Please select image", @ScriptDir, "All (*.*)"))                 $hImage = _LoadImage($Input1, $Pic1, $hImage, $iPicW,$iPicH)             Case $Button2                 GUICtrlSetState($Button2, $GUI_DISABLE)                 GUICtrlSetData($Button2, "working..")                 Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage, 0x00000000)                 Local $aRes = _AutoYolo3_GetObjInHBitmap($hHBITMAP)                 ;_ArrayDisplay($aRes)                 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($hImage)                     _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)                     For $i = 1 To $aRes[0][0]                         ; Draw a frame around the object                         _GDIPlus_GraphicsDrawRect($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($hGraphics, $sLabel, $hFont, $tLayout, $hFormat, $hBrush)                     Next                     $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage, 0x00000000)                     GUICtrlSendMsg($Pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP)                     _GDIPlus_PenDispose($hPen)                     _GDIPlus_FontDispose($hFont)                     _GDIPlus_FontFamilyDispose($hFamily)                     _GDIPlus_StringFormatDispose($hFormat)                     _GDIPlus_BrushDispose($hBrush)                     _GDIPlus_BrushDispose($hBrushBack)                     _GDIPlus_GraphicsDispose($hGraphics)                 EndIf                 GUICtrlSetData($Button2, "detect objects!")                 GUICtrlSetState($Button2, $GUI_ENABLE)         EndSwitch     WEnd     If $hImage <> 0 Then         _GDIPlus_ImageDispose($hImage)     EndIf     _GDIPlus_Shutdown() EndFunc   ;==>_GUIExample1 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 Requirements: Windows x64, AutoIt x64 Microsoft Visual C++ 2015-2019 Redistributable (x64) - https://aka.ms/vs/16/release/vc_redist.x64.exe OpenCV binaries - https://sourceforge.net/projects/opencvlibrary/files/4.3.0/opencv-4.3.0-vc14_vc15.exe/download Quickstart: Ensure you are running Windows x64, AutoIt x64 Install Microsoft Visual C++ 2015-2019 Redistributable (x64) if not already installed - https://aka.ms/vs/16/release/vc_redist.x64.exe Create your project directory anywhere, for this example we use C:\projectdir\ Download OpenCV - https://sourceforge.net/projects/opencvlibrary/files/4.3.0/opencv-4.3.0-vc14_vc15.exe/download Unpack OpenCV anywhere and copy opencv_videoio_ffmpeg430_64.dll, opencv_world430.dll to C:\projectdir\ Download trained weights, classes, config files Weights file: Save as C:\projectdir\yolo\yolov3.weights - https://pjreddie.com/media/files/yolov3.weights Classes file: Save as C:\projectdir\yolo\yolov3.txt - https://github.com/pjreddie/darknet/blob/master/data/coco.names https://raw.githubusercontent.com/zishor/yolo-python-rtsp/master/cfg/yolov3.txt NEW Config file: Save as C:\projectdir\yolo\yolov3.cfg - https://github.com/pjreddie/darknet/blob/master/cfg/yolov3.cfg https://raw.githubusercontent.com/zishor/yolo-python-rtsp/master/cfg/yolov3.cfg NEW Unpack autoyolo1.1.zip from downloads below to your project dir So your project directory should look like: C:\projectdir\ │   autoyolo.dll │   AutoYOLO3.au3 │   basic_example.au3 │   gui_example.au3 │   opencv_videoio_ffmpeg430_64.dll │   opencv_world430.dll │   people-2557408_1920.jpg │   scooter-5180947_1920.jpg │ └───yolo         yolov3.cfg         yolov3.txt         yolov3.weights You are done! Try running one of the examples! Download: LAST UPDATED: 06-JUN-2020 autoyolo1.1.zip 785 KB Credits: YOLOv3: An Incremental Improvement - Joseph Redmon, Ali Farhad https://pjreddie.com/yolo/ https://www.learnopencv.com/deep-learning-based-object-detection-using-yolov3-with-opencv-python-c/ zishor for alternative config and classes (https://github.com/zishor/yolo-python-rtsp) MIT License FAQ: I get error "Cannot use dll" Ensure that you are running script as x64, that you have Microsoft Visual C++ 2015-2019 Redistributable (x64) installed, and that the following files are in the @ScriptDir: autoyolo.dll, opencv_videoio_ffmpeg430_64.dll, opencv_world430.dll I get a crash when clicking detect Try using the NEW config and classes links above All feedback is welcome -smartee
    2 points
  2. Hi Lars, Same thing for me. Over the weekend I spend quite a lot of time trying to get the simple .NET example going. But also no success 😞 It seems that the libraries are not yet stable enough to start building upon. If you read the simple getting started example, which promises to get everyone going in a few lines. https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms But unfortunately it did not... I am stuck at the moment to get the "WebView2Loader.dll" loaded. Anyhow if there is news I will release an update.
    2 points
  3. This weekend I've tested the AutoHotkey code on Windows 10. There are links to two different scripts in the posts above. None of these scripts works on Windows 10. So there is no code to translate to AutoIt. Of course, I've installed the Microsoft Edge Chromium version on Windows 10 and the required runtime code. The Edge version is the same on Windows 10 and Windows 7. To get ahead, it's probably easiest to look at the getting started example. The required WebView2 COM interfaces used in this example are not included in the Windows SDK and must be installed through the WebView2 NuGet package. And since these COM interfaces are also needed for tag descriptions for ObjCreateInterface() and ObjectFromTag() (for callback interfaces as in UIA Events), it makes good sense to continue with this example. The problem with this approach is that it'll be time consuming. It'll require more time than I'm interested in spending right now. Therefore, I'll not go ahead with this project. Sorry. Instead, I'll continue with the projects on rectangular selections in listviews. I'll be working on these projects through the rest of the winter. Whether I'll continue with the WebView2 project afterwards, time will tell.
    2 points
  4. Hi Nine, Long post coming (who said "as usual") I really like the way you scripted this GIF animation because you separate clearly : * all the functions in the UDF... * ...leaving very few code in the example file, which is great for the final user ! But I had an issue (from time to time) with the example file, i.e. if I drag too quickly one of the 4 gif's, then keying Esc to end the script, or in several other cases. Then sometimes a bad message appears "AutoIt must end etc..." with an exit code error in the console (always the same error code) : 3221225477 I think this error is an Access violation (Indicates that the executed program has terminated abnormally or crashed). Good news is I found why it crashed, we'll discuss it later. As you know, we got a saying "à quelque chose malheur est bon" which could translate in english by (thx google) "every cloud has a silver lining" or however unpleasant an experience can be, you will probably learn from it. And that happened to me because this error made me investigate into other scripts related to animated gifs, hoping I'll find something there that would show how these other scripts display the several frames of a gif file and compare them to your code etc... UEZ's "Play GIF Anim from memory" found in this pastebin link was a big help, because it allowed me to change 3 parts in your UDF with his code, then I never got anymore the error 3221225477 even if I run the example script dozen of times. Lines changed in your UDF : 1st part ; Global $hGIF_Animation_AdLib ; commented 2nd part : ; If Not $iIdx Then $hGIF_Animation_AdLib = AdlibRegister(__GIF_Animation_DrawTimer, 10) ; commented and replaced by : If Not $iIdx Then ; $iFPS = 25 ; UEZ's way (33 would be more precise for the GIF ballerina dancer in UEZ's script) Local $iFPS = 100 ; to match Nine's Adlib each 10ms (as 1000 / 100 = 10 in next DllCall) GUIRegisterMsg($WM_TIMER, "__GIF_Animation_DrawTimer") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", Int(1000 / $iFPS), "int", 0) ; gladly $hGUI is declared global in Nine's example file EndIf 3rd part : ; AdlibUnRegister($hGIF_Animation_AdLib) ; commented and replaced by : GUIRegisterMsg($WM_TIMER, "") After these 3 changes were applied, everything constantly worked fine, so it was now easier to find the issue : ; AdlibUnRegister($hGIF_Animation_AdLib) ; wrong statement because $hGIF_Animation_AdLib = 1 AdlibUnRegister(__GIF_Animation_DrawTimer) ; yes ! Then just changing one line in your UDF should fix it, in case other users got the same problem. Thanks for reading and I hope you enjoyed the journey
    2 points
  5. Nine

    GIF Animation (cached)

    I had this GIF animation script, but it was kind of slow when multiple GIFs were displayed. And then Bilgus posted a framework of how to use GDI+ Cached Bitmaps. I transformed my script and was very happy of the result. Hope you like it too. I enclosed the GIF, the UDF and the example into the zip file. ps. Hope KaFu won't mind as I used his avatar in the example Version 2023-08-15 * Added support for SetOnEvent GUI, while deletion of controls happens frequently * Optimized some minor code parts * Solved a possible stack overflow issue Version 2022-12-06 * Added support to transparent GIF over window background. The type of GIF that necessitate erasure between frames. Version 2022-04-07 * Added double buffering for all GIF * Added ability to erase each frame before repainting, thru a new optional parameter. This is required when the frames do not cover the whole area, leaving a trace of the previous frame. * Added support for the usage of the Default keyword for optional parameters Version 2020-12-20 * Changed frame delays from 0 to a minimum delay to prevent CPU overload Version 2020-12-02 * Reuse empty slots left by the deletion of GIF controls * Corrected bugs Version 2020-12-01 * Added support to delete a GIF control Version 2020-11-29 * Corrected bug on unregister adlib function (thanks to PixelSearch) Included in the zip file 2 examples. One with multiple GIF. Second with transparent GIF over a window background. Cached GIF Animation.zip
    1 point
  6. here is an explanation video of autoit arrays:
    1 point
  7. @Atrax27 If you want to know what are arrays and how to use them, then take a look at this topic Credits: @TheDcoder
    1 point
  8. What you might want to do is, rather than using an array, just monitor for when the value of the combo box changes, and then modify the label text based on the selection. Something like this should work: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form = GUICreate("Neato 5000", 615, 100, 190, 122) $Input = GUICtrlCreateCombo("Frankie", 0, 0, 609, 21) GUICtrlSetData($Input, "Robert|Jill|Jack|Buddy|Holly|Gerald|Charles", "Frankie") $Button = GUICtrlCreateButton("Message", 0, 24, 609, 25) $Label1 = GUICtrlCreateLabel("Red Shoes", 8, 75, 100, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input Switch GuiCtrlRead ( $input ) Case "Frankie" GUICtrlSetData ( $label1, "Label text for Frankie" ) Case "Robert" GUICtrlSetData ( $label1, "Label text for Robert" ) Case "Jill" GUICtrlSetData ( $label1, "Label text for Jill" ) Case "Jack" GUICtrlSetData ( $label1, "Label text for Jack" ) Case "Buddy" GUICtrlSetData ( $label1, "Label text for Buddy" ) Case "Holly" GUICtrlSetData ( $label1, "Label text for Holly" ) Case "Gerald" GUICtrlSetData ( $label1, "Label text for Gerald" ) Case "Charles" GUICtrlSetData ( $label1, "Label text for Charles" ) EndSwitch Case $Button Example(GUICtrlRead($Input)) EndSwitch WEnd Func Example($text) Msgbox(0,"", "Bye Bye " & GUICtrlRead($Input)) Exit EndFunc
    1 point
  9. Remove quotes around TimerTest
    1 point
  10. Please note that if the delimiter is a "|" in the file, there is maybe a simpler way #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Array.au3> #include <GuiListView.au3> ; Create file $sFileName = "Data.txt" FileDelete($sFileName) $sString = "Checked|Column 1|Column 2|Column 3|Column 4|Column 5|Column 6|Column 7|Column 8" & @CRLF & _ "×|50.01.0001|160404134631346000|Other value|T3|alphachymotrypsin|Other value|C|alpha choay 4000IU" & @CRLF & _ "×|50.01.0003|160407154252435000|Other value|T2|Paracetamol|Other value|C|Acepron 250mg" & @CRLF & _ "|50.01.0005|160415135700860000|Other value|T3|Acenocoumarol|Other value|D|Acenocumarol WPW 4mg" & @CRLF & _ "|50.01.0006|160423064434487000|Other value|T3|Acetylcystein|Other value|D|Aceblue 100mg" & @CRLF & _ "×|50.01.0007|160430993168114000|Other value|T1|Acetylcystein|Other value|C|Aceblue 200mg" FileWrite($sFileName, $sString) ;============================================ ; Create array 1D $aData = StringRegExp(FileRead($sFileName), '\N+', 3) ; delete cols 3-6 and set order 0-1-2-7-4-5-8 For $i = 0 To UBound($aData)-1 $aData[$i] = StringRegExpReplace($aData[$i], '(?x)((?:.*?\|){3}) (.*?\|) ((?:.*?\|){2}) (.*?\|) (.*?\|) (.*)', "$1$5$3$6") Next ;_ArrayDisplay($aData) $column_titles = $aData[0] _ArrayDelete($aData, 0) ;============================================ ; Create GUI $hGUI = GUICreate("Test", 800, 500) ; Create controls GUICtrlCreateLabel("Find:", 10, 30, 100, 20) $cInput = GUICtrlCreateInput("", 120, 30, 300, 20) $cSave = GUICtrlCreateButton("Save Check", 480, 10, 80, 20) $cFind = GUICtrlCreateButton("Find", 480, 30, 80, 20) ; $cFind8Only = GUICtrlCreateCheckbox(" Column 8 only", 600, 30, 200, 20) $cReset = GUICtrlCreateButton("Reset", 680, 70, 80, 20) ; Create ListView $cListView = GUICtrlCreateListView($column_titles, 10, 100, 780, 300) _GUICtrlListView_SetExtendedListViewStyle($cListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES)) For $i = 1 to _GUICtrlListView_GetColumnCount($cListView) - 1 _GUICtrlListView_SetColumnWidth ($cListView, $i, 110) Next ; Create items _ResetListview() GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cFind $search = GuiCtrlRead($cInput) If $search = "" Then ContinueLoop $aResults = _ArrayFindAll ($aData, $search, 0, 0, 0, 1) If UBound($aResults) = 0 Then Msgbox(0,"", "no results found") ContinueLoop EndIf ; _ArrayDisplay($aResults) _GUICtrlListView_DeleteAllItems($cListView) For $i = 0 To UBound($aResults)-1 GUICtrlCreateListViewItem($aData[$aResults[$i]], $cListView) If StringLeft($aData[$aResults[$i]], 1) = "×" Then _GUICtrlListView_SetItemChecked($cListView, $i) _GUICtrlListView_SetItemText($cListView, $i, "") EndIf Next Case $cReset _GUICtrlListView_DeleteAllItems($cListView) _ResetListview() EndSwitch WEnd Func _ResetListview() For $i = 0 to UBound($aData)-1 GUICtrlCreateListViewItem($aData[$i], $cListView) If StringLeft($aData[$i], 1) = "×" Then ; Check the checkboxes to match the data _GUICtrlListView_SetItemChecked($cListView, $i) _GUICtrlListView_SetItemText($cListView, $i, "") EndIf Next EndFunc
    1 point
×
×
  • Create New...