在 wxpython 中捕捉到像素
我正在创建一个简单的 GUI 来记录在图像上单击的点,使用 wxpython。但是,我希望点击能够捕捉到图像上的某些点。请建议方法。
I am creating a simple GUI to record points which are clicked on the image, using wxpython. However, i would like the click to be snapped to certain points on the image. Please suggest methods.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最容易捕捉到固定比例网格的方法是:
其中比例是网格的大小,例如 10 像素。
如果点分布不均匀,则根据距离(或出于效率原因,使用距离的平方)找到最接近的点。
The easiest to snap to a fixed scale grid is with something like:
where scale is the size of your grid, eg 10 pixels.
If the points are nonuniformly distributed, then find the closest based on the distance (or the square of the distance for efficiency reasons).
您可能会看一下 wxPython 的 对象图形库。文档有点稀疏,但是 Diagram 类 有直接支持对齐网格;查看 wxPython 演示 Miscellaneous->OGL 部分,了解一些入门想法。我正在进行一个项目w。现在的 OGL - 它的功能很棒,但就像我说的,我发现文档有点薄。
You might have a look at wxPython's Object Graphics Library. The documentation's a little sparse but the Diagram class has direct support for snapping to grids; take a look at the wxPython Demo's Miscellaneous->OGL section for some ideas to get started. I'm in the middle of a project w. OGL right now - it's great for what it does but like I said I find the documentation a little thin.