Pixy2 and the Arduino Uno Rev 3- Counting X Y Movement

I have found a lot of information on servo control based off of X Y data and centering that object, which has been somewhat helpful, however I am trying to count a bunch of objects, like marbles rolling past the camera. I would like to only count them as they go from one section of the screen to the other based off well defined X Y coordinates.

I plan to only count a maximum of 2 signatures and the Pixy2 can track up to 100 "blocks per the interface, however documentation says 0-255. Each "block" is tracked until it leaves the screen and then the program recycles those block numbers.

I need to count each "block" going from one side, lets say x= 0-40 to x= 275-315. And count them for 24 hours and reset after each day. So my question is, would it be best to put "if [control structure]" to do this task or is there a better way?

This is the demo return data to the arduino from the Pixy2 with only one object signature:
Detected 1
block 0: sig: 1 x: 269 y: 157 width: 62 height: 34 index: 74 age: 0
Detected 1
block 0: sig: 1 x: 235 y: 155 width: 54 height: 33 index: 74 age: 1
Detected 1
block 0: sig: 1 x: 199 y: 152 width: 42 height: 33 index: 74 age: 2
Detected 1
block 0: sig: 1 x: 167 y: 148 width: 34 height: 32 index: 74 age: 3
Detected 1
block 0: sig: 1 x: 131 y: 145 width: 30 height: 25 index: 74 age: 4
Detected 1
block 0: sig: 1 x: 103 y: 127 width: 10 height: 4 index: 74 age: 5
Detected 1
block 0: sig: 1 x: 53 y: 131 width: 46 height: 30 index: 74 age: 6
Detected 1
block 0: sig: 1 x: 19 y: 131 width: 38 height: 26 index: 74 age: 7
Detected 1
block 0: sig: 1 x: 19 y: 131 width: 38 height: 26 index: 74 age: 8

It tracks the age of the object which I think may help not count a new block with the same ID (in this case 0) once the same ID exits the view of the Pixy2.

I don't want to spend a ton of time trying to get if functions to work if there is another route. I have spent hours going over servo code to see if that would help and I feel a little lost. Any direction from experts like yourselves would help. Thank you!

If I had to guess, I'd say that that output represented one object moving along the track. What I would want to see is similar data for two objects moving along the track at the same time (separated a bit). Then, I'd want to see data for two objects, only one of which is on the track at any given time.

You need to determine what causes the object number to increment. Rolling two marbles along the track, one at a time, might cause the object number to be 0 for the first one and 1 for the second one. Or, it might be that, since there is only one object at a time, both are object 0.

If each object has a unique number, that is the only piece of information that matters.

If the object number just identifies which of n objects are being tracked at some point in time, then the age of the nth object will be important.

One data point is not sufficient.

Here is 3 objects going from top of video to bottom.

16:58:36.139 -> Detected 3
16:58:36.139 -> block 0: sig: 1 x: 188 y: 96 width: 16 height: 9 index: 128 age: 20
16:58:36.139 -> block 1: sig: 1 x: 191 y: 103 width: 18 height: 3 index: 127 age: 26
16:58:36.139 -> block 2: sig: 1 x: 184 y: 88 width: 16 height: 3 index: 137 age: 1
16:58:36.139 -> Detected 3
16:58:36.139 -> block 0: sig: 1 x: 186 y: 97 width: 24 height: 7 index: 128 age: 21
16:58:36.139 -> block 1: sig: 1 x: 188 y: 107 width: 16 height: 5 index: 127 age: 27
16:58:36.287 -> block 2: sig: 1 x: 189 y: 88 width: 22 height: 2 index: 137 age: 2
16:58:36.287 -> Detected 3
16:58:36.287 -> block 0: sig: 1 x: 188 y: 114 width: 24 height: 5 index: 137 age: 3
16:58:36.287 -> block 1: sig: 1 x: 185 y: 95 width: 14 height: 8 index: 128 age: 22
16:58:36.287 -> block 2: sig: 1 x: 184 y: 106 width: 12 height: 3 index: 127 age: 28
16:58:36.287 -> Detected 3
16:58:36.287 -> block 0: sig: 1 x: 183 y: 110 width: 14 height: 3 index: 127 age: 29
16:58:36.287 -> block 1: sig: 1 x: 192 y: 106 width: 20 height: 2 index: 137 age: 4
16:58:36.287 -> block 2: sig: 1 x: 184 y: 118 width: 8 height: 3 index: 128 age: 23
16:58:36.287 -> Detected 3
16:58:36.287 -> block 0: sig: 1 x: 188 y: 117 width: 16 height: 9 index: 128 age: 24
16:58:36.287 -> block 1: sig: 1 x: 185 y: 103 width: 18 height: 4 index: 137 age: 5
16:58:36.318 -> block 2: sig: 1 x: 183 y: 110 width: 14 height: 3 index: 127 age: 30
16:58:36.363 -> Detected 3
16:58:36.363 -> block 0: sig: 1 x: 185 y: 103 width: 18 height: 4 index: 137 age: 6
16:58:36.363 -> block 1: sig: 1 x: 189 y: 121 width: 14 height: 3 index: 128 age: 25
16:58:36.363 -> block 2: sig: 1 x: 189 y: 126 width: 14 height: 2 index: 127 age: 31