Hi Edward,
Thank you for your answer !
*1.*Actually, when the “stop” command is before the loop, without getting blocks and moving, and without the “run” command as you advised, it returns frames in an infinite loop :
+ Pixy Tracking Demo Started +
STOP returned 0 response 0
getFrame returned 0 response 0
returned w 40 h 40 npix 1600
0a 09 0a 09 0b 0a 0b 09
09 07 09 09 09 08 09 09
09 09 09 09 09 08 09 09
08 08 08 07 08 06 08 08
08 08 08 07 08 08 08 08
08 07 07 07 08 07 08 07
08 07 08 07 07 07 07 08
08 07 07 07 08 07 07 07
getFrame returned 0 response 0
returned w 40 h 40 npix 1600
09 08 0a 09 0a 0a 0b 0b
09 08 09 09 0a 09 09 0a
08 09 09 0a 09 09 09 09
08 08 09 07 08 07 08 08
08 08 08 08 09 08 09 08
07 07 08 07 08 06 08 08
08 08 08 07 09 08 08 07
09 07 07 06 08 07 08 07
...
*2.*Then, when I try to add the tracking code with the get_frame() function inside the while loop, it doesn’t work anymore :
_(pseudo code)_:
command "stop"
while :
get_frame()
tracking codes // get_blocks, move motors, ...
It freezes at the frame 0 :
+ Pixy Tracking Demo Started +
STOP returned 0 response 0
frame 0:
getFrame returned 0 response 0
returned w 40 h 40 npix 1600
1a 17 26 34 3a 23 1a 10
12 1b 2c 30 2f 13 13 0c
1b 1d 2b 2e 37 18 16 0f
16 24 2f 24 24 0f 10 0d
1d 25 34 2b 24 12 12 0e
1b 2b 2e 1b 18 0e 0f 0e
20 2b 32 25 1c 10 12 0e
24 2d 2f 13 12 0c 0e 0e
sig: 1 x: 233 y: 194 width: 27 height: 10
sig: 1 x: 178 y: 192 width: 11 height: 3
sig: 1 x: 118 y: 49 width: 5 height: 7
^C
*3.*Using the command “run” makes Pixy return frames (before loop) and track after (in loop):
_(pseudo codes)_:
command "stop"
get_frame() // as many times as I want
command "run" // without "run" the tracking codes do not execute, it freezes
while :
tracking codes
This code prooves that grab_frame() and tracking() could work together then, doesn’it ?
*4.*I even tried to call “stop” with “run” many times … Sorry you advised not to but I was curious, and it seems to work:
_(pseudo codes)_:
command "stop"
get_frame()
command "run"
command "stop"
get_frame()
command "run"
while :
tracking codes
*5.*But my objective is still to grab frame at any times (e.g. each 50 frames) while tracking. And when the codes look like :
_(pseudo codes)_:
command "stop"
get_frame()
command "run"
while :
command "stop"
get_frame()
command "run"
tracking codes
the first grab_frame() works but not the inside while one, it returns the same errors ([-152] invalid command and [-7] undefined error :
getFrame returned -7 response 0
returned w 40 h 40 npix 1600
Undefined error: [-7]
Plus, I don’t understand why the get_frame() works fine and sometimes it stops working when I execute the program a 2nd time… The code has to be reexecuted many times until it works again by disconnecting/reconnecting Pixy USB.
(Sorry for the long story )
Marino