|
Post by mksg on Jul 5, 2021 17:34:06 GMT
Hi, I'm new to this so I'm sorry if this is not clear or a dumb question.
I know how to monitor a range of pixels for a specific colour change, but not sure about how to record the times at which the change occurs. I am monitoring a certain pixel range, let's say it is generally black and sometimes turns white. I would like to report/record back to me the times that it turns white. For example: 1. The pixels are black. Then it turns white for first time. This should trigger the first instance at 't1' = time of day at which black turns white. Or this could trigger a counter that starts at time=0. 2. Then wait say 50 milliseconds because I know it turns black again. This is just a waiting parameter meant to allow pixels to change back to black. No recording of times needed. 3. The pixels are black. Then it turns white for second time. This should trigger the second instance at 't2' = time of day at which black turns white again. Or this could stop the counter that was started at 0. 4. So ultimately I get two times (t1 and t2) when the pixel turned white, so I can in excel take t2-t1 to get the time interval between the white occurences.
I would need the level of accuracy for t1 and t2 be recorded in milliseconds.
Thanks! MS
|
|
|
Post by Steve on Jul 6, 2021 10:13:25 GMT
Hi mksg, We can do this a few ways in MMM and with this example I'm putting the pixel condition ( www.turnssoft.com/conditions.html#pixelcolor) between a loop based on the %time_macro% internal counter. This variable holds the current running time of the macro in seconds. 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %intC%::1 * | PIXEL CHECK 2 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1004 Y:394] | IS THE SAME | GOTO MACRO LINE | 3 | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | LOOP 3 | RUN ACTION | OUTPUT TO FILE | C:\Users\steph\Dropbox\Macro\File\pixel changes.txt::APPEND_NEWLINE::T%intC%=%TIME_H%:%TIME_M%:%TIME_S%:%TIME_MS% 4 | RUN ACTION | WAIT MILLISECONDS | 50 5 | RUN ACTION | DEFINE INTEGER VARIABLE | %intC%::+1 * | LOOP 6 | IF | INTEGER VARIABLE | %TIME_MACRO% | LESS THAN | 10 | GOTO MACRO LINE | 2 At line 1 we declare your instance counter At line 2 we start the pixel evaluation. If a pixel is white (255,255,255) then goto line 3 else then goto line label 'LOOP'. At line 3 we output our instance count followed by the time. At line 4 we wait 50 ms At line 5 we increment our counter At line 6 we evaluate the %time_macro% variable. If we have been running for less than 10 seconds then loop back to line 2.
In the demo below we run the macro. Every couple of seconds I move a white background over the pixel target area and trigger line 2 to evaluate to TRUE. This then runs line 3, 4, and 5 which writes to our log file and continues the loop.
|
|
|
Post by mksg on Jul 6, 2021 15:15:12 GMT
That is really helpful and solves my question. Thanks!
|
|
|
Post by mksg on Jul 8, 2021 23:14:01 GMT
Hi,
It turns out I have run into another complication. The pixels I monitor are generally dark (but not perfectly black and not a constant RGB value). They are video content so the pixels stay darkish but are constantly changing ever so slightly. Then the pixels turn white (or close to white, again not a constant RGB value) and when change from darkish to lightish that is when I want to record the time of occurence.
So, in Steve's sample code line below for a pixel color of white, is there some way to introduce some tolerance to the pixel color? ie, the following line is a bit too stringent: 2 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1004 Y:394] | IS THE SAME | GOTO MACRO LINE | 3 | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | LOOP Are there some more tolerable options like: 2 | IF | PIXEL COLOR | Color [R>200, G>200, B>200]::At Location [X:1004 Y:394] | IS THE SAME | GOTO MACRO LINE | 3 | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | LOOP
PIXEL RANGE condition was also not solving my problem because the slight changes in dark pixels triggers the command, while I am wanting it to wait for the bigger change to lightish pixels.
Thanks a bunch! MS
|
|
|
Post by Steve on Jul 9, 2021 6:26:33 GMT
Hi, It turns out I have run into another complication. The pixels I monitor are generally dark (but not perfectly black and not a constant RGB value). They are video content so the pixels stay darkish but are constantly changing ever so slightly. Then the pixels turn white (or close to white, again not a constant RGB value) and when change from darkish to lightish that is when I want to record the time of occurence. So, in Steve's sample code line below for a pixel color of white, is there some way to introduce some tolerance to the pixel color? ie, the following line is a bit too stringent: 2 | IF | PIXEL COLOR | Color [ R=255, G=255, B=255]::At Location [X:1004 Y:394] | IS THE SAME | GOTO MACRO LINE | 3 | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | LOOP Are there some more tolerable options like: 2 | IF | PIXEL COLOR | Color [ R>200, G>200, B>200]::At Location [X:1004 Y:394] | IS THE SAME | GOTO MACRO LINE | 3 | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | LOOP PIXEL RANGE condition was also not solving my problem because the slight changes in dark pixels triggers the command, while I am wanting it to wait for the bigger change to lightish pixels. Thanks a bunch! MS No unfortunately not but I really like the concept.
2 | IF | PIXEL COLOR | Color [R>200, G>200, B>200]::At Location [X:1004 Y:394] | IS THE SAME | GOTO MACRO LINE | 3 | ELSE | 2 | RUN ACTION | GOTO MACRO LINE | LOOP
I'll have a look at the code and see if I can add this in for the next update. Such a small change could have a big impact. I'll look into adding < and > modifiers to the command.
Great idea
|
|
|
Post by Steve on Jul 9, 2021 23:06:06 GMT
Thanks again for the idea.
|
|
|
Post by mksg on Jul 11, 2021 4:49:43 GMT
That is great news!
|
|