joncom Posted April 17, 2005 Posted April 17, 2005 (edited) I would like to somehow make a type of motion detect system that will perform specific functions when there is movement on certain areas of the screen. I've searched around, and it appears this has never been done before, so I'm hoping that a few develeopers and myself might be able to pull off something new here.First off, feel free to interupt me if you feel there is a better way of doing this, but this is what I'm sort or thinking in my head (might be a little cpu hungry).THE PLAN:Run a loop that will go through a series of pixel's, grabbing the pixel color, and storing it in an array. The min/max X and Y value's would have to be set before the loop.After it grabs a section of the screen's pixels, it would wait/(or immediately?) run through the loop again, check if any of the pixel colors have changed. Now, in the situation I intend to use the script for, there is SLIGHT color changes (lighting effects) occuring all the time. I'm pretty sure that you can have a color range though, so the color number of "Dark Dark Blue" would be closer to "Dark Blue" than lets say "Red" would... this leaves room to give the script some slack. We could just do something like: if ($pixelColor - 1000) < $currentColor > ($pixelColor + 1000)Excuse any improper syntax, its just to get the idea across...ANYWAYS, that's just me brain storming.... I'd appreciate your thoughts, let me know if you think this would work, any changes you might suggest, etc...Thanks Edited April 17, 2005 by joncom
joncom Posted April 17, 2005 Author Posted April 17, 2005 This would bring up the question of how to make sure that it takes into consideration slight lighting effects... using this function, a single pixel changing seems to complete alter the checksum value significantly.... I need the detection to pick up on significant movement... not slight...
quaizywabbit Posted April 18, 2005 Posted April 18, 2005 This would bring up the question of how to make sure that it takes into consideration slight lighting effects... using this function, a single pixel changing seems to complete alter the checksum value significantly....I need the detection to pick up on significant movement... not slight...<{POST_SNAPBACK}>working with security cam video? [u]Do more with pre-existing apps![/u]ANYGUIv2.8
joncom Posted April 18, 2005 Author Posted April 18, 2005 No, just detecting motion on screen... like if you took a window, and drags it in front of the motion area, it would detect the significant change.... but if the color of the area just changed slightly, it would notice the change, but be smart enough to just ignore it.
steveR Posted April 18, 2005 Posted April 18, 2005 I played around with this one morning. It latches on to the pixel color and can track it.It will search the last position fo the pixel color in a widening box until it finds it. The searching could be improved so it doesn't search the same area twice.But it was interesting fooling around with it.#68445 AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
joncom Posted April 18, 2005 Author Posted April 18, 2005 Thanks, but I'm not looking for a single pixel, or even a pixel color... The pixelcolors that I store, and constantly changing slightly due to lighting effects in the game. Have you ever seen a motion capture camera program... how you can set the sensitivity.. I need somethign sort of like that, how it can see that there is motion, and I can specify how intense the motion must be before it acts upon it.
zeroZshadow Posted April 18, 2005 Posted April 18, 2005 you mean ur just making a auto-shooter??? then it will be of no use, because the pixel search is to slow i tryed this allready for a insta-gib game, and it shoot 0.3 sec after seeing a person and that just to slow. (frikking bunny hoppers) *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
joncom Posted April 19, 2005 Author Posted April 19, 2005 its not for a shooter game.... speed isn't critical.. in fact .3 sec would be quite good...
zeroZshadow Posted April 19, 2005 Posted April 19, 2005 3 sec?? then it'll be possible, but don't scan an area that big, because it will eat ya cpu. where is is for anyway? *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
buzz44 Posted April 19, 2005 Posted April 19, 2005 (edited) I need the detection to pick up on significant movement... not slight...PixelChecksum ( left, top, right, bottom [, step] ) When using a step value greater than 1 you must bear in mind that the checksumming becomes less reliable for small changes as not every pixel is checked.Couldn't you just change the step value to a larger number? Edited April 19, 2005 by Burrup qq
zeroZshadow Posted April 19, 2005 Posted April 19, 2005 I THINK THAT AIN;T GOOD checking colours would be better, because you can set the shades there. so it would be better with the Lights, he was talking about *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
CodeMaster Rapture Posted April 20, 2005 Posted April 20, 2005 You'll want to use PixelGetColor and save some colors to variables and then figure out your thresh-hold for "motion" be it 100 shades ot 10000 shades of that color. It can be done pretty simple, just a bit CPU intensive. I've done this a few times with odd results. The problem is, the built in pixel functions are really horrible (just lemme get ahold of the source code, grrrr). Anyways, this might enlighten you on your goal: ;Change these to the area you want to search in PixelSearch format (top,left,right,bottom) $left = 0 $right = 0 $top = 0 $bottom = 0 While 1 ;Your loop here If Check_Motion() = 1 Then ;Do whatever on motion detected EndIf WEnd Func Check_Motion() $color = (put your initial color here) For $x = $left to $right For $y = $top to $bottom $motion_color = PixelGetColor($x,$y) If $motion_color > $color+1000 OR $motion_color < $color-1000 Then $motion = 1 ExitLoop Else $motion = 0 EndIf Next If $motion = 1 Then ExitLoop Next Return $motion EndFunc
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