Hi. I'm working with pd+reacTIVision and have a doubt maybe someone could help to solve.
When I turn one fiducial I can get the angle value, from 0 to 360. After 360, if you continue turning, again it goes directly to 0 (from 0 to 360).
I want make encoders using that angle value. I have make a patch that store 2 angle values and compare them, if one of the values is bigger than previous I get "1" but if the value is smaller I get "-1".
The problem, is that when you go from 360 to 0 or 1 (sometimes skips values if you turn fast) I get a "-1" when I was looking for a "1" and vice versa.
Any idea about how solve this problem?
Hope you could understand what I mean, I'm not native english and wasn't the best student out there...
-
fiducials working like relative encoders
-
I add the patch here for better understanding.
fiducial_encoder.pd -
Hi,
I tried opening your patch to check out what is going on, but I don't have the object [RCT_Marker 0] on my system. From which library is it from? I have both reacTIVision and the TUIO Pd library installed on my computer. If I manage to load that object, I'd be glad to take a look on your problem.
Take care,
Gilberto -
Yes, sorry, it's a simple but useful patch that was posted in the forum sometime ago. Here is:
http://forum.pdpatchrepo.info/topic/738/reactivision-simple-fiducial-marker-patch -
Hi, sorry for the late reply, I have been away from Pd during the last days. So I had a look on your patch and I think I understand what you want. What do you think about this simple solution: what if you simply ignore any changes that are larger than, let's say, 350? This way, when the marker's angle changes from around 359 into around 1, this click will be ignored, but the next (let's say from 1 to 2) would count normally. You could implement this by some very simple logic, you can use some {expr] objects such as the ones below:
[expr if (($f1 > $f2) && (abs($f1 - $f2) < 350), 1, 0)]
[expr if (($f1 < $f2) && (abs($f1 - $f2) < 350), 1, 0)]Here is the patch that I altered, and it seems to be functioning well now: fiducial_encoder.pd
Take care,
Gilberto -
Thanks Gilberto, it's a simple but good solution.
I have tested it with the TUIO-Simulator and works right.
I will try it later with the real camera, a ps3 eyetoy working at 60 fps.
The problem with reacTIVision (at least in my case) is that if you turn fiducials very fast, even using the TUIO-Simulator, it jumps values of those 360.
So if I understand correctly your solution, I guess 350 is a good value. -
Hi,
I also have problems when turning the markers too fast, but I guess that's a limitation of the technology we are using. As for my solution above, let me break that [expr] object for you so you can see what it's doing (and maybe adapt it better for your needs):
[expr if (($f1 > $f2) && (abs($f1 - $f2) < 350), 1, 0)] means:
if $f1 > $f2 and if the absolute value of $f1 - $f2 < 350, then the output will be 1, else it will output 0.
Good luck!
Gilberto