Automatic face detection using Picasa API to extract individual images

前端 未结 7 1212
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 01:15

(A similar question has been asked on superuser for answers related to applications. The question is posted here to gather programmable solutions for the same)

7条回答
  •  没有蜡笔的小新
    2020-12-13 01:51

    For the cropping part, I am typing the code without testing, but this should work:

    371, 'Y'=>156);
    $p2 = array('X'=>468, 'Y'=>156);
    $p3 = array('X'=>468, 'Y'=>272);
    $p4 = array('X'=>371, 'Y'=>272);
    
    //let's calculate the parametres
    $srcX = $p1['X'];
    $srcY = $p1['Y'];
    $width = $p2['X'] - $p1['X'];
    $height = $p4['Y'] - $p1['Y'];
    
    //image processing
    $srcImg = imagecreatefromjpeg($srcImg);
    $dstImg = imagecreatetruecolor($width, $height);
    imagecopy($dstImg, $srcImg, 0, 0, $srcX, $srcY, $width, $height);
    imagejpeg($dstImg, $outImg, 100); // 100 for highest quality, 0 for lowest quality
    imagedestroy($dstImg);
    ?>
    

    The above code assumes that your source image is in JPEG format and the coordinates make a perfect rectangle or square.

    Hope that helps.

提交回复
热议问题