使用Picasa API提取单个图像的自动人脸检测 [英] Automatic face detection using Picasa API to extract individual images

查看:225
本文介绍了使用Picasa API提取单个图像的自动人脸检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(A类似的问题已经被问上的超级用户对相关应用的答案。问题是张贴在这里聚集的可编程解决方案相同)

在我工作的地方,护照照片扫描在一起,然后切成单张照片并保存具有独特的文件编号。目前我们使用Paint.net手动选择,剪切和保存图片。

At my work place, passport sized photographs are scanned together, then cut up into individual pictures and saved with unique file numbers. Currently we use Paint.net to manually select, cut and save the pictures.

样品扫描文档的Picasa截图:
(来源:谷歌图片搜索多个来源,fairuse)

Sample Scanned Document Picasa Screenshot: (from: google image search multiple sources, fairuse)

有关如。在Picasa 3.8,在点击查看>的人,所有的面孔示,我问他们的名字,我可以自动保存这些个人照片与名字不同的照片?

For eg. In Picasa 3.8, On clicking View > People, all the faces are shown and I am asked to name them, can I save these individual pictures automatically with the names as different pictures?

更新

所有我想要做的就是上面的转换对单张照片的图片。

All I want to do is convert the picture above to individual pictures.

在上图中,我已经展示的Picasa 3.8如何检测图像,并提示我给它们命名。我不需要人脸识别,我只是需要人脸检测。 Picasa中检测到单个图像,并显示他们在RHS。这些独立的图像是我需要什么。 Picasa会创建一个.ini文件,从而节省了包含各个面的坐标的十六进制值。

In the image above, I have shown how Picasa 3.8 detects the images and prompts me to name them. I do not need face recognition, I simply need face detection. Picasa detects the individual images and shows them on the RHS. These individual images are what I need. Picasa creates a .ini file which saves the hex values which contains the co-ordinates of the individual faces.

这些各个面都是我感兴趣的。如果我能有坐标,我可以从图片裁剪所需的图像。

SAMPLE.jpg

INI内容

 [SAMPLE.jpg]
faces=rect64(c18f4c8ef407851e),d4ff0a020be5c3c0;rect64(534a06d429ae627),dff6163dfd9d4e41;rect64(b9c100fae46b3046),e1059dcf6672a2b3;rect64(7b5105daac3a3cf4),4fc7332c107ffafc;rect64(42a036a27062a6c),ef86c3326c143248;rect64(31f4efe3bd68fd8),90158b3d3b65dc9b;rect64(327904e0614d390d),43cbda6e92fcb63e;rect64(4215507584ae9b8c),15b6a967e857f334;rect64(895d4efeb8b68425),5c4ff70ac70b27d3
backuphash=3660

* ini文件似乎是节省了脸标签的坐标为 rect64(534a06d429ae627),dff6163dfd9d4e41 为每个标签。
Picasa帮助网站用户引用<一个href=\"http://www.google.com/support/forum/p/Picasa/user?userid=02815233294807518823&hl=en\">Technonath说

*The ini file seems to be saving the co-ordinates of the face tags as rect64(534a06d429ae627),dff6163dfd9d4e41 for each tag. Quoting from Picasa Help Site user Technonath says

@oedious写道: - 这将是
  有些技术,所以坚持下去。
  *在rect64()包裹的数字是一个64位的十六进制数。
  *打破这种成4个16位的数字。
  *由最大无符号16位数字(65535)将每个你就会有
  0和1之间的四个数字。
  *四个数字其余的给你脸相对坐标
  矩形(左,上,右,下)。
  *如果你想用绝对坐标结束了,多的左,
  权由图像宽度和顶
  和由图像高度底

@oedious wrote:- This is going to be somewhat technical, so hang on. * The number encased in rect64() is a 64-bit hexadecimal number. * Break that up into four 16-bit numbers. * Divide each by the maximum unsigned 16-bit number (65535) and you'll have four numbers between 0 and 1. * The four numbers remaining give you relative coordinates for the face rectangle: (left, top, right, bottom). * If you want to end up with absolute coordinates, multiple the left and right by the image width and the top and bottom by the image height.

有关rect64(包裹数以上报价谈判)怎么样的逗号后面括号外的数字?

The above quote talks about the number encased in rect64() what about the number outside the parentheses after the comma?

我曾问一个相关的问题。其中的答案可能帮助你。
<一href=\"http://stackoverflow.com/questions/3892408/get-four-16bit-numbers-from-a-64bit-hex-value\">http://stackoverflow.com/questions/3892408/get-four-16bit-numbers-from-a-64bit-hex-value

I have asked a related question. Answers of which may help you too. http://stackoverflow.com/questions/3892408/get-four-16bit-numbers-from-a-64bit-hex-value

注:
  INI细节是相同的哪个的Picasa
  对于特定的图像生成

Note: The ini details are the same which picasa generated for the particular image.

另外的问题已经被更新多次,可能不够明确。

Plus the question has been updated multiple times and may not be clear enough.

有在 Picasa帮助网站一些回应,在那里我问同样的问题
一位来自该线程的答案,以获得基于来自ini文件的十六进制值坐标。下面code是在C#中的<一个href=\"http://www.google.com/support/forum/p/Picasa/user?userid=06712422887226750608&hl=en\">esac从帮助网站。我可以做同样在PHP?

