Commit 3e5dc5a7 authored by Rob Schonberger's avatar Rob Schonberger Committed by Commit Bot

Set Delay by heuristic, flagged by configuration. Add thorough test.

This CL introduces behavior to delay touches that would be flagged as
palm by heuristic, until inference occurs. This is all flagged by a
configuration flag.

We add a thorough unittest to test behavior: that delay is set, and
kept, until Inference. Test that delay is not set when flag is off.

Bug: 1009290
Change-Id: I060db0a2dda207537a5cc1f61690d0fafcc2f4d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888618Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Rob Schonberger <robsc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711052}
parent 639d6d62
......@@ -167,12 +167,12 @@ void NeuralStylusPalmDetectionFilter::Filter(
slots_to_decide.insert(slot);
}
if (!end_of_stroke && stroke.samples_seen() < config.max_sample_count &&
if (config.heuristic_delay_start_if_palm && !end_of_stroke &&
stroke.samples_seen() < config.max_sample_count &&
IsHeuristicPalmStroke(stroke)) {
// A stroke that we _think_ may be a palm, but is too short to decide
// yet. So we mark for delay for now.
// TODO(robsc): enable this behavior.
// is_delay_.set(slot, true);
is_delay_.set(slot, true);
}
}
......
......@@ -48,6 +48,11 @@ struct EVENTS_OZONE_EVDEV_EXPORT NeuralStylusPalmDetectionFilterModelConfig {
// greater than or equal to this should be marked as a palm. If <= 0, has no
// effect
float heuristic_palm_area_limit = 0.0f;
// If true, runs the heuristic palm check on short strokes, and enables delay
// on them if the heuristic would have marked the touch as a palm at that
// point.
bool heuristic_delay_start_if_palm = false;
};
// An abstract model utilized by NueralStylusPalmDetectionFilter.
......
......@@ -304,4 +304,70 @@ TEST_F(NeuralStylusPalmDetectionFilterTest, InferenceOncePalm) {
}
}
TEST_F(NeuralStylusPalmDetectionFilterTest, DelayShortFingerTouch) {
std::bitset<kNumTouchEvdevSlots> actual_held, actual_cancelled;
std::bitset<kNumTouchEvdevSlots> expected_held, expected_cancelled;
model_config_.heuristic_delay_start_if_palm = true;
touch_[0].touching = true;
touch_[0].tracking_id = 605;
touch_[0].x = 50;
touch_[0].y = 55;
// small touch! 39*21 = 819, which is < 1000.
touch_[0].major = 39;
touch_[0].minor = 21;
base::TimeTicks touch_time =
base::TimeTicks::UnixEpoch() + base::TimeDelta::FromMillisecondsD(10.0);
palm_detection_filter_->Filter(touch_, touch_time, &actual_held,
&actual_cancelled);
EXPECT_EQ(expected_held, actual_held);
EXPECT_EQ(expected_cancelled, actual_cancelled);
}
TEST_F(NeuralStylusPalmDetectionFilterTest, DelayShortPalmTouch) {
std::bitset<kNumTouchEvdevSlots> actual_held, actual_cancelled;
std::bitset<kNumTouchEvdevSlots> expected_held, expected_cancelled;
model_config_.heuristic_delay_start_if_palm = true;
touch_[0].touching = true;
touch_[0].tracking_id = 605;
touch_[0].x = 50;
touch_[0].y = 55;
// big touch! 39*30 = 1170, which is > 1000.
touch_[0].major = 39;
touch_[0].minor = 30;
base::TimeTicks touch_time =
base::TimeTicks::UnixEpoch() + base::TimeDelta::FromMillisecondsD(10.0);
palm_detection_filter_->Filter(touch_, touch_time, &actual_held,
&actual_cancelled);
expected_held.set(0, true);
EXPECT_EQ(expected_held, actual_held);
EXPECT_EQ(expected_cancelled, actual_cancelled);
// Delay continues even afterwards, until inference time: then it's off.
for (uint32_t i = 1; i < model_config_.max_sample_count - 1; ++i) {
touch_[0].was_touching = true;
touch_time += base::TimeDelta::FromMillisecondsD(10.0);
touch_[0].major = 15;
touch_[0].minor = 15;
touch_[0].x += 1;
touch_[0].y += 1;
palm_detection_filter_->Filter(touch_, touch_time, &actual_held,
&actual_cancelled);
EXPECT_EQ(expected_held, actual_held) << " failed at " << i;
EXPECT_EQ(expected_cancelled, actual_cancelled) << " failed at " << i;
}
// When running inference, turn delay to false.
EXPECT_CALL(*model_, Inference(testing::_))
.Times(1)
.WillOnce(testing::Return(-0.1));
touch_time =
base::TimeTicks::UnixEpoch() + base::TimeDelta::FromMillisecondsD(10.0);
palm_detection_filter_->Filter(touch_, touch_time, &actual_held,
&actual_cancelled);
expected_held.set(0, false);
EXPECT_EQ(expected_held, actual_held);
EXPECT_EQ(expected_cancelled, actual_cancelled);
}
} // namespace ui
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment