google / ink-stroke-modeler Goto Github PK
View Code? Open in Web Editor NEWC++ library for beautifully smoothing freehand (touch/stylus/pointer) input.
License: Apache License 2.0
C++ library for beautifully smoothing freehand (touch/stylus/pointer) input.
License: Apache License 2.0
Is it possible to provide an version in javascript? or could be used in web with wasm?
Hello.
I'm working on Python bindings for using this library, and so far I have accomplished this with a Not so clean solution using C++ lambda expressions to avoid issues with the absl::Status returned by the Reset and Update functions of the StrokeModeler class like this:
py::class_<ink::stroke_model::StrokeModeler>(handle, "StrokeModeler")
.def(py::init<>())
.def("Reset", [](ink::stroke_model::StrokeModeler &self) -> py::str {
auto status = self.Reset();
if(!status.ok()) {
return py::str(status.message());
}
return py::str("OK");
})
.def("Reset", [](ink::stroke_model::StrokeModeler &self, ink::stroke_model::StrokeModelParams params) -> py::str {
auto status = self.Reset(params);
if(!status.ok()) {
return py::str(status.message());
}
return py::str("OK");
})
.def("Update", [](ink::stroke_model::StrokeModeler &self, const ink::stroke_model::Input& input, std::vector<ink::stroke_model::Result>& result) -> py::str {
auto status = self.Update(input, result);
if(!status.ok()) {
return py::str(status.message());
}
return py::str("OK");
})
.def("Save", &ink::stroke_model::StrokeModeler::Save)
.def("Restore", &ink::stroke_model::StrokeModeler::Restore);
Here you can see that the Save and Restore bindings are much clear to translate to python.
Another issue is that for this abseil implementation, I need to add into the pybind11 CMakeLists.txt file all dependencies on this project, eg:
pybind11_add_module(
smooth_lines
wrapper.cpp
#The following dependencies are not needed if there weren't an abseil dependency.
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/types.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/params.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/stroke_modeler.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/internal/wobble_smoother.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/internal/stylus_state_modeler.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/internal/prediction/kalman_predictor.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/internal/prediction/stroke_end_predictor.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/internal/prediction/kalman_filter/axis_predictor.cc
${CMAKE_SOURCE_DIR}/ink-stroke-modeler/ink_stroke_modeler/internal/prediction/kalman_filter/kalman_filter.cc
)
If abseil is not a dependency, the CMakeLists.txt file above would be much cleaner.
My suggestion is to use a custom exception class instead of using Abseil library. Not an expert in C++ so I'm not sure if a custom class is the best option, but removing the Abseil dependency would be great for this use case (and might be the same for other bindings).
Allstar has detected that this repository’s Branch Protection security policy is out of compliance. Status:
Branch Protection enforcement is configured in Allstar, however Branch Protection is not available on this repository. Upgrade to GitHub Pro or make this repository public to enable this feature.
See: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches for more information.
If this is not feasible, then disable Branch Protection policy enforcement for this repository in Allstar configuration.
This issue will auto resolve when the policy is in compliance.
Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.
Allstar has detected that this repository’s Outside Collaborators security policy is out of compliance. Status:
Did not find any owners of this repository
This policy requires all repositories to have an organization member or team assigned as an administrator. Either there are no administrators, or all administrators are outside collaborators. A responsible party is required by organization policy to respond to security events and organization requests.
To add an administrator From the main page of the repository, go to Settings -> Manage Access.
(For more information, see https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories)
Alternately, if this repository does not have any maintainers, archive or delete it.
This issue will auto resolve when the policy is in compliance.
Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.
The target name "ink_stroke_modeler_matrix)" is reserved or not valid for
certain CMake features, such as generator expressions, and may result in
undefined behavior.
Hi, I've tried to build this library on Windows 11 and MSVC2019, but the build fails. The following error seems to be responsible:
C:\Users\Documents\ink-stroke-modeler\_deps\gtest-src\googletest\src\gtes
t-all.cc(38,10): fatal error C1083: Cannot open include file: 'gtest/gtest.h':
No such file or directory
...
C:\Users\Documents\ink-stroke-modeler\ink_stroke_modeler/types.h(183,11):
error C7555: use of designated initializers requires at least '/std:c++20' [C:
\Users\Documents\ink-stroke-modeler\ink_stroke_modeler\ink_stroke_modeler
_types.vcxproj]
C:\Users\Documents\ink-stroke-modeler\ink_stroke_modeler/types.h(186,11):
error C7555: use of designated initializers requires at least '/std:c++20' [C:
\Users\Documents\ink-stroke-modeler\ink_stroke_modeler\ink_stroke_modeler
_types.vcxproj]
C:\Users\Documents\ink-stroke-modeler\ink_stroke_modeler/types.h(189,11):
error C7555: use of designated initializers requires at least '/std:c++20'
I see from the cmake scripts that that gtest should be fetched automatically, so not sure why the first error occurs (I was able to fix the first error using gtest from vcpkg).
Also, not sure if there are any plans for this already but it'd be really nice if this library could be made available through vcpkg.
Allstar has detected that this repository’s SECURITY.md security policy is out of compliance. Status:
Security policy not enabled.
A SECURITY.md file can give users information about what constitutes a vulnerability and how to report one securely so that information about a bug is not publicly visible. Examples of secure reporting methods include using an issue tracker with private issue support, or encrypted email with a published key.
To fix this, add a SECURITY.md file that explains how to handle vulnerabilities found in your repository. Go to https://github.com/googlestaging/ink-stroke-modeler/security/policy to enable.
For more information, see https://docs.github.com/en/code-security/getting-started/adding-a-security-policy-to-your-repository.
This issue will auto resolve when the policy is in compliance.
Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.
May I ask how to do it to support mobile terminals, iOS and Android
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.