Fix touch coordinate calibration

TRT: I3b5f3ed07eabc59306a17

Bug: 8505668
Change-Id: I574d25a4e9886c521f013f9a8ffc09cc145fc0fc
main
Satoshi Kataoka 2013-04-09 14:15:47 +09:00
parent 1f70a4d681
commit a1d84bcf8f
10 changed files with 51 additions and 32 deletions

View File

@ -129,7 +129,7 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
}
float ProximityInfo::getNormalizedSquaredDistanceFromCenterFloatG(
const int keyId, const int x, const int y) const {
const int keyId, const int x, const int y, const float verticalScale) const {
const bool correctTouchPosition = hasTouchPositionCorrectionData();
const float centerX = static_cast<float>(correctTouchPosition ? getSweetSpotCenterXAt(keyId)
: getKeyCenterXOfKeyIdG(keyId));
@ -138,7 +138,7 @@ float ProximityInfo::getNormalizedSquaredDistanceFromCenterFloatG(
if (correctTouchPosition) {
const float sweetSpotCenterY = static_cast<float>(getSweetSpotCenterYAt(keyId));
const float gapY = sweetSpotCenterY - visualKeyCenterY;
centerY = visualKeyCenterY + gapY * ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE_G;
centerY = visualKeyCenterY + gapY * verticalScale;
} else {
centerY = visualKeyCenterY;
}

View File

@ -39,7 +39,8 @@ class ProximityInfo {
bool hasSpaceProximity(const int x, const int y) const;
int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const;
float getNormalizedSquaredDistanceFromCenterFloatG(
const int keyId, const int x, const int y) const;
const int keyId, const int x, const int y,
const float verticalScale) const;
bool sameAsTyped(const unsigned short *word, int length) const;
int getCodePointOf(const int keyIndex) const;
bool hasSweetSpotData(const int keyIndex) const {

View File

@ -20,7 +20,8 @@
namespace latinime {
const float ProximityInfoParams::NOT_A_DISTANCE_FLOAT = -1.0f;
const int ProximityInfoParams::MIN_DOUBLE_LETTER_BEELINE_SPEED_PERCENTILE = 5;
const float ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE_G = 1.1f;
const float ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE = 1.0f;
const float ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE_G = 0.5f;
/* Per method constants */
// Used by ProximityInfoStateUtils::initGeometricDistanceInfos()

View File

@ -25,6 +25,7 @@ class ProximityInfoParams {
public:
static const float NOT_A_DISTANCE_FLOAT;
static const int MIN_DOUBLE_LETTER_BEELINE_SPEED_PERCENTILE;
static const float VERTICAL_SWEET_SPOT_SCALE;
static const float VERTICAL_SWEET_SPOT_SCALE_G;
// Used by ProximityInfoStateUtils::initGeometricDistanceInfos()

View File

@ -28,6 +28,7 @@
namespace latinime {
// TODO: Remove the dependency of "isGeometric"
void ProximityInfoState::initInputParams(const int pointerId, const float maxPointToKeyLength,
const ProximityInfo *proximityInfo, const int *const inputCodes, const int inputSize,
const int *const xCoordinates, const int *const yCoordinates, const int *const times,
@ -94,12 +95,17 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
pushTouchPointStartIndex, lastSavedInputSize);
}
// TODO: Remove the dependency of "isGeometric"
const float verticalSweetSpotScale = isGeometric
? ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE_G
: ProximityInfoParams::VERTICAL_SWEET_SPOT_SCALE;
if (xCoordinates && yCoordinates) {
mSampledInputSize = ProximityInfoStateUtils::updateTouchPoints(mProximityInfo,
mMaxPointToKeyLength, mInputProximities, xCoordinates, yCoordinates, times,
pointerIds, inputSize, isGeometric, pointerId, pushTouchPointStartIndex,
&mSampledInputXs, &mSampledInputYs, &mSampledTimes, &mSampledLengthCache,
&mSampledInputIndice);
pointerIds, verticalSweetSpotScale, inputSize, isGeometric, pointerId,
pushTouchPointStartIndex, &mSampledInputXs, &mSampledInputYs, &mSampledTimes,
&mSampledLengthCache, &mSampledInputIndice);
}
if (mSampledInputSize > 0 && isGeometric) {
@ -115,8 +121,8 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
if (mSampledInputSize > 0) {
ProximityInfoStateUtils::initGeometricDistanceInfos(mProximityInfo, mSampledInputSize,
lastSavedInputSize, &mSampledInputXs, &mSampledInputYs, &mSampledNearKeySets,
&mSampledDistanceCache_G);
lastSavedInputSize, verticalSweetSpotScale, &mSampledInputXs, &mSampledInputYs,
&mSampledNearKeySets, &mSampledDistanceCache_G);
if (isGeometric) {
// updates probabilities of skipping or mapping each key for all points.
ProximityInfoStateUtils::updateAlignPointProbabilities(

View File

@ -42,8 +42,8 @@ namespace latinime {
const ProximityInfo *const proximityInfo, const int maxPointToKeyLength,
const int *const inputProximities, const int *const inputXCoordinates,
const int *const inputYCoordinates, const int *const times, const int *const pointerIds,
const int inputSize, const bool isGeometric, const int pointerId,
const int pushTouchPointStartIndex, std::vector<int> *sampledInputXs,
const float verticalSweetSpotScale, const int inputSize, const bool isGeometric,
const int pointerId, const int pushTouchPointStartIndex, std::vector<int> *sampledInputXs,
std::vector<int> *sampledInputYs, std::vector<int> *sampledInputTimes,
std::vector<int> *sampledLengthCache, std::vector<int> *sampledInputIndice) {
if (DEBUG_SAMPLING_POINTS) {
@ -112,10 +112,10 @@ namespace latinime {
}
if (pushTouchPoint(proximityInfo, maxPointToKeyLength, i, c, x, y, time,
isGeometric /* doSampling */, i == lastInputIndex, sumAngle,
currentNearKeysDistances, prevNearKeysDistances, prevPrevNearKeysDistances,
sampledInputXs, sampledInputYs, sampledInputTimes, sampledLengthCache,
sampledInputIndice)) {
verticalSweetSpotScale, isGeometric /* doSampling */, i == lastInputIndex,
sumAngle, currentNearKeysDistances, prevNearKeysDistances,
prevPrevNearKeysDistances, sampledInputXs, sampledInputYs, sampledInputTimes,
sampledLengthCache, sampledInputIndice)) {
// Previous point information was popped.
NearKeysDistanceMap *tmp = prevNearKeysDistances;
prevNearKeysDistances = currentNearKeysDistances;
@ -222,7 +222,8 @@ namespace latinime {
/* static */ void ProximityInfoStateUtils::initGeometricDistanceInfos(
const ProximityInfo *const proximityInfo, const int sampledInputSize,
const int lastSavedInputSize, const std::vector<int> *const sampledInputXs,
const int lastSavedInputSize, const float verticalSweetSpotScale,
const std::vector<int> *const sampledInputXs,
const std::vector<int> *const sampledInputYs,
std::vector<NearKeycodesSet> *SampledNearKeySets,
std::vector<float> *SampledDistanceCache_G) {
@ -236,7 +237,8 @@ namespace latinime {
const int x = (*sampledInputXs)[i];
const int y = (*sampledInputYs)[i];
const float normalizedSquaredDistance =
proximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y);
proximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(
k, x, y, verticalSweetSpotScale);
(*SampledDistanceCache_G)[index] = normalizedSquaredDistance;
if (normalizedSquaredDistance
< ProximityInfoParams::NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD) {
@ -354,12 +356,14 @@ namespace latinime {
// the given point and the nearest key position.
/* static */ float ProximityInfoStateUtils::updateNearKeysDistances(
const ProximityInfo *const proximityInfo, const float maxPointToKeyLength, const int x,
const int y, NearKeysDistanceMap *const currentNearKeysDistances) {
const int y, const float verticalSweetspotScale,
NearKeysDistanceMap *const currentNearKeysDistances) {
currentNearKeysDistances->clear();
const int keyCount = proximityInfo->getKeyCount();
float nearestKeyDistance = maxPointToKeyLength;
for (int k = 0; k < keyCount; ++k) {
const float dist = proximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y);
const float dist = proximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y,
verticalSweetspotScale);
if (dist < ProximityInfoParams::NEAR_KEY_THRESHOLD_FOR_DISTANCE) {
currentNearKeysDistances->insert(std::pair<int, float>(k, dist));
}
@ -439,7 +443,8 @@ namespace latinime {
// Returning if previous point is popped or not.
/* static */ bool ProximityInfoStateUtils::pushTouchPoint(const ProximityInfo *const proximityInfo,
const int maxPointToKeyLength, const int inputIndex, const int nodeCodePoint, int x, int y,
const int time, const bool doSampling, const bool isLastPoint, const float sumAngle,
const int time, const float verticalSweetSpotScale, const bool doSampling,
const bool isLastPoint, const float sumAngle,
NearKeysDistanceMap *const currentNearKeysDistances,
const NearKeysDistanceMap *const prevNearKeysDistances,
const NearKeysDistanceMap *const prevPrevNearKeysDistances,
@ -451,8 +456,8 @@ namespace latinime {
size_t size = sampledInputXs->size();
bool popped = false;
if (nodeCodePoint < 0 && doSampling) {
const float nearest = updateNearKeysDistances(
proximityInfo, maxPointToKeyLength, x, y, currentNearKeysDistances);
const float nearest = updateNearKeysDistances(proximityInfo, maxPointToKeyLength, x, y,
verticalSweetSpotScale, currentNearKeysDistances);
const float score = getPointScore(mostCommonKeyWidth, x, y, time, isLastPoint, nearest,
sumAngle, currentNearKeysDistances, prevNearKeysDistances,
prevPrevNearKeysDistances, sampledInputXs, sampledInputYs);

View File

@ -38,7 +38,8 @@ class ProximityInfoStateUtils {
static int updateTouchPoints(const ProximityInfo *const proximityInfo,
const int maxPointToKeyLength, const int *const inputProximities,
const int *const inputXCoordinates, const int *const inputYCoordinates,
const int *const times, const int *const pointerIds, const int inputSize,
const int *const times, const int *const pointerIds,
const float verticalSweetSpotScale, const int inputSize,
const bool isGeometric, const int pointerId, const int pushTouchPointStartIndex,
std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs,
std::vector<int> *sampledInputTimes, std::vector<int> *sampledLengthCache,
@ -84,6 +85,7 @@ class ProximityInfoStateUtils {
const int inputIndex, const int keyId);
static void initGeometricDistanceInfos(const ProximityInfo *const proximityInfo,
const int sampledInputSize, const int lastSavedInputSize,
const float verticalSweetSpotScale,
const std::vector<int> *const sampledInputXs,
const std::vector<int> *const sampledInputYs,
std::vector<NearKeycodesSet> *SampledNearKeySets,
@ -118,6 +120,7 @@ class ProximityInfoStateUtils {
static float updateNearKeysDistances(const ProximityInfo *const proximityInfo,
const float maxPointToKeyLength, const int x, const int y,
const float verticalSweetSpotScale,
NearKeysDistanceMap *const currentNearKeysDistances);
static bool isPrevLocalMin(const NearKeysDistanceMap *const currentNearKeysDistances,
const NearKeysDistanceMap *const prevNearKeysDistances,
@ -130,7 +133,8 @@ class ProximityInfoStateUtils {
std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs);
static bool pushTouchPoint(const ProximityInfo *const proximityInfo,
const int maxPointToKeyLength, const int inputIndex, const int nodeCodePoint, int x,
int y, const int time, const bool doSampling, const bool isLastPoint,
int y, const int time, const float verticalSweetSpotScale,
const bool doSampling, const bool isLastPoint,
const float sumAngle, NearKeysDistanceMap *const currentNearKeysDistances,
const NearKeysDistanceMap *const prevNearKeysDistances,
const NearKeysDistanceMap *const prevPrevNearKeysDistances,

View File

@ -48,13 +48,6 @@
namespace latinime {
// Naming convention
// - Distance: "Weighted" edit distance -- used both for spatial and language.
// - Compound Distance: Spatial Distance + Language Distance -- used for pruning and scoring
// - Cost: delta/diff for Distance -- used both for spatial and language
// - Length: "Non-weighted" -- used only for spatial
// - Probability: "Non-weighted" -- used only for language
// This struct is purely a bucket to return values. No instances of this struct should be kept.
struct DicNode_InputStateG {
bool mNeedsToUpdateInputStateG;

View File

@ -426,7 +426,6 @@ void Suggest::processDicNodeAsOmission(
weightChildNode(traverseSession, childDicNode);
if (!TRAVERSAL->isPossibleOmissionChildNode(traverseSession, dicNode, childDicNode)) {
DicNode::managedDelete(childDicNode);
continue;
}
processExpandedDicNode(traverseSession, childDicNode);

View File

@ -23,6 +23,15 @@
namespace latinime {
// Naming convention
// - Distance: "Weighted" edit distance -- used both for spatial and language.
// - Compound Distance: Spatial Distance + Language Distance -- used for pruning and scoring
// - Cost: delta/diff for Distance -- used both for spatial and language
// - Length: "Non-weighted" -- used only for spatial
// - Probability: "Non-weighted" -- used only for language
// - Score: Final calibrated score based on the compound distance, which is sent to java as the
// priority of a suggested word
class DicNode;
class DicTraverseSession;
class ProximityInfo;