Delphi:如何像 facebook 那样标记照片 [英] Delphi: How to tag photos the way facebook does

查看:23
本文介绍了Delphi:如何像 facebook 那样标记照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种在 Delphi 桌面应用程序中标记照片的方法,就像 Facebook 那样.

I need a way to tag photos in a Delphi desktop application the way Facebook does it.

这包括一些方法可以轻松地在人物上添加标签,然后将鼠标悬停在照片中的人物上以显示标签.

That includes some way to easily add the tags over the people, and then hovering the mouse over the person in the photo to show the tag.

给出的答案中的两个建议:Delphi Components for Face Identification和标记"不能解决这个问题.

The two suggestions in the answer given to: "Delphi Components for Face Identification and Tagging" don't solve this.

但我不知道从哪里开始,也无法在网上找到有关如何执行此操作的想法.脸书是如何做到的?或者也许有一个允许它的 Delphi 组件.

But I have no idea where to start, and have been unable to find ideas on the web on how to do this. How does Facebook do it? Or maybe there's a component for Delphi that will allow it.

尝试实现类似 Facebook 的标记的最佳方式是什么?

What would be the best way to try to implement Facebook-like tagging?

附言这是 Facebook 对此的一些 API 定义:http://wiki.developers.facebook.com/index.php/Photos.addTag

p.s. This is some of Facebook's API definition for this: http://wiki.developers.facebook.com/index.php/Photos.addTag

这是一个 Java 程序,它实现了我想在我的 Delphi 应用程序中执行的面部标记功能:fb-photo-uploader

Here is a Java program that implements the face tagging functionality that I want to do in my Delphi app: fb-photo-uploader

推荐答案

你引用的API的关键参数是图片ID、坐标和标签.标签可以是 Facebook 用户的用户 ID,也可以是自由格式的文本(当标记的主题不是 Facebook 用户时).Facebook 只使用一个坐标,因为它使用固定大小的区域来表示标记区域;这个想法是你点击一个人的脸的中心,Facebook 只是存储那个点.

The key parameters of the API you cited are the picture ID, the coordinates, and the tag. The tag can be either the user ID of a Facebook user, or it can be free-form text (for the case when the tagged subject is not a Facebook user). Facebook uses just one coordinate because it uses fixed-size regions to denote a tagged area; the idea is that you click on the center of a person's face, and Facebook just stores that point.

如果您在 TImage 控件中显示图片(毕竟这是显而易见的首选),您可以使用 OnMouseDownOnMouseUp 检测鼠标点击 事件.(OnClick 事件更简单,但不会告诉您坐标.)一旦您获得了一个点,提示输入一个标签来伴随该点.你可以使用预先确定的标签,比如 Facebook 的用户 ID,或者只使用普通文本,或者使用你自己设计的东西.您使用什么来表示标签值的问题与您迄今为止提出的任何其他问题都是正交的.

If you display a picture in a TImage control (that's the obvious first choice, after all), you can detect mouse clicks with the OnMouseDown and OnMouseUp events. (The OnClick event is simpler, but doesn't tell you the coordinates.) Once you've acquired a point, prompt for a label to accompany that point. You can use predetermined labels, like Facebook's user IDs, or just use ordinary text, or use something of your own devising. The question of what you use to represent a tag value is orthogonal to whatever other questions you've asked so far.

Facebook 的照片标记的另一半是,将鼠标移到图像上会在图像上显示标签文本,将鼠标移到下面的标签上会突出显示相关区域.处理 OnMouseMove 事件并编写一些代码以根据需要显示或隐藏标签和形状.如果您使用 TLabelTShape,您甚至可能不必修改图像,但在图像顶部显示这些控件可能会干扰进一步的 OnMouseMove事件.尝试一些实验并查看适合您的方法应该不会花费太长时间.

The other half of Facebook's photo tagging is that moving the mouse over the image displays the tag text over the image, and moving the mouse over the labels below highlight the associated regions. Handle OnMouseMove events and write some code to display or hide labels and shapes as appropriate. If you use TLabel and TShape, you might not even have to modify the image, but showing those controls on top of the image might interfere with further OnMouseMove events for the image. It shouldn't take too long to try some experiments and see what works for you.

这篇关于Delphi:如何像 facebook 那样标记照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