andyjw1

Checking for colour

6 posts in this topic

#1 ·  Posted

I am trying to run a simple little script that will check for a particular colour pixel in a small box and then return its coordinates.

This is it:

    Local $aCoord = PixelSearch(830,440,1030,640,0x69ADF2)
    if not @error Then
msgbox(0,"Func", "X Y" & $aCoord[0] & "," & $aCoord[1] )

    Sleep (500)
    EndIf
    

It will be called as a function and the "msgbox" bit will be replaced but this is just for testing.

 

It will run but doesnt give me the msgbox so is it detecting the colour? I thought the "not @error" should make it wait until it see the condition?

 

thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted

@andyjw1 what exactly are you trying to automate (web page, desktop app, etc.). As you are beginning to see, PixelSearch is about the worst way you can go about checking for the presence of, or change in, a window. I can guarantee there is an easier way, if you can give us a bit more info.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

Im am just starting to learn so all I am trying to do is detect a particular moving colour within a 200 pixel box.

I eventually want to follow a point in a video image which will then output to a DMX program which will in turn control a moving light to follow the same spot. Hope that made sense :)

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Nope, still a little too vague for me. Good luck in your endeavors, perhaps someone will wander by and offer assistance. :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted

Sorry, Ill try and be a bit clearer.

I have a light on a stage that I can move using an app on the PC so that I can follow a person around the stage, like a spotlight on a comedian.

What I want to do is point a video camera at the stage and use the code to detect where the person is within the video image, it will then control the light.

 

Any better?

Thanks

Share this post


Link to post
Share on other sites

#6 ·  Posted

While 1
    Local $aCoord = PixelSearch(830,440,1030,640,0x69ADF2)
    If $aCoord Then
      MsgBox(0,"Func", "X Y" & $aCoord[0] & "," & $aCoord[1] )
      Sleep (500)
      ExitLoop
    EndIF
WEnd

This will loop and keep going until the pixel is found. If it still isn't being found, make sure your bounds are correct, and also make sure the shade is EXACTLY correct since you have the shade-variation set to 0.


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
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