phatjk

Autoit Face Detection

Aug 26th, 2018
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.71 KB | None | 0 0
  1. #include-once
  2. #include <_httprequest.au3>
  3. #include <GDIPlus.au3>
  4. #include <String.au3>
  5. $key = 'a17062b012c34f0d9594955341feb049'
  6. Func FaceDetection($FileDir)
  7. $apiurl = 'https://api-us.faceplusplus.com/facepp/v3/detect?api_key=FGf2js-mqbFAuBcyiU0elKuWCCnO0y8K&api_secret=mexzR3twAUh8F0uRqsAoUZFKp3Sfo6bL'
  8. Local $aForm = [['$image_file', $FileDir]]
  9. $request = _HttpRequest(2,$apiurl,$aForm)
  10. Local $Return[4]=[Int(_StringBetween($request,'"left":',',')[0]),Int(_StringBetween($request,'"top":',',')[0]),Int(_StringBetween($request,'"width":',',')[0]),Int(_StringBetween($request,'"height":','}')[0])]
  11. Return $Return
  12. EndFunc
  13. Func DrawRectanglesLineImage($sFile, $nX, $nY, $nWidth, $nHeight,$OutputName='Output.jpg')
  14. _GDIPlus_Startup()
  15. Global $hImage = _GDIPlus_ImageLoadFromFile($sFile)
  16. If Not $hImage Or @error Then Exit + (_GDIPlus_Shutdown()) ;exit when the image is not supported by GDI+ (strange syntax but it works :-)
  17. Global $aDim = _GDIPlus_ImageGetDimension($hImage)
  18. Global Const $hCanvas = _GDIPlus_ImageGetGraphicsContext($hImage) ;get the canvas
  19. _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set antialiasing for the canvas to increase quality
  20. Global Const $hPen = _GDIPlus_PenCreate(0xFFFF0000) ;create a red pen (ARGB format)
  21. _GDIPlus_PenSetColor($hPen, 0xFF0000FF) ;change the pen color to blue
  22. _GDIPlus_GraphicsDrawRect($hCanvas, $nX,$nY,$nWidth,$nHeight, $hPen) ;draw a rectangle in the center
  23. Global Const $sFileSave = @ScriptDir & "\"&$OutputName
  24. _GDIPlus_ImageSaveToFile($hImage, $sFileSave) ;save the modified image
  25. ;clean up the gdiplus resources
  26. _GDIPlus_PenDispose($hPen)
  27. _GDIPlus_GraphicsDispose($hCanvas)
  28. _GDIPlus_ImageDispose($hImage)
  29. _GDIPlus_Shutdown()
  30. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment