<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: OpenCV com]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17642&amp;type=atom" />
	<updated>2023-03-10T12:31:46Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=17642</id>
		<entry>
			<title type="html"><![CDATA[AHK: OpenCV com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=157070#p157070" />
			<content type="html"><![CDATA[<p><a href="https://www.autoitscript.com/forum/topic/206432-opencv-v4-udf">https://www.autoitscript.com/forum/topi … ncv-v4-udf</a><br />На автохотки пользоваться как-то так:<br /></p><div class="codebox"><pre><code>opencv_world_path := A_ScriptDir &quot;\opencv-4.7.0-windows\opencv\build\x64\vc16\bin\opencv_world470.dll&quot;
opencv_ffmpeg_path := A_ScriptDir &quot;\opencv-4.7.0-windows\opencv\build\x64\vc16\bin\opencv_videoio_ffmpeg470_64.dll&quot;
autoit_opencv_com_path := A_ScriptDir &quot;\autoit-opencv-com\autoit_opencv_com470.dll&quot;

hOpencv := DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, opencv_world_path, &quot;ptr&quot;)
hOpencvFfmpeg := DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, opencv_ffmpeg_path, &quot;ptr&quot;)
hOpencvCom := DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, autoit_opencv_com_path, &quot;ptr&quot;)
ComObjCreate := Func(&quot;_ComObjCreate&quot;).Bind(autoit_opencv_com_path)

; ком объект создаем через Call
cv := ComObjCreate.Call(&quot;OpenCV.cv&quot;)
img := cv.imread(&quot;D:\Unnamed.bmp&quot;)
cv.imshow(&quot;Image&quot;, img)
cv.waitKey()
cv.destroyAllWindows()
return


_ComObjCreate(opencvPath, comobject)
{
   DllCall(opencvPath &quot;\DllActivateManifest&quot;)
   comobject := ComObjCreate(comobject)
   DllCall(opencvPath &quot;\DllDeactivateActCtx&quot;)
   return comobject
}</code></pre></div><p>Рисование контура:<br /></p><div class="codebox"><pre><code>cv := ComObjCreate.Call(&quot;OpenCV.cv&quot;)
img := cv.imread(&quot;D:\Unnamed.bmp&quot;)
img_grey := cv.cvtColor(img, CV_COLOR_BGR2GRAY := 6)
cv.threshold(img_grey, 100, 255, CV_THRESH_BINARY := 0)
thresh := cv.extended.1
contours := cv.findContours(thresh, CV_RETR_TREE := 3, CV_CHAIN_APPROX_SIMPLE := 2)
arr := ComObjArray(VT_VARIANT:=12, 4)
arr[0] := 0
arr[1] := 0
arr[2] := 255
arr[3] := 0
cv.drawContours(img, contours, -1, arr, 2)
cv.imshow(&quot;Image&quot;, img)
cv.waitKey()
cv.destroyAllWindows()
return


_ComObjCreate(opencvPath, comobject)
{
   DllCall(opencvPath &quot;\DllActivateManifest&quot;)
   comobject := ComObjCreate(comobject)
   DllCall(opencvPath &quot;\DllDeactivateActCtx&quot;)
   return comobject
}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=16712">Тема для обсуждения</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-03-10T12:31:46Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=157070#p157070</id>
		</entry>
</feed>
