DigitalLocksmith Posted July 11, 2007 Posted July 11, 2007 Ok, I can get the coordinates to write to the same column, but for some reason I'm having trouble getting x in column0 and y in column1 and so on like this... [col0],[col1] 149, 248 164, 326 112, 543 This is where I started but it's returning a blank array. CODE#include<Array.au3> Dim $avArray[10][2] While 1 $coord = PixelSearch(0, 0, 320, 240, 0xFFFF00, 10) If @error Then Sleep(1000) Else MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1], 3) _ArrayAdd($avArray[0][0], $coord[0]) _ArrayAdd($avArray[0][1], $coord[1]) _ArrayDisplay( $avArray, "Whole array" ) EndIf WEnd
the_lord_mephy Posted July 11, 2007 Posted July 11, 2007 why not just do $avArray[0][0] = $coord[0] $avArray[0][1] = $coord[1] not sure, but your #include<Array.au3> doesn't have a space between include and < My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
mikehunt114 Posted July 11, 2007 Posted July 11, 2007 (edited) If you add this in your loop, it will add an x and y element each time:$avArray[$count][0] = $coord[0] $avArray[$count][1] = $coord[1] $count += 1You have to initialize $count as 0 outside your loop.However, I don't see how this script will work. Are you aware that PixelSearch only returns the first found pixel, so you'll be finding the same coordinates repeatedly? Edited July 11, 2007 by mikehunt114 IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
DigitalLocksmith Posted July 11, 2007 Author Posted July 11, 2007 Oh, wow...So you're saying that there is no way to return all pixels found of a given color? I hope not. This was going to be sweet. I'm working on a motion sensor script for webcams that can identify a specific signature. It's almost a crude facial recognition breakthrough. This is why I want to plot and compare the #FFFF00 yellow array coordinates signatures. Now I'm sure you understand why. Is there any way to make this happen with autoit?
evilertoaster Posted July 11, 2007 Posted July 11, 2007 (edited) PixelSearch() looks for the 1st occurence of a given color. If you already know the color, loop though with PixelGetColor() and check each pixel agianst whatever color your looking for, if it matches add it to your array. Edited July 11, 2007 by evilertoaster
DigitalLocksmith Posted July 11, 2007 Author Posted July 11, 2007 Good idea...I'm going to check that out while I think...
Moderators SmOke_N Posted July 11, 2007 Moderators Posted July 11, 2007 http://www.autoitscript.com/forum/index.ph...st&p=266683 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
DigitalLocksmith Posted July 11, 2007 Author Posted July 11, 2007 (edited) Awesome, SmOke_N....Got it working...Can these arrays be compared, though...Let me get deeper into what I'm trying to do. If you look at the picture of the hand on my last post, you'll notice the yellow outline. What I hope to accomplish is to recognize the hand even if you move the hand farther from the camera, causing it to be smaller in the captured image. Technically, even though the hand is smaller, it retains the same relative shape. I'd like to figure out a way to use a ratio, -/+ a certain % threshold by comparing (array values * ratio) to determine that it is still a hand even though the size has changed. This has to be possible. Any suggestions? Edited July 11, 2007 by DigitalLocksmith
mikehunt114 Posted July 11, 2007 Posted July 11, 2007 Awesome, SmOke_N....Got it working...Can these arrays be compared, though...Sure they can. You just need to figure out what to compare it to IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Moderators SmOke_N Posted July 11, 2007 Moderators Posted July 11, 2007 Awesome, SmOke_N....Got it working...Can these arrays be compared, though... Compared to what? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
DigitalLocksmith Posted July 11, 2007 Author Posted July 11, 2007 (edited) Let me get deeper into what I'm trying to do. If you look at the picture of the hand on my last post, you'll notice the yellow outline. What I hope to accomplish is to recognize the hand even if you move the hand farther from the camera, causing it to be smaller in the captured image. Technically, even though the hand is smaller, it retains the same relative shape. I'd like to figure out a way to use a ratio, -/+ a certain % threshold by comparing (array values * ratio) to determine that it is still a hand even though the size has changed. This has to be mathematically possible. Any suggestions? Edited July 11, 2007 by DigitalLocksmith
mikehunt114 Posted July 11, 2007 Posted July 11, 2007 Would PixelCheckSum be appropriate? IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
DigitalLocksmith Posted July 11, 2007 Author Posted July 11, 2007 Pixel checksum isn't going to work well enough for this because it always changes. I have the exact color dialed in, I just need to figure out a way to compare the arrays on different scales if that makes any sense. I can already get it to recognize movement and take what ever action, but I want to take it further by having the ability to make a decision based on the shape, or what it sees. Not just that it sees movement. This is going to be amazing if I can ever get it to work. I have a few other things in mind already like a completely automated paintball turret. When you walk by, you get unloaded on!
Moderators SmOke_N Posted July 11, 2007 Moderators Posted July 11, 2007 Pixel checksum isn't going to work well enough for this because it always changes. I have the exact color dialed in, I just need to figure out a way to compare the arrays on different scales if that makes any sense. I can already get it to recognize movement and take what ever action, but I want to take it further by having the ability to make a decision based on the shape, or what it sees. Not just that it sees movement. This is going to be amazing if I can ever get it to work. I have a few other things in mind already like a completely automated paintball turret. When you walk by, you get unloaded on!Why not just make an array of every size possible, then make that an array a string, then compare the arrays to the array received that way?Or as mike suggested, do a pixelchecksum of every possible size, and compare that way... The issue I can definately see you running into is speed doing it the way I think you are suggesting. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
DigitalLocksmith Posted July 11, 2007 Author Posted July 11, 2007 Ok, I think I understand where you're going with that. I guess I could start with the array signature for the largest "hand" and subtract 1 from every value per array...? Then see if it falls into a relative size of one of those arrays? This is going to be complicated and speed will be an issue. I guess it doesn't have to be real time as long as it works. You could still use captured video, I guess. Maybe a combo pixelgetcolor and pixelchecksum will work. This may be too much for it to handle.
DigitalLocksmith Posted July 11, 2007 Author Posted July 11, 2007 (edited) Smoke, how can I add all of the values of the 2 columns seperately and divide (average) by the number of elements in each column? Also, Filewrite from array isn't working...I'm researching, I'm just turning up nothing. Like: add all column0 = Whatever/number of elements add all column1 = Whatever/number of elements With this code: CODE#include<Array.au3> #include <File.au3> Sleep(3000) $poop = 0 While $poop <10 $array = _PixelSearchEx(0, 0, 320, 240, 0xFFFF00) If @error Then Exit EndIf $poop = $poop + 1 WEnd _FileWriteFromArray("fan club.txt", $array, 1) _ArrayDisplay($array) Func _PixelSearchEx($xTop, $yTop, $xBottom, $yBottom, $nColor, $iShade = 0, $iStep = 1) Local $aPix, $aCoords, $nYAdd, $iAdd For $xCC = $xTop To $xBottom $nYAdd = 0 While $nYAdd <= $yBottom $aPix = PixelSearch($xCC, $yTop + $nYAdd, $xCC, $yBottom, $nColor, $iShade, $iStep) If Not IsArray($aPix) Then ExitLoop If Not IsArray($aCoords) Then Local $aCoords[1][2] $nYAdd += ($aPix[1] - $yTop) + 1 $iAdd += 1 ReDim $aCoords[$iAdd + 1][2] $aCoords[$iAdd][0] = $aPix[0] $aCoords[$iAdd][1] = $aPix[1] WEnd Next If IsArray($aCoords) Then Return $aCoords Return SetError(1, 0, 0) EndFunc Func _ArrayDisplay2D($aArray, $sTitle = 'Array Display 2Dim', $iBase = 1, $sToConsole = 0) If Not IsArray($aArray) Then Return SetError(1, 0, 0) Local $sHold = 'Dimension 1 Has: ' & UBound($aArray, 1) -1 & ' Element(s)' & @LF & _ 'Dimension 2 Has: ' & UBound($aArray, 2) - 1 & ' Element(s)' & @LF & @LF For $iCC = $iBase To UBound($aArray, 1) - 1 For $xCC = 0 To UBound($aArray, 2) - 1 $sHold &= '[' & $iCC & '][' & $xCC & '] = ' & $aArray[$iCC][$xCC] & @LF Next Next If $sToConsole Then Return ConsoleWrite(@LF & $sHold) Return MsgBox(262144, $sTitle, StringTrimRight($sHold, 1)) EndFunc Edited July 11, 2007 by DigitalLocksmith
Moderators SmOke_N Posted July 11, 2007 Moderators Posted July 11, 2007 1. I believe _FileWriteFromArray() only works on 1 dimensional arrays. 2. I have no idea what you are really asking... and would hate to waste the brain power to just figure out I was going down the wrong path. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now