Jump to content

Motion Tracking and velocity


XZ3R0
 Share

Recommended Posts

In short: how can i find the velocity of an object? Right now i have 2 pixelseraches that i plug into the formula of velocity. But once i run the second search the first one gets forgotten. So whats a work around or another way to find the velocity of an object.

Another problem i thought about is if the pixelsearch doesn't find the same object the second time. this would return with unusable data.

In long: i have an array of 3 colors im searching for. I run the first pixel search. lets say it finds black. then i runs a second pixlesearch. it also finds the same black. then i get the velocity and i do what i need with it. that's my theory. but what if during the second pixelsearch it finds red instead (a different object) then the formula isn't going to work. is there a way to track an object? or even search around the same area as before but for the same color? do i need to set the returned values for the pixlesearch in an array? or should i be using something completely different?

Link to comment
Share on other sites

no. one is $search = pixelsearch(...) and the other one is $search2 = pixelsearch(...)

then if i used $search[0] the script will run into an error and say something about a non arrayed variable trying to be use as a array.

Edited by XZ3R0
Link to comment
Share on other sites

$coor1 = PixelSearch( $start[0], $start[1], $current[0], $current[1], $Colors, 5, 8 )
            While Not @error
                $time = TimerInit()
                $coor2 = PixelSearch( $start[0], $start[1], $current[0], $current[1], $Colors, 5, 8 )
                $velocityx = ($coor1[0] - $coor2[0])/TimerDiff($time)
                $velocityy = ($coor1[1] - $coor2[1])/TimerDiff($time)
                MouseClick ( "left", (($velocityx*timerdiff($time))+400), (($velocityy*TimerDiff($time))+470), 1, 3 )
                Sleep(500)

Link to comment
Share on other sites

$coor1 = PixelSearch( $start[0], $start[1], $current[0], $current[1], $Colors, 5, 8 )
            While Not @error
                $time = TimerInit()
                $coor2 = PixelSearch( $start[0], $start[1], $current[0], $current[1], $Colors, 5, 8 )
                if IsArray($coor1) And IsArray($coor2) Then
                    $velocityx = ($coor1[0] - $coor2[0])/TimerDiff($time)
                    $velocityy = ($coor1[1] - $coor2[1])/TimerDiff($time)
                    MouseClick ( "left", (($velocityx*timerdiff($time))+400), (($velocityy*TimerDiff($time))+470), 1, 3 )
                EndIf
                Sleep(500)

Try this

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Link to comment
Share on other sites

so it works now but the velocity thing doesn't. probably because the objects are restricted to a box or something :\

edit:

ok, my velocity formula was backwards should be coord2-coord1 but it still doesn't work.

Edited by XZ3R0
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...