There are some responses at the Picasa Help site, where I asked the same question One of the answers from that thread to get co-ordinates based on the hex values from the ini file. The following code is in C# from esac from the help site. Can I do the same in PHP?

public static RectangleF GetRectangle(string hashstr)
{
    UInt64 hash = UInt64.Parse(hashstr, System.Globalization.NumberStyles.HexNumber);
    byte[] bytes = BitConverter.GetBytes(hash);

    UInt16 l16 = BitConverter.ToUInt16(bytes, 6);
    UInt16 t16 = BitConverter.ToUInt16(bytes, 4);
    UInt16 r16 = BitConverter.ToUInt16(bytes, 2);
    UInt16 b16 = BitConverter.ToUInt16(bytes, 0);

    float left = l16 / 65535.0F;
    float top = t16 / 65535.0F;
    float right = r16 / 65535.0F;
    float bottom = b16 / 65535.0F;

    return new RectangleF(left, top, right - left, bottom - top);
} 

PHP code 尝试的64位转换为数字1和0之间

PHP code trying to convert 64bit to numbers between 1 and 0

<?php
$dim = getimagesize("img.jpg");    
$hex64=array();
$b0="c18f4c8ef407851e";
$hex64[]=substr($b0,0,4);
$hex64[]=substr($b0,4,4);
$hex64[]=substr($b0,8,4);
$hex64[]=substr($b0,12,4);
$width=$dim[0];
$height=$dim[1];
foreach($hex64 as $hex16){
$dec=hexdec($hex16);
$divide=65536;
$mod=$dec%$divide;
$result=$dec/$divide;
$cordinate1=$result*$width;
$cordinate2=$result*$height;
echo "Remainder 1 : ".$mod." ; Result 1 :  ".$result."<br/>CO-ORDINATES : <B>".$cordinate1." ".$cordinate2."</B><br/>";
}
?>

输出

余1:49551;结果1:
  0.75608825683594坐标:371.99542236328 396.94633483887余1:19598;结果1:
  0.29904174804688坐标:147.12854003906 156.99691772461余1:62471;结果1:
  0.95323181152344坐标:468.99005126953 500.4467010498余1:34078;结果1:
  0.51998901367188坐标:255.83459472656 272.99423217773

Remainder 1 : 49551 ; Result 1 : 0.75608825683594 CO-ORDINATES : 371.99542236328 396.94633483887 Remainder 1 : 19598 ; Result 1 : 0.29904174804688 CO-ORDINATES : 147.12854003906 156.99691772461 Remainder 1 : 62471 ; Result 1 : 0.95323181152344 CO-ORDINATES : 468.99005126953 500.4467010498 Remainder 1 : 34078 ; Result 1 : 0.51998901367188 CO-ORDINATES : 255.83459472656 272.99423217773

所以我的坐标也和@Nirmal有<一个href=\"http://stackoverflow.com/questions/3872112/automatic-face-detection-using-picasa-api-to-extract-individual-images/3932181#3932181\">shown如何裁剪他们。现在,下一步将是解析picasa.ini为十六进制codeS和文件名和整合code。 Picasa中目前不通过API提供六角codeS(或是吗?)。如果是这样的话,事情会更好。

So I have the co-ordinates too and @Nirmal has shown how to crop them. Now next steps would be to parse picasa.ini for the hex codes and file names and integrate the code. Picasa doesn't currently provide the hex codes via a api(or Do they?). If that were the case, things would have been better.

因此​​,我们即将解决。谢谢大家,我希望我能颁发赏金给大家(我不能,但不要害怕,并期待在您的代表秒杀!)

So we are nearing a solution. Thank you all, I wish I could award the bounty to everyone(I cannot, but fear not and look out for a spike in your rep!)

推荐答案

要回答这个问题的Picasa,请在Picasa中论坛这样的响应:结果
http://www.google.com/support/forum/p/Picasa/thread?tid=36ae553a7b49088e&hl=en

To answer the picasa question, see this response on the picasa forums:
http://www.google.com/support/forum/p/Picasa/thread?tid=36ae553a7b49088e&hl=en

@oedious写道: - 这将是
  有些技术,所以坚持下去。
  *在rect64()包裹的数字是一个64位的十六进制数。
  *打破这种成4个16位的数字。
  *由最大无符号16位数字(65535)将每个你就会有
  0和1之间的四个数字。
  *四个数字其余的给你脸相对坐标
  矩形(左,上,右,下)。
  *如果你想用绝对坐标结束了,多的左,
  权由图像宽度和顶
  和由图像高度底

@oedious wrote:- This is going to be somewhat technical, so hang on. * The number encased in rect64() is a 64-bit hexadecimal number. * Break that up into four 16-bit numbers. * Divide each by the maximum unsigned 16-bit number (65535) and you'll have four numbers between 0 and 1. * The four numbers remaining give you relative coordinates for the face rectangle: (left, top, right, bottom). * If you want to end up with absolute coordinates, multiple the left and right by the image width and the top and bottom by the image height.

这篇关于使用Picasa API提取单个图像的自动人脸检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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