Removing 'Not A Number' Input from Lists
I am motion tracking a framesub with cv.jit.centroid and when I get list outputs when no motion takes place I am getting NANs. I'd like to find a way to remove these from my list so I am only receiving numbers which can then be used as X and Y coordinates or data for other things. Ideas?
Thanks
If getting the NaN is a problem with your current patch and you can figure out the problem, fix the patch. Without a patch to look at, we're just playing 20 questions, though.
I uploaded the Patch, The problem area is where I am unpacking from cv.jit.centroid and receiving NANs. Ideally I'd just like to filter out the numbers and remove the NANs, because I don't think it is possible to not receive them from cv.jit.centroid.
I am also a newb to Max so I couldn't figure it out, that's why I am posting.
fixing it would be best, but it should also be easy to filter it out:
iterate the list, route int float, group the list...
Take a look at the [bitsafe~] object. It outputs a 0 every time it receives a NaN input. It only works with signals, though, so if you are working with floats, you'll need to first convert them to signals.
Here's the method I use to remove things like nan and +/-inf when I need to, it might be useful to you.
lh
I would really discourage you from using tosymbol/fromsymbol, which generates tons of symbols. Instead, you can use an interesting property of NaNs, they are never equal to NaNs. You can apply that to vexpr as well.
Hi from 11 years later! That's awesome, EJ, but... inf == inf?
And from 13 years, thank you EJ!