feat: Add Puara TouchArrayGestureDetector processor#11
feat: Add Puara TouchArrayGestureDetector processor#11yrevash wants to merge 2 commits intoossia:masterfrom
Conversation
|
Hi @jcelerier and @edumeneses Current Implementation:
Please let me know your thoughts on this initial version and any further changes or expansions you'd like to see |
|
Code looks good! @edumeneses what do you think? I'd be curious to see an example of how one would use it in practice, do we have a device we can try it with? Otherwise sensors2osc also supports multitouch |
|
This is a descriptor particular to touch arrays, e.g., the T-Stick or devices using the Trill touch sensors. I'm not sure it's really generalizable, but it could be interesting to explore possibilities with normalized arrays |
|
I see, so yeah Sensors2OSC should allow to try it :) |
|
Hey @jcelerier, let me know of any changes, or if we should move with a merge. |
| { | ||
| // 1. Getting input touch array and its size | ||
| // Useing .value here as std::vector doesn't have an implicit conversion from halp::val_port | ||
| std::vector<int>& current_touch_array_data = inputs.touch_array_input.value; |
There was a problem hiding this comment.
I'd mark this as const auto& instead
There was a problem hiding this comment.
Hey @jcelerier ,
"Regarding the const auto& suggestion for current_touch_array_data (renamed to touch_data):
When I applied const auto&, touch_data.data() returns a const int*. However, the TouchArrayGestureDetector::update function is defined as
void update(int* touchArray, int touchSize)
The compiler threw an error: Cannot initialise a parameter of type 'int *' with an rvalue of type 'const value_type *' (aka 'const int *').
This is C++'s const-correctness preventing me from passing const data to a function that could potentially modify it (because it expects a non-const int*).
Therefore, the most const-correct solution would be to update the TouchArrayGestureDetector::update signature in puara/descriptors/touchArrayGestureDetector.h to:
void update(const int* touchArray, int touchSize);
Should I proceed with this change and commit? Or should I keep the default implementation as it is.
There was a problem hiding this comment.
Hey @jcelerier,
As I mentioned, I think modifying ToughArrayGestures.h is a valid option as TouchArrayGestureDetector::update function does not modify the touchArray data it receives. It only reads from it (via arrayAverage and blobDetector.detect1D).
Thus, it would be a good choice to change the call from
--> void update(int* touchArray, int touchSize)
to this
--> void update(const int* touchArray, int touchSize);
| // 1. Getting input touch array and its size | ||
| // Useing .value here as std::vector doesn't have an implicit conversion from halp::val_port | ||
| std::vector<int>& current_touch_array_data = inputs.touch_array_input.value; | ||
| const int touch_size = static_cast<int>(current_touch_array_data.size()); |
There was a problem hiding this comment.
not really necessary - you could rename the array "touch" and then do "touch.size()" throughout, it's not going to have any performance impact due to inlining
|
Hey @jcelerier, Requested Review, much more importantly, the part When I applied const auto&, touch_data.data() returns a const int*. However, the TouchArrayGestureDetector::update function is defined as void update(int touchArray, int touchSize)* **The compiler threw an error: Cannot initialise a parameter of type 'int ' with an rvalue of type 'const value_type ' (aka 'const int '). Therefore, the most correct solution would be to update the TouchArrayGestureDetector::update signature in puara/descriptors/touchArrayGestureDetector.h to: _void update(const int touchArray, int touchSize);_* |
397d5c4 to
fa25dea
Compare
Implements an Avendish wrapper for puara_gestures::TouchArrayGestureDetector.
Note: A safety check for empty input arrays is included in the wrapper. Discussion point: whether the underlying library is robust enough to handle this, potentially simplifying the wrapper.