je désire créer un script pour compter les voiture a certains endroit précis de mon écran (voiture prise par camera) j'ai essayé de faire un pixelgetcolor mais trop précis pour ma recherche vu que les pixels ne sont pas toujours de la même couleur (le gris de la route change tout le temps a cause de la lumière et de la mauvaise caméra) j'ai testé aussi la fonction suivante:
-http://autoitscript.fr/forum/viewtopic.php?f=21&t=4433
avec _Color_GetNumber
mais je n'arrive pas à bien l'utiliser.
Ps: je désire un mousegetpos pour détecter l'emplacement du point en haut a gauche et en bas a droite du rectangle à détecter(Les voitures sont sures de passer a plus de 50% dedans).Et un autre pour la couleur(normalement gris mais sur certaines camera vert).Les camera sont en couleurs même sur les camera vertes.
J'ai fait un code pour compter en manuelle qui prend 3 position une seule suffit si c'est automatique.
► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F1}", "compteur");demarrage rapide du compteur
Global $input, $input2, $input3, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $nom1, $pause, $label, $penrg, $position1, $position2, $position3, $compte, $compte2, $compte3, $compte4
$Enregistrement = GUICreate("Enregistrement", 564, 110, 190, 120);création d'un gui
$Camera = GUICtrlCreateInput("1", 80, 8, 57, 21)
$hr = GUICtrlCreateInput(@HOUR, 217, 8, 45, 21)
$Camera1 = GUICtrlCreateLabel("Camera :", 8, 8, 48, 17)
$Heure = GUICtrlCreateLabel("Heure :", 168, 8, 49, 17)
$Mn = GUICtrlCreateInput(@MIN, 262, 8, 45, 21)
$se = GUICtrlCreateInput(@SEC, 307, 8, 45, 21)
$Date = GUICtrlCreateLabel("Date", 8, 40, 35, 17)
$jr = GUICtrlCreateInput(@MDAY, 48, 40, 45, 21)
$moi = GUICtrlCreateInput(@MON, 96, 40, 45, 21)
$an = GUICtrlCreateInput(@YEAR, 144, 40, 41, 21)
$nom = GUICtrlCreateLabel("Camera_jour_mois_annee.csv", 8, 80, 368, 17)
$go = GUICtrlCreateButton("Go", 232, 40, 121, 50)
$position1a = GUICtrlCreateInput("Position 1", 440, 8, 113, 21)
$position2a = GUICtrlCreateInput("Position 2", 440, 40, 113, 21)
$position3a = GUICtrlCreateInput("Position 3", 440, 72, 113, 21)
$Label1 = GUICtrlCreateLabel("Position 1 =", 368, 8, 68, 17)
$Label2 = GUICtrlCreateLabel("Position 2 =", 368, 40, 68, 17)
$Label3 = GUICtrlCreateLabel("Position 3 =", 368, 72, 68, 17)
$updownm = GUICtrlCreateUpdown($moi)
$updownj = GUICtrlCreateUpdown($jr)
$updowns = GUICtrlCreateUpdown($se)
$updownh = GUICtrlCreateUpdown($hr)
$updownmn = GUICtrlCreateUpdown($Mn)
GUISetState()
$a = 1
$b = @MDAY
$c = @MON
$d = @YEAR
While 1
$msg = GUIGetMsg()
If $msg = $go Then Call("compteur")
If $msg = $GUI_EVENT_CLOSE Then Exit
If GUICtrlRead($Camera) = $a Then
Else
$a = GUICtrlRead($Camera)
GUICtrlSetData($nom, "C" & $a & "_" & $b & "_" & $c & "_" & $d & ".csv")
$nom1 = GUICtrlRead($nom)
EndIf
If GUICtrlRead($jr) = $b Then
Else
$b = GUICtrlRead($jr)
GUICtrlSetData($nom, "C" & $a & "_" & $b & "_" & $c & "_" & $d & ".csv")
$nom1 = GUICtrlRead($nom)
EndIf
If GUICtrlRead($moi) = $c Then
Else
$c = GUICtrlRead($moi)
GUICtrlSetData($nom, "C" & $a & "_" & $b & "_" & $c & "_" & $d & ".csv")
$nom1 = GUICtrlRead($nom)
EndIf
If GUICtrlRead($an) = $d Then
Else
$d = GUICtrlRead($an)
GUICtrlSetData($nom, "C" & $a & "_" & $b & "_" & $c & "_" & $d & ".csv")
$nom1 = GUICtrlRead($nom)
EndIf
WEnd
Func compteur()
$position1 = GUICtrlRead($position1a)
$position2 = GUICtrlRead($position2a)
$position3 = GUICtrlRead($position3a)
$m = @HOUR * 3600 + @MIN * 60 + @SEC
$e = GUICtrlRead($hr)
$f = GUICtrlRead($Mn)
$g = GUICtrlRead($se)
$l = $e * 3600 + $f * 60 + $g
GUIDelete()
$gui = GUICreate("compteur", 100, 140, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))
$compte = 1
HotKeySet("&", "a")
HotKeySet("é", "b")
HotKeySet('"', "c")
HotKeySet("1", "a")
HotKeySet("2", "b")
HotKeySet('3', "c")
HotKeySet("{left}", "a")
HotKeySet("{up}", "b")
HotKeySet("{right}", "c")
HotKeySet("{F2}", "pause")
$input = GUICtrlCreateInput("0", 0, 0, 100, 20)
GUICtrlCreateLabel($position1, 25, 20, 100, 20)
$updown = GUICtrlCreateUpdown($input)
$input2 = GUICtrlCreateInput("0", 0, 40, 100, 20)
GUICtrlCreateLabel($position2, 25, 60, 100, 20)
$updown2 = GUICtrlCreateUpdown($input2)
$input3 = GUICtrlCreateInput("0", 0, 80, 100, 20)
GUICtrlCreateLabel($position3, 25, 100, 100, 20)
$updown3 = GUICtrlCreateUpdown($input3)
$label = GUICtrlCreateLabel("Pause = F2", 25, 120, 100, 20)
WinSetOnTop("compteur", "", 1)
GUISwitch($gui)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then
$compte4 = $compte + $compte2 + $compte3
FileWriteLine(@ScriptDir & "\" & $nom1, "")
FileWriteLine(@ScriptDir & "\" & $nom1, "Total;" & $compte4)
FileWriteLine(@ScriptDir & "\" & $nom1, $position1 & ";" & $compte)
FileWriteLine(@ScriptDir & "\" & $nom1, $position2 & ";" & $compte2)
FileWriteLine(@ScriptDir & "\" & $nom1, $position3 & ";" & $compte3)
Exit
EndIf
WEnd
EndFunc ;==>compteur
Func a()
$k = @HOUR * 3600 + @MIN * 60 + @SEC
$n = $k - $m + $l
$compte = GUICtrlRead($input)
$compte = $compte + 1
GUICtrlSetData($input, $compte)
FileWriteLine(@ScriptDir & "\" & $nom1, $position1 & ";" & _ajuster_temps($n))
EndFunc ;==>a
Func b()
$k = @HOUR * 3600 + @MIN * 60 + @SEC
$n = $k - $m + $l
$compte2 = GUICtrlRead($input2)
$compte2 = $compte2 + 1
GUICtrlSetData($input2, $compte2)
FileWriteLine(@ScriptDir & "\" & $nom1, $position2 & ";" & _ajuster_temps($n))
EndFunc ;==>b
Func c()
$k = @HOUR * 3600 + @MIN * 60 + @SEC
$n = $k - $m + $l
$compte3 = GUICtrlRead($input3)
$compte3 = $compte3 + 1
GUICtrlSetData($input3, $compte3)
FileWriteLine(@ScriptDir & "\" & $nom1, $position3 & ";" & _ajuster_temps($n))
EndFunc ;==>c
Func pause()
$l = $n
GUICtrlSetData($label, _ajuster_temps($n))
$pause = Not $pause
While $pause
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
GUICtrlSetData($label, "Pause = F2")
$m = @HOUR * 3600 + @MIN * 60 + @SEC
EndFunc ;==>pause
Func _ajuster_temps($func_temps)
;$func_temps en secondes
$func_temps = Number($func_temps)
If $func_temps = 1 Then
Return "1"
ElseIf $func_temps < 60 Then
Return $func_temps
ElseIf $func_temps = 60 Then
Return "00:00:01"
ElseIf $func_temps < 3600 And Mod($func_temps, 60) = 0 Then
Return "00:00:" & Int($func_temps / 60)
ElseIf $func_temps < 3600 Then
Return "OO:" & Int($func_temps / 60) & ":" & Mod($func_temps, 60)
ElseIf $func_temps = 3600 Then
Return "00:01:00"
ElseIf $func_temps < 86400 And Mod($func_temps, 60) = 0 And Mod($func_temps, 3600) = 0 Then
Return "OO:" & Int($func_temps / 3600) & ":00"
ElseIf $func_temps < 86400 And Mod($func_temps, 60) = 0 Then
Return Int($func_temps / 3600) & ":" & Mod(Int($func_temps / 60), 60) & ":00"
ElseIf $func_temps < 86400 Then
Return Int($func_temps / 3600) & ":" & Mod(Int($func_temps / 60), 60) & ":" & Mod($func_temps, 60)
Else
Return $func_temps
EndIf
EndFunc ;==>_ajuster_temps

