Created
January 13, 2020 00:14
-
-
Save Aminadav/6e90b4e5c11e9cbb791c2a9854597716 to your computer and use it in GitHub Desktop.
Face Detection (face_detection + crop using imagemagick + batch using xargs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using: ls yadani | xargs -L 1 -I {} node extract yadani/{} cropped/{} | |
var cp=require("child_process") | |
var x=new Array(...process.argv) | |
var target=x.pop().replace(/ /g,'\\ ') | |
var src=x.pop().replace(/ /g,'\\ ') | |
console.log({target,src}) | |
var res=cp.execSync(`face_detection ${src}`).toString().trim() | |
var a=res.split(',') | |
console.log({a}) | |
// wXh,x,y | |
// Top Right x,y, bottom left x,y | |
var str=`convert ${src} -crop ${a[3]-a[1]}x${a[2]-a[4]}+${a[4]}+${a[1]} ${target}` | |
console.log(str) | |
var res=cp.execSync(str) | |
console.log(res.toString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment