2012-02-03 58 views
0

我碰到face.com的API,我想一個簡單的PHP代碼來檢測臉...face.com API,如何檢測臉部然後提取它?

我得到如下回應,當我試圖在face.detect API:

<tag> 
<tid>[email protected]_e200f9aee59fb59a97a325e17f79edcc_74.38_53.56_0_0</tid> 
<recognizable>1</recognizable> 
<threshold></threshold> 
<uids> 
</uids> 
<gid></gid> 
<label></label> 
<confirmed>0</confirmed> 
<manual>0</manual> 
<tagger_id></tagger_id> 
<width>18.75</width> 
<height>33.33</height> 
<center> 
    <x>74.38</x> 
    <y>53.56</y> 
</center> 
<eye_left> 
    <x>70.51</x> 
    <y>45.42</y> 
</eye_left> 
<eye_right> 
    <x>78.55</x> 
    <y>45.88</y> 
</eye_right> 
<mouth_left> 
    <x>70.35</x> 
    <y>61.11</y> 
</mouth_left> 
<mouth_center> 
    <x>73.95</x> 
    <y>62.66</y> 
</mouth_center> 
<mouth_right> 
    <x>78.09</x> 
    <y>61.82</y> 
</mouth_right> 
<nose> 
    <x>74.01</x> 
    <y>55.01</y> 
</nose> 
<ear_left></ear_left> 
<ear_right></ear_right> 
<chin></chin> 
<yaw>-1.46</yaw> 
<roll>1.85</roll> 
<pitch>1.73</pitch> 
<attributes > 
    <glasses> 
     <value>false</value> 
     <confidence>16</confidence> 
    </glasses> 
    <smiling> 
     <value>true</value> 
     <confidence>84</confidence> 
    </smiling> 
    <face> 
     <value>true</value> 
     <confidence>93</confidence> 
    </face> 
    <gender> 
     <value>male</value> 
     <confidence>24</confidence> 
    </gender> 
    <mood> 
     <value>happy</value> 
     <confidence>18</confidence> 
    </mood> 
    <lips> 
     <value>parted</value> 
     <confidence>64</confidence> 
    </lips> 
</attributes> 
</tag> 

問題是:我如何提取臉部圖像?我可以看到臉部寬度是18.75,身高是33.33,但是全尺寸是844x450,那麼我如何才能反映這些值以專門用旋轉值來抓取臉部呢?謝謝

+0

喲有寬度,高度和臉部中心,所以你所要做的只是簡單的數學。 – 2012-02-03 20:01:11

+0

@ dev-null-dweller:好吧,中心是74.38,53.56,根據圖像邊緣,它是臉部中心的x/y位置嗎?這是不正確的。 – Ashraf 2012-02-03 20:04:18

+1

不,它們是圖像寬度/高度的百分比。 – 2012-02-03 20:18:28

回答

2

dev-null-dweller表示返回值的百分比。

查看face.com API Sandbox以查看響應的可視化。