<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Определение точных координат центра лица на картинке]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14981&amp;type=atom" />
	<updated>2019-09-24T08:40:58Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14981</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136169#p136169" />
			<content type="html"><![CDATA[<p>Malcev, понятно.<br />Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-24T08:40:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136169#p136169</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136168#p136168" />
			<content type="html"><![CDATA[<p>По второму кругу?<br /><a href="http://forum.script-coding.com/viewtopic.php?id=14447">http://forum.script-coding.com/viewtopic.php?id=14447</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-09-24T07:57:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136168#p136168</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136167#p136167" />
			<content type="html"><![CDATA[<p>Понятно.<br /> Теперь скрипт выглядит вот так:<br /></p><div class="codebox"><pre><code>koordX :=x+w/2
koordY :=y+h/2

FileAppend,
(
 %koordX%
 %koordY%
), My File.txt </code></pre></div><p>Но скрипт теперь не перезаписывает файл My File.txt <br />а нагромождает там - все в кучу.</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-24T07:50:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136167#p136167</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136166#p136166" />
			<content type="html"><![CDATA[<p>Почитайте в чем разница между текстом и переменными.<br />Если и после этого не получится, то на форуме есть поиск - посмотрите примеры использования данной команды.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-09-24T07:33:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136166#p136166</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136165#p136165" />
			<content type="html"><![CDATA[<p>Malcev, пример взят как раз из той самой справки, о которой вы говорили.<br />http://ahk-wiki.ru/fileappend</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-24T06:51:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136165#p136165</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136164#p136164" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ОсиповаТатьяна пишет:</cite><blockquote><p>Как же изменить скрипт, чтобы он вычислял и прописывал в файле численные координаты ?</p></blockquote></div><p>Почитать таки справку.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-09-24T06:23:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136164#p136164</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136163#p136163" />
			<content type="html"><![CDATA[<p>Malcev,<br />Получился вот такой скрипт:<br /></p><div class="codebox"><pre><code>
file := &quot;lena.jpg&quot;
window := &quot;gui&quot;
haarcascade := &quot;haarcascade_frontalface_default.xml&quot;
scale := 1.3


;start dll opencv
Global opencv_core := &quot;opencv_core2413.dll&quot;
Global opencv_highgui := &quot;opencv_highgui2413.dll&quot;
Global opencv_imgproc := &quot;opencv_imgproc2413.dll&quot;
Global opencv_objdetect := &quot;opencv_objdetect2413.dll&quot;
_OpenCV_Startup()

;//load haar data
cascade := _cvLoad(haarcascade)

;// load IPL type image
pimg := _cvLoadImage(file)

;// show our input image
_cvShowImage(window, pimg)

;// Create destination images
pimgGrayScale := _cvCreateImage(_cvGetSize(pimg, width, height), 8, 1)
pimgsmall := _cvCreateImage(_cvSize(Round(width/scale), Round(height/scale)), 8, 1)

;//converting the original image into grayscale, resize, and equalize
_cvCvtColor(pimg, pimgGrayScale, CV_BGR2GRAY := 6)
_cvResize(pimgGrayScale, pimgsmall, CV_INTER_LINEAR := 1)
_cvEqualizeHist(pimgsmall, pimgsmall)

; //setup memory block for sequence storage
pstorage := _cvCreateMemStorage(0)   ; //storage area for all contours
_cvClearMemStorage(pstorage)

;// Detect features using haar cascades store as CvSeq
objects := _cvHaarDetectObjects(pimgsmall, cascade, pstorage, 1.1, 8, 0, _cvSize(30, 30))

;// Draw rectangles around detected features
loop % NumGet(objects+0, 8+A_PtrSize*4, &quot;int&quot;)   ;  total found
{
   r := _cvGetSeqElem(objects, A_Index)
   x := NumGet(r+0, 0, &quot;int&quot;)*scale
   y := NumGet(r+0, 4, &quot;int&quot;)*scale
   w := NumGet(r+0, 8, &quot;int&quot;)*scale
   h := NumGet(r+0, 12, &quot;int&quot;)*scale


FileAppend,
(
x+w/2
y+h/2
), My File.txt 


   _cvRectangle(pimg, _cvPoint(x, y), _cvPoint(x+w, y+h), _CV_RGB(255, 0, 0), 2, 8, 0)

   ;// Update input image
   _cvShowImage(window, pimg)
}
msgbox done

_cvReleaseImage(pimgsmall)
_cvReleaseImage(pimgGrayScale)
_cvReleaseImage(pimg)
_cvDestroyAllWindows()
_cvClearMemStorage(pstorage)
_cvClearSeq(objects)
_Opencv_CloseDLL()
ExitApp






_OpenCV_Startup()
{
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_core, &quot;Ptr&quot;)
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_highgui, &quot;Ptr&quot;)
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_imgproc, &quot;Ptr&quot;)
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_objdetect, &quot;Ptr&quot;)
}

_cvLoadImage(filename, iscolor := 1)  ;  CV_LOAD_IMAGE_COLOR
{
   Result := DllCall(opencv_highgui &quot;\cvLoadImage&quot;, &quot;AStr&quot;, filename, &quot;int&quot;, iscolor, &quot;Cdecl Int&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvNamedWindow(name, flags := 0x00000001)   ;   CV_WINDOW_AUTOSIZE 
{
   DllCall(opencv_highgui &quot;\cvNamedWindow&quot;, &quot;AStr&quot;, name, &quot;int&quot;, flags, &quot;Cdecl Int&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvShowImage(name, pimage)
{
   DllCall(opencv_highgui &quot;\cvShowImage&quot;, &quot;AStr&quot;, name, &quot;ptr&quot;, pimage, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvGetSize(pimage, ByRef width := 0, ByRef height := 0)
{
   WidthHeight := DllCall(opencv_core &quot;\cvGetSize&quot;, &quot;ptr&quot;, pimage, &quot;Cdecl int64&quot;)
   width := 0xFFFFFFFF &amp; WidthHeight
   height := WidthHeight &gt;&gt; 32
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return WidthHeight
}

_cvCreateMat(cvrows, cvcols, cvtype)
{
   Result := DllCall(opencv_core &quot;\cvCreateMat&quot;, &quot;int&quot;, cvrows, &quot;int&quot;, cvcols, &quot;int&quot;, cvtype, &quot;Cdecl ptr&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvMatchTemplate(cvimage, cvtempl, cvresult, cvmethod)
{
   DllCall(opencv_imgproc &quot;\cvMatchTemplate&quot;, &quot;ptr&quot;, cvimage, &quot;ptr&quot;, cvtempl, &quot;ptr&quot;, cvresult, &quot;int&quot;, cvmethod, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvNormalize(cvsrc, cvdst, cva, cvb, cvnorm_type, cvmask)
{
   DllCall(opencv_core &quot;\cvNormalize&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;Double&quot;, cva, &quot;Double&quot;, cvb, &quot;int&quot;, cvnorm_type, &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvThreshold(cvsrc, cvdst, cvthreshold, cvmax_value, cvthreshold_type)
{
   DllCall(opencv_imgproc &quot;\cvThreshold&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;Double&quot;, cvthreshold, &quot;Double&quot;, cvmax_value, &quot;int&quot;, cvthreshold_type, &quot;Cdecl double&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvSize(width, height)
{
   return width&amp;0xFFFFFFFF|height&lt;&lt;32
}

_cvPoint(x, y)
{
   return x&amp;0xFFFFFFFF|y&lt;&lt;32
}

_cvCreateImage(cvsize, cvdepth, cvchannels)
{
   Result := DllCall(opencv_core &quot;\cvCreateImage&quot;, &quot;int64&quot;, cvsize, &quot;int&quot;, cvdepth, &quot;int&quot;, cvchannels, &quot;Cdecl ptr&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvScalar(value)
{
   VarSetCapacity(vScalar, 32, 0)
   if IsObject(value)
   {
      loop 4
         NumPut(value%A_Index%, vScalar, (A_Index-1)*8, &quot;double&quot;)
   }
   else
   {
      loop 4
         NumPut(value, vScalar, (A_Index-1)*8, &quot;double&quot;)
   }
   return &amp;vScalar
}

_CV_RGB(cvRed, cvGreen, cvBlue)
{
   VarSetCapacity(vScalar, 32, 0)
   NumPut(cvBlue, vScalar, 0, &quot;double&quot;)
   NumPut(cvGreen, vScalar, 8, &quot;double&quot;)
   NumPut(cvRed, vScalar, 16, &quot;double&quot;)
   NumPut(0, vScalar, 24, &quot;double&quot;)
   return &amp;vScalar
}

_cvSet(cvarr, cvvalue, cvmask := 0)
{
   if (A_PtrSize = 4)
      DllCall(opencv_core &quot;\cvSet&quot;, &quot;ptr&quot;, cvarr, &quot;double&quot;, NumGet(cvvalue+0, 0, &quot;double&quot;), &quot;double&quot;, NumGet(cvvalue+0, 8, &quot;double&quot;), &quot;double&quot;, NumGet(cvvalue+0, 16, &quot;double&quot;), &quot;double&quot;, NumGet(cvvalue+0, 24, &quot;double&quot;), &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   else
      DllCall(opencv_core &quot;\cvSet&quot;, &quot;ptr&quot;, cvarr, &quot;ptr&quot;, cvvalue, &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvMinMaxLoc(cvarr, cvmin_val, cvmax_val, cvmin_loc, cvmax_loc, cvmask)
{
   DllCall(opencv_core &quot;\cvMinMaxLoc&quot;, &quot;ptr&quot;, cvarr, &quot;ptr&quot;, cvmin_val, &quot;ptr&quot;, cvmax_val, &quot;ptr&quot;, cvmin_loc, &quot;ptr&quot;, cvmax_loc, &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvRectangle(cvimg, cvpt1, cvpt2, cvcolor, cvthickness, cvline_type, cvshift)
{
   if (A_PtrSize = 4)
      DllCall(opencv_core &quot;\cvRectangle&quot;, &quot;ptr&quot;, cvimg, &quot;int64&quot;, cvpt1, &quot;int64&quot;, cvpt2, &quot;double&quot;, NumGet(cvcolor+0, 0, &quot;double&quot;), &quot;double&quot;, NumGet(cvcolor+0, 8, &quot;double&quot;), &quot;double&quot;, NumGet(cvcolor+0, 16, &quot;double&quot;), &quot;double&quot;, NumGet(cvcolor+0, 24, &quot;double&quot;), &quot;int&quot;, cvthickness, &quot;int&quot;, cvline_type, &quot;int&quot;, cvshift, &quot;Cdecl&quot;)
   else
      DllCall(opencv_core &quot;\cvRectangle&quot;, &quot;ptr&quot;, cvimg, &quot;int64&quot;, cvpt1, &quot;int64&quot;, cvpt2, &quot;ptr&quot;, cvcolor, &quot;int&quot;, cvthickness, &quot;int&quot;, cvline_type, &quot;int&quot;, cvshift, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvCvtColor(cvsrc, cvdst, cvcode)
{
   DllCall(opencv_imgproc &quot;\cvCvtColor&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;int&quot;, cvcode, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvResize(cvsrc, cvdst, cvinterpolation := 1)   ; CV_INTER_LINEAR
{
   DllCall(opencv_imgproc &quot;\cvResize&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;int&quot;, cvinterpolation, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvEqualizeHist(cvsrc, cvdst)
{
   DllCall(opencv_imgproc &quot;\cvEqualizeHist&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvLoad(cvfilename, cvmemstorage := 0, cvname := 0, cvreal_name := 0)
{
   Result := DllCall(opencv_core &quot;\cvLoad&quot;, &quot;AStr&quot;, cvfilename, &quot;ptr&quot;, cvmemstorage, &quot;ptr&quot;, cvname, &quot;ptr&quot;, cvreal_name, &quot;Cdecl ptr&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvCreateMemStorage(cvblock_size)
{
   Result := DllCall(opencv_core &quot;\cvCreateMemStorage&quot;, &quot;int&quot;, cvblock_size, &quot;Cdecl ptr&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvClearMemStorage(cvstorage)
{
   DllCall(opencv_core &quot;\cvClearMemStorage&quot;, &quot;ptr&quot;, cvstorage, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvHaarDetectObjects(cvimage, cvcascade, cvstorage, cvscale_factor := 1.1, cvmin_neighbors := 3, cvflags := 0, cvmin_size := 0, cvmax_size := 0)
{
   Result := DllCall(opencv_objdetect &quot;\cvHaarDetectObjects&quot;, &quot;ptr&quot;, cvimage, &quot;ptr&quot;, cvcascade, &quot;ptr&quot;, cvstorage, &quot;double&quot;, cvscale_factor, &quot;int&quot;, cvmin_neighbors, &quot;int&quot;, cvflags, &quot;int64&quot;, cvmin_size, &quot;int64&quot;, cvmax_size, &quot;Cdecl ptr&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvGetSeqElem(cvseq, cvindex)
{
   Result := DllCall(opencv_core &quot;\cvGetSeqElem&quot;, &quot;ptr&quot;, cvseq, &quot;int&quot;, cvindex, &quot;Cdecl ptr&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvReleaseImage(pimage)
{
   DllCall(opencv_core &quot;\cvReleaseImage&quot;, &quot;ptr*&quot;, pimage, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvReleaseMat(cvmat)
{
   DllCall(opencv_core &quot;\cvReleaseMat&quot;, &quot;ptr*&quot;, cvmat, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvDestroyAllWindows()
{
   DllCall(opencv_highgui &quot;\cvDestroyAllWindows&quot;, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvClearSeq(cvseq)
{
   DllCall(opencv_core &quot;\cvClearSeq&quot;, &quot;ptr&quot;, cvseq, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_Opencv_CloseDLL()
{
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_core)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_highgui)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_imgproc)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_objdetect)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
}

_Error(val)
{
   msgbox % val
   ExitApp
}</code></pre></div><p>Появляется файл &quot;My File.txt&quot;, но там нет координат, а просто запись:<br />x+w/2<br />y+h/2<br />Как же изменить скрипт, чтобы он вычислял и прописывал в файле численные координаты ?</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-24T05:06:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136163#p136163</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136151#p136151" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ОсиповаТатьяна пишет:</cite><blockquote><p>Это видимо будут значения x+w/2&nbsp; &nbsp;и&nbsp; y+h/2</p></blockquote></div><p>Эта часть правильна.<br />Остальное вы можете проверить сами.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-09-22T18:27:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136151#p136151</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136150#p136150" />
			<content type="html"><![CDATA[<p>Malcev, ясно.<br />Это видимо будут значения x+w/2&nbsp; &nbsp;и&nbsp; y+h/2</p><p>Команда записи этих значений в файл будет выглядеть так:<br /></p><div class="codebox"><pre><code>FileAppend,
(
x+w/2
y+h/2
), My File.txt 
</code></pre></div><p>Все правильно ?</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-22T18:15:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136150#p136150</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136134#p136134" />
			<content type="html"><![CDATA[<p>Мне знаком этот скрипт, так как я его когда-то и написал. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />После ;// Draw rectangles around detected features в цикле определяются координаты.<br />Можете сохранять их в переменную и после выхода из цикла сохранять переменную в файл.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-09-21T19:20:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136134#p136134</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136133#p136133" />
			<content type="html"><![CDATA[<p>Malcev, вот листинг скрипта:<br /></p><div class="codebox"><pre><code>
file := &quot;lena.jpg&quot;
window := &quot;gui&quot;
haarcascade := &quot;haarcascade_frontalface_default.xml&quot;
scale := 1.3


;start dll opencv
Global opencv_core := &quot;opencv_core2413.dll&quot;
Global opencv_highgui := &quot;opencv_highgui2413.dll&quot;
Global opencv_imgproc := &quot;opencv_imgproc2413.dll&quot;
Global opencv_objdetect := &quot;opencv_objdetect2413.dll&quot;
_OpenCV_Startup()

;//load haar data
cascade := _cvLoad(haarcascade)

;// load IPL type image
pimg := _cvLoadImage(file)

;// show our input image
_cvShowImage(window, pimg)

;// Create destination images
pimgGrayScale := _cvCreateImage(_cvGetSize(pimg, width, height), 8, 1)
pimgsmall := _cvCreateImage(_cvSize(Round(width/scale), Round(height/scale)), 8, 1)

;//converting the original image into grayscale, resize, and equalize
_cvCvtColor(pimg, pimgGrayScale, CV_BGR2GRAY := 6)
_cvResize(pimgGrayScale, pimgsmall, CV_INTER_LINEAR := 1)
_cvEqualizeHist(pimgsmall, pimgsmall)

; //setup memory block for sequence storage
pstorage := _cvCreateMemStorage(0)   ; //storage area for all contours
_cvClearMemStorage(pstorage)

;// Detect features using haar cascades store as CvSeq
objects := _cvHaarDetectObjects(pimgsmall, cascade, pstorage, 1.1, 8, 0, _cvSize(30, 30))

;// Draw rectangles around detected features
loop % NumGet(objects+0, 8+A_PtrSize*4, &quot;int&quot;)   ;  total found
{
   r := _cvGetSeqElem(objects, A_Index)
   x := NumGet(r+0, 0, &quot;int&quot;)*scale
   y := NumGet(r+0, 4, &quot;int&quot;)*scale
   w := NumGet(r+0, 8, &quot;int&quot;)*scale
   h := NumGet(r+0, 12, &quot;int&quot;)*scale
   _cvRectangle(pimg, _cvPoint(x, y), _cvPoint(x+w, y+h), _CV_RGB(255, 0, 0), 2, 8, 0)

   ;// Update input image
   _cvShowImage(window, pimg)
}
msgbox done

_cvReleaseImage(pimgsmall)
_cvReleaseImage(pimgGrayScale)
_cvReleaseImage(pimg)
_cvDestroyAllWindows()
_cvClearMemStorage(pstorage)
_cvClearSeq(objects)
_Opencv_CloseDLL()
ExitApp






_OpenCV_Startup()
{
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_core, &quot;Ptr&quot;)
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_highgui, &quot;Ptr&quot;)
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_imgproc, &quot;Ptr&quot;)
   DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, opencv_objdetect, &quot;Ptr&quot;)
}

_cvLoadImage(filename, iscolor := 1)  ;  CV_LOAD_IMAGE_COLOR
{
   Result := DllCall(opencv_highgui &quot;\cvLoadImage&quot;, &quot;AStr&quot;, filename, &quot;int&quot;, iscolor, &quot;Cdecl Int&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvNamedWindow(name, flags := 0x00000001)   ;   CV_WINDOW_AUTOSIZE 
{
   DllCall(opencv_highgui &quot;\cvNamedWindow&quot;, &quot;AStr&quot;, name, &quot;int&quot;, flags, &quot;Cdecl Int&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvShowImage(name, pimage)
{
   DllCall(opencv_highgui &quot;\cvShowImage&quot;, &quot;AStr&quot;, name, &quot;ptr&quot;, pimage, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvGetSize(pimage, ByRef width := 0, ByRef height := 0)
{
   WidthHeight := DllCall(opencv_core &quot;\cvGetSize&quot;, &quot;ptr&quot;, pimage, &quot;Cdecl int64&quot;)
   width := 0xFFFFFFFF &amp; WidthHeight
   height := WidthHeight &gt;&gt; 32
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return WidthHeight
}

_cvCreateMat(cvrows, cvcols, cvtype)
{
   Result := DllCall(opencv_core &quot;\cvCreateMat&quot;, &quot;int&quot;, cvrows, &quot;int&quot;, cvcols, &quot;int&quot;, cvtype, &quot;Cdecl ptr&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvMatchTemplate(cvimage, cvtempl, cvresult, cvmethod)
{
   DllCall(opencv_imgproc &quot;\cvMatchTemplate&quot;, &quot;ptr&quot;, cvimage, &quot;ptr&quot;, cvtempl, &quot;ptr&quot;, cvresult, &quot;int&quot;, cvmethod, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvNormalize(cvsrc, cvdst, cva, cvb, cvnorm_type, cvmask)
{
   DllCall(opencv_core &quot;\cvNormalize&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;Double&quot;, cva, &quot;Double&quot;, cvb, &quot;int&quot;, cvnorm_type, &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvThreshold(cvsrc, cvdst, cvthreshold, cvmax_value, cvthreshold_type)
{
   DllCall(opencv_imgproc &quot;\cvThreshold&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;Double&quot;, cvthreshold, &quot;Double&quot;, cvmax_value, &quot;int&quot;, cvthreshold_type, &quot;Cdecl double&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvSize(width, height)
{
   return width&amp;0xFFFFFFFF|height&lt;&lt;32
}

_cvPoint(x, y)
{
   return x&amp;0xFFFFFFFF|y&lt;&lt;32
}

_cvCreateImage(cvsize, cvdepth, cvchannels)
{
   Result := DllCall(opencv_core &quot;\cvCreateImage&quot;, &quot;int64&quot;, cvsize, &quot;int&quot;, cvdepth, &quot;int&quot;, cvchannels, &quot;Cdecl ptr&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvScalar(value)
{
   VarSetCapacity(vScalar, 32, 0)
   if IsObject(value)
   {
      loop 4
         NumPut(value%A_Index%, vScalar, (A_Index-1)*8, &quot;double&quot;)
   }
   else
   {
      loop 4
         NumPut(value, vScalar, (A_Index-1)*8, &quot;double&quot;)
   }
   return &amp;vScalar
}

_CV_RGB(cvRed, cvGreen, cvBlue)
{
   VarSetCapacity(vScalar, 32, 0)
   NumPut(cvBlue, vScalar, 0, &quot;double&quot;)
   NumPut(cvGreen, vScalar, 8, &quot;double&quot;)
   NumPut(cvRed, vScalar, 16, &quot;double&quot;)
   NumPut(0, vScalar, 24, &quot;double&quot;)
   return &amp;vScalar
}

_cvSet(cvarr, cvvalue, cvmask := 0)
{
   if (A_PtrSize = 4)
      DllCall(opencv_core &quot;\cvSet&quot;, &quot;ptr&quot;, cvarr, &quot;double&quot;, NumGet(cvvalue+0, 0, &quot;double&quot;), &quot;double&quot;, NumGet(cvvalue+0, 8, &quot;double&quot;), &quot;double&quot;, NumGet(cvvalue+0, 16, &quot;double&quot;), &quot;double&quot;, NumGet(cvvalue+0, 24, &quot;double&quot;), &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   else
      DllCall(opencv_core &quot;\cvSet&quot;, &quot;ptr&quot;, cvarr, &quot;ptr&quot;, cvvalue, &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvMinMaxLoc(cvarr, cvmin_val, cvmax_val, cvmin_loc, cvmax_loc, cvmask)
{
   DllCall(opencv_core &quot;\cvMinMaxLoc&quot;, &quot;ptr&quot;, cvarr, &quot;ptr&quot;, cvmin_val, &quot;ptr&quot;, cvmax_val, &quot;ptr&quot;, cvmin_loc, &quot;ptr&quot;, cvmax_loc, &quot;ptr&quot;, cvmask, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvRectangle(cvimg, cvpt1, cvpt2, cvcolor, cvthickness, cvline_type, cvshift)
{
   if (A_PtrSize = 4)
      DllCall(opencv_core &quot;\cvRectangle&quot;, &quot;ptr&quot;, cvimg, &quot;int64&quot;, cvpt1, &quot;int64&quot;, cvpt2, &quot;double&quot;, NumGet(cvcolor+0, 0, &quot;double&quot;), &quot;double&quot;, NumGet(cvcolor+0, 8, &quot;double&quot;), &quot;double&quot;, NumGet(cvcolor+0, 16, &quot;double&quot;), &quot;double&quot;, NumGet(cvcolor+0, 24, &quot;double&quot;), &quot;int&quot;, cvthickness, &quot;int&quot;, cvline_type, &quot;int&quot;, cvshift, &quot;Cdecl&quot;)
   else
      DllCall(opencv_core &quot;\cvRectangle&quot;, &quot;ptr&quot;, cvimg, &quot;int64&quot;, cvpt1, &quot;int64&quot;, cvpt2, &quot;ptr&quot;, cvcolor, &quot;int&quot;, cvthickness, &quot;int&quot;, cvline_type, &quot;int&quot;, cvshift, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvCvtColor(cvsrc, cvdst, cvcode)
{
   DllCall(opencv_imgproc &quot;\cvCvtColor&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;int&quot;, cvcode, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvResize(cvsrc, cvdst, cvinterpolation := 1)   ; CV_INTER_LINEAR
{
   DllCall(opencv_imgproc &quot;\cvResize&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;int&quot;, cvinterpolation, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvEqualizeHist(cvsrc, cvdst)
{
   DllCall(opencv_imgproc &quot;\cvEqualizeHist&quot;, &quot;ptr&quot;, cvsrc, &quot;ptr&quot;, cvdst, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvLoad(cvfilename, cvmemstorage := 0, cvname := 0, cvreal_name := 0)
{
   Result := DllCall(opencv_core &quot;\cvLoad&quot;, &quot;AStr&quot;, cvfilename, &quot;ptr&quot;, cvmemstorage, &quot;ptr&quot;, cvname, &quot;ptr&quot;, cvreal_name, &quot;Cdecl ptr&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvCreateMemStorage(cvblock_size)
{
   Result := DllCall(opencv_core &quot;\cvCreateMemStorage&quot;, &quot;int&quot;, cvblock_size, &quot;Cdecl ptr&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvClearMemStorage(cvstorage)
{
   DllCall(opencv_core &quot;\cvClearMemStorage&quot;, &quot;ptr&quot;, cvstorage, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvHaarDetectObjects(cvimage, cvcascade, cvstorage, cvscale_factor := 1.1, cvmin_neighbors := 3, cvflags := 0, cvmin_size := 0, cvmax_size := 0)
{
   Result := DllCall(opencv_objdetect &quot;\cvHaarDetectObjects&quot;, &quot;ptr&quot;, cvimage, &quot;ptr&quot;, cvcascade, &quot;ptr&quot;, cvstorage, &quot;double&quot;, cvscale_factor, &quot;int&quot;, cvmin_neighbors, &quot;int&quot;, cvflags, &quot;int64&quot;, cvmin_size, &quot;int64&quot;, cvmax_size, &quot;Cdecl ptr&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvGetSeqElem(cvseq, cvindex)
{
   Result := DllCall(opencv_core &quot;\cvGetSeqElem&quot;, &quot;ptr&quot;, cvseq, &quot;int&quot;, cvindex, &quot;Cdecl ptr&quot;)
   if !Result or ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
   return Result
}

_cvReleaseImage(pimage)
{
   DllCall(opencv_core &quot;\cvReleaseImage&quot;, &quot;ptr*&quot;, pimage, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvReleaseMat(cvmat)
{
   DllCall(opencv_core &quot;\cvReleaseMat&quot;, &quot;ptr*&quot;, cvmat, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvDestroyAllWindows()
{
   DllCall(opencv_highgui &quot;\cvDestroyAllWindows&quot;, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_cvClearSeq(cvseq)
{
   DllCall(opencv_core &quot;\cvClearSeq&quot;, &quot;ptr&quot;, cvseq, &quot;Cdecl&quot;)
   if ErrorLevel
      _Error(A_ThisFunc &quot;`n&quot; ErrorLevel)
}

_Opencv_CloseDLL()
{
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_core)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_highgui)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_imgproc)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, opencv_objdetect)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
}

_Error(val)
{
   msgbox % val
   ExitApp
}
</code></pre></div><p>Подскажите пожалуйста, куда здесь добавить команду fileappend - чтобы в txt-файл эти координаты перевести ?</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-21T19:14:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136133#p136133</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136132#p136132" />
			<content type="html"><![CDATA[<p>fileappend</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-09-21T15:56:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136132#p136132</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136131#p136131" />
			<content type="html"><![CDATA[<p>Проблема в том, чтобы в txt-файл эти координаты перевести.</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-21T15:54:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136131#p136131</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136129#p136129" />
			<content type="html"><![CDATA[<p>А в чем проблема?<br />В скрипте же явно написано в каком месте эти координаты получаются.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-09-21T15:06:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136129#p136129</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Определение точных координат центра лица на картинке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136121#p136121" />
			<content type="html"><![CDATA[<p>Добрый день.<br />Есть скрипт, который определяет положение лица на картинке.</p><p>Как сделать так, чтобы скрипт выписывал в txt файл - координаты центра этого красного квадрата (в котором определилось лицо) ?<br />В текстовом файле 1.txt - появится надпись <br />X=254<br />Y=320</p><p>Файлы лежат здесь : dropmefiles.com/ggzpR</p>]]></content>
			<author>
				<name><![CDATA[ОсиповаТатьяна]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39847</uri>
			</author>
			<updated>2019-09-21T05:11:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136121#p136121</id>
		</entry>
</feed>
