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