<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: libfacedetection - библиотека для определения лица]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=17639</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17639&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: libfacedetection - библиотека для определения лица».]]></description>
		<lastBuildDate>Fri, 10 Mar 2023 12:22:07 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK: libfacedetection - библиотека для определения лица]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157067#p157067</link>
			<description><![CDATA[<p><a href="https://autoit.de/thread/86499-facedetection-udf/">https://autoit.de/thread/86499-facedetection-udf/</a><br />На автохотки запускать так:<br /></p><div class="codebox"><pre><code>Global libfacedetect_path := A_ScriptDir &quot;\libfacedetect-x&quot; 8*A_PtrSize &quot;.dll&quot;
image_path := &quot;G:\B0001824-Edit.jpg&quot;
libfacedetect(image_path, result)
iFaces := NumGet(result, 0, &quot;int&quot;)
msgbox % &quot;Number of faces detected: &quot; iFaces
loop % ifaces
{
   x := NumGet(result, 4 + 284*(A_Index - 1), &quot;short&quot;)
   y := NumGet(result, 6 + 284*(A_Index - 1), &quot;short&quot;)
   width := NumGet(result, 8 + 284*(A_Index - 1), &quot;short&quot;)
   height := NumGet(result, 10 + 284*(A_Index - 1), &quot;short&quot;)
   confidence := NumGet(result, 12 + 284*(A_Index - 1), &quot;short&quot;)
   angle := NumGet(result, 14 + 284*(A_Index - 1), &quot;short&quot;)
   msgbox % &quot;x: &quot; x &quot;`ny: &quot; y &quot;`nwidth: &quot; width &quot;`nheight: &quot; height &quot;`nconfidence: &quot; confidence &quot;`nangle: &quot; angle
}
msgbox done
return


libfacedetect(image_path, byref tResult, iMode := 4, fScale := 1.2, iMin_Neighbors := 1, iMin_Object_Width := 20, iMax_Object_Width := 0, bDoLandmark := 1)
{
   ; ###############################################################################################################################
   ; # iMode = 1:
   ; #    frontal face detection / 68 landmark detection
   ; #    it&#039;s fast, but cannot detect side view faces
   ; #
   ; # iMode = 2:
   ; #    frontal face detection designed for video surveillance / 68 landmark detection
   ; #    it can detect faces with bad illumination.
   ; #
   ; # iMode = 3:
   ; #    multiview face detection / 68 landmark detection
   ; #    it can detect side view faces, but slower than facedetect_frontal.
   ; #
   ; # iMode = 4:
   ; #    reinforced multiview face detection / 68 landmark detection
   ; #    it can detect side view faces, better but slower than facedetect_multiview.
   ; #
   ; # fScale:              scale factor for scan windows
   ; # iMin_Neighbors:      how many neighbors each candidate rectangle should have to retain it
   ; # iMin_Object_Width:   Minimum possible face size. Faces smaller than that are ignored.
   ; # iMax_Object_Width:   Maximum possible face size. Faces larger than that are ignored. It is the largest posible when max_object_width=0.
   ; # bDoLandmark:         landmark detection
   ; ###############################################################################################################################

   static _sFDDLL1, _sFDDLL2, _sFDDLL3, _sFDDLL4, _pFD_ASM_8BitGray, pToken
   if !_sFDDLL1
   {
      DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, libfacedetect_path, &quot;ptr&quot;)
      if (A_PtrSize = 8)
      {
         hex := &quot;5657534889CF4889D6450FAFC141B9555500008B1688D0660FB6DEC1EA086601D8660FB6DE6601D841F7E1C1E81088074883C6044883C7014183E80177D55B5F5EC3&quot;
         _sFDDLL1 := &quot;?facedetect_frontal@@YAPEAHPEAE0HHHMHHHH@Z&quot;
         _sFDDLL2 := &quot;?facedetect_frontal_surveillance@@YAPEAHPEAE0HHHMHHHH@Z&quot;
         _sFDDLL3 := &quot;?facedetect_multiview@@YAPEAHPEAE0HHHMHHHH@Z&quot;
         _sFDDLL4 := &quot;?facedetect_multiview_reinforce@@YAPEAHPEAE0HHHMHHHH@Z&quot;
      }
      else
      {
         hex := &quot;555657538B7C24148B7424188B4C241C0FAF4C2420BD555500008B1688D0660FB6DEC1EA086601D8660FB6DE6601D8F7E5C1E810880783C60483C70183E90177D95B5F5E5DC21000&quot;
         _sFDDLL1 := &quot;?facedetect_frontal@@YAPAHPAE0HHHMHHHH@Z&quot;
         _sFDDLL2 := &quot;?facedetect_frontal_surveillance@@YAPAHPAE0HHHMHHHH@Z&quot;
         _sFDDLL3 := &quot;?facedetect_multiview@@YAPAHPAE0HHHMHHHH@Z&quot;
         _sFDDLL4 := &quot;?facedetect_multiview_reinforce@@YAPAHPAE0HHHMHHHH@Z&quot;
      }
      _pFD_ASM_8BitGray := DllCall(&quot;kernel32.dll\VirtualAlloc&quot;, &quot;ptr&quot;, 0, &quot;ptr&quot;, 88-(A_PtrSize*3-12)/2, &quot;uint&quot;, MEM_COMMIT := 0x1000, &quot;uint&quot;, PAGE_EXECUTE_READWRITE := 0x40, &quot;ptr&quot;)
      _pFD_ASM_8BitGray := _pFD_ASM_8BitGray + 16 - Mod(_pFD_ASM_8BitGray, 16)
      loop, parse, hex
      {
         if ((A_Index &amp; 1) != 0)
            num := &quot;0x&quot; A_LoopField
         else
            NumPut(num A_LoopField, _pFD_ASM_8BitGray+0, A_Index/2-1, &quot;char&quot;)
      }

      DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;gdiplus&quot;)
      VarSetCapacity(si, 8+2*A_PtrSize, 0)
      NumPut(0x1, si, &quot;uint&quot;)
      DllCall(&quot;gdiplus\GdiplusStartup&quot;, &quot;ptr*&quot;, pToken, &quot;ptr&quot;, &amp;si, &quot;ptr&quot;, 0)
   }

   ; Get scan0 of bitmap
   DllCall(&quot;gdiplus\GdipCreateBitmapFromFile&quot;, &quot;wstr&quot;, image_path, &quot;ptr*&quot;, needlePbitmap)
   DllCall(&quot;gdiplus\GdipGetImageWidth&quot;, &quot;ptr&quot;, needlePbitmap, &quot;uint*&quot;, needleWidth)
   DllCall(&quot;gdiplus\GdipGetImageHeight&quot;, &quot;ptr&quot;, needlePbitmap, &quot;uint*&quot;, needleHeight)
   VarSetCapacity(needleRect, 16, 0)
   NumPut(needleWidth, needleRect, 8, &quot;uint&quot;)
   NumPut(needleHeight, needleRect, 12, &quot;uint&quot;)
   VarSetCapacity(needleBitmapData, 16+2*A_PtrSize, 0)
   DllCall(&quot;gdiplus\GdipBitmapLockBits&quot;, &quot;ptr&quot;, needlePbitmap, &quot;ptr&quot;, &amp;needleRect, &quot;uint&quot;, ReadWrite := 3, &quot;int&quot;, Format32bppRgb := 139273, &quot;ptr&quot;, &amp;needleBitmapData)
   needleStride := NumGet(needleBitmapData, 8, &quot;int&quot;)
   needleScan := NumGet(needleBitmapData, 16, &quot;ptr&quot;)

   ; convert scan0 to gray (single-channel)
   VarSetCapacity(_tFD_BmpG, needleWidth*needleHeight, 0)
   DllCall(_pFD_ASM_8BitGray, &quot;ptr&quot;, &amp;_tFD_BmpG, &quot;ptr&quot;, needleScan, &quot;int&quot;, needleWidth, &quot;int&quot;, needleHeight)

   ; find faces
   VarSetCapacity(tResult, 0x20000, 0)
   DllCall(libfacedetect_path &quot;\&quot; _sFDDLL%iMode%, &quot;ptr&quot;, &amp;tResult, &quot;ptr&quot;, &amp;_tFD_BmpG, &quot;int&quot;, needleWidth, &quot;int&quot;, needleHeight, &quot;int&quot;, needleWidth, &quot;float&quot;, fScale, &quot;int&quot;, iMin_Neighbors, &quot;int&quot;, iMin_Object_Width, &quot;int&quot;, iMax_Object_Width, &quot;int&quot;, bDoLandmark, &quot;cdecl&quot;)

   ; clear resources
   DllCall(&quot;gdiplus\GdipBitmapUnlockBits&quot;, &quot;ptr&quot;, needlePbitmap, &quot;ptr&quot;, &amp;needleBitmapData)
   DllCall(&quot;gdiplus\GdipDisposeImage&quot;, &quot;ptr&quot;, needlePbitmap)
   return
}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=17623">Тема для обсуждения</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Fri, 10 Mar 2023 12:22:07 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157067#p157067</guid>
		</item>
	</channel>
</rss>
