openCVで顔をごにょごにょする#TechLunch

 openCVで顔をごにょごにょする#TechLunch

openCVで顔をごにょごにょする
2013/02/26 (水) 12:00-13:00 @ Livesense TechLunch
発表者:植村 健太

E60aa4f80303f3f386898546ddb3686a?s=128

Livesense Inc.

April 21, 2014
Tweet

Transcript

  1. PQFO$7ͰإΛ͝ʹΐ͝ʹΐͯ͠ΈΔ σβΠϯ෦ɹ২ଜݐଠ 14೥2݄26೔ਫ༵೔

  2. PQFODWͱ͸ OpenCVʢΦʔϓϯγʔϰΟɺӳޠ: Open Source Computer Vision Libraryʣͱ͸Πϯς ϧ͕։ൃɾެ։ͨ͠ΦʔϓϯιʔεͷίϯϐϡʔλϏδϣϯ޲͚ϥΠϒϥϦɻ C/C++ɺJavaɺPython޲͚ʹϥΠϒϥϦ͕͋Δ ίϯϐϡʔλϏδϣϯʢcomputer

    visionʣ͸େࡶ೺ʹݴͬͯɺʮϩϘοτͷ໨ʯΛ࡞Δݚڀ෼໺Ͱ͋Δ 14೥2݄26೔ਫ༵೔
  3. Կ͕ग़དྷΔʁ ը૾ॲཧ (Image Processing) ߏ଄ղੳ (Structural Analysis) Ϟʔγϣϯղੳͱ෺ମ௥੻ (Motion Analysis

    and Object Tracking) ύλʔϯೝࣝ (Pattern Recognition) ΧϝϥΩϟϦϒϨʔγϣϯͱ3࣍ݩ࠶ߏ੒ (Camera Calibration and 3D Reconstruction) ػցֶश ϢʔβΠϯλϑΣʔε 14೥2݄26೔ਫ༵೔
  4. ࠓ೔͸ը૾ೝࣝΛ͠·͢ɻ 14೥2݄26೔ਫ༵೔

  5. ը૾ೝࣝͬͯԿʁ ίϯϐϡʔλʔ͸͜ͷը૾͸إͳͷ͔ɺͳΜͳͷ͔Α͘Θ͔ͬͯͳ͍ͷ ͰͦΕΛڭ͑ͯ͋͛·͢ɻ 14೥2݄26೔ਫ༵೔

  6. Ͳ͏΍ͬͯೝ͍ࣝͯ͠Δʁ 1.ਓͷإͷࣸਅͬͯ໨ͷճΓΛ΅͔ͯ͠ݟΔͱɺͦͷ͙͢Լͷ๹ͷ͋ͨΓΑΓ͸҉͍ɻ 2.૭ը૾ͷத͔Β໨ͷลΓʹͳΔҐஔͷ্Լʹྡ઀͢Δԣ௕ͷ௕ํܗྖҬΛ੾Γग़ͯͦ͠ΕͧΕͷྖҬͷ ໌౓ͷฏۉΛͱΔɻ 3.্ͷྖҬ͕໌Δͯ͘ԼͷྖҬ͕҉͔ͬͨΒإը૾ͷީิʹ͢Δɻ 4.ඓےͷఱลΑΓ͸ඓےͷ྆࿬ͷ໌Δ͞ͷฏۉͷ΄͏͕খ͍͜͞ͱ͕ଟ͍ɻ ʙ إͱͯ͠ೝࣝ ͲΜͲΜإͷީิ͔Β֎͍ͯ͘͠ 14೥2݄26೔ਫ༵೔

  7. ࣮ࡍʹ΍ͬͯΈΔ XJUI 14೥2݄26೔ਫ༵೔

  8. PQFO'SBNFXPSLTͬ͘͟Γ ήʔϜͱ͔ΠϯελϨʔγϣϯΛ࡞Δͷʹ޲͍ͯΔ ΫϩεϓϥοτϑΥʔϜͷ ΞϓϦέʔγϣϯ։ൃϑϨʔϜϫʔΫ 14೥2݄26೔ਫ༵೔

  9. 14೥2݄26೔ਫ༵೔

  10. 14೥2݄26೔ਫ༵೔

  11. إݕग़ϥΠϒϥϦΛ࢖͏ PG0QFO$7 14೥2݄26೔ਫ༵೔

  12. PGY0QFO$Wͷإݕग़ϥΠϒϥϦ ϝϞɿϓϩάϥϜಈ͔͢ 14೥2݄26೔ਫ༵೔

  13. void testApp::setup(){ finder.setup("haarcascade_frontalface_alt2.xml"); vid.allocate(CAM_WIDTH, CAM_HEIGHT); gray.allocate(CAM_WIDTH, CAM_HEIGHT); vidGrabber.setVerbose(true); vidGrabber.initGrabber(CAM_WIDTH, CAM_HEIGHT);

    } PQFO$7ͷإݕग़ϥΠϒϥϦ 14೥2݄26೔ਫ༵೔
  14. void testApp::update(){ vidGrabber.update(); vid.setFromPixels(vidGrabber.getPixels(), CAM_WIDTH, CAM_HEIGHT); vid.convertRgbToHsv(); vid.convertToGrayscalePlanarImage(gray, 2); finder.findHaarObjects(gray);

    } 14೥2݄26೔ਫ༵೔
  15. void testApp::draw(){ ofSetColor(255,255,255); vidGrabber.draw(0,0); gray.draw(CAM_WIDTH, 0, CAM_WIDTH, CAM_HEIGHT); //ofNoFill(); ofSetColor(255,

    255, 0); int numFace = finder.blobs.size(); float x[numFace], y[numFace], w[numFace], h[numFace]; for(int i = 0; i < numFace; i++) { ofRect( finder.blobs[i].boundingRect ); } } 14೥2݄26೔ਫ༵೔
  16. ྠֲநग़Λߦ͏ʴিಥ൑ఆ PG#PYE PG0QFO$7 14೥2݄26೔ਫ༵೔

  17. എܠࠩ෼Λߦ͏ࣄͰྠֲநग़ 14೥2݄26೔ਫ༵೔

  18. ͬ͘͟ΓͲ͏͍͏͜ͱ͔ ݕग़͢Δ෺ମ͕ͳ͍ঢ়ଶͰɺഎܠը૾Λه࿥͓ͯ͘͠ ݕग़͢Δ෺ମΛؚΊͨݱࡏͷը૾Λೖྗ ه࿥͓͍ͯͨ͠എܠը૾ͱɺݱࡏͱͷࠩ෼Λͱͬͨը૾Λੜ੒ ࠩ෼Λͱͬͨը૾Λഎܠ͔Β෼཭͢ΔͨΊɺઃఆͨ͠஋Λᮢ஋ͱ͠ ͯɺനࠇʹۃԽ͢Δ 14೥2݄26೔ਫ༵೔

  19. நग़ͨ͠ϥΠϯΛিಥ൑ఆʹར༻͢Δ 14೥2݄26೔ਫ༵೔

  20. PGY#PYE 14೥2݄26೔ਫ༵೔

  21. PGY#PYEͬ͘͟Γ ʮ෺ཧΤϯδϯʯ ॏྗ΍িಥɺຎࡲͱ͍ͬͨ෺ཧܭࢉΛෳࡶͳܭࢉΛ͢Δ͜ͱͳ͘ར༻Ͱ͖Δ //Box2Dॳظઃఆ box2d.init(); //Box2DͷੈքΛॳظԽ box2d.setGravity(xํ޲΁ͷॏྗ, yํ޲΁ͷॏྗ); box2d.createBounds(0, 0,ɹը໘ͷ෯,ɹը໘ͷߴ͞);

    //ը໘ΛนͰғΉ box2d.setFPS(30); //30fpsͰදࣔ box2d.checkBounds(true); Person yuji; yuji.setPhysics(ॏ͞,൓ൃྗ,ຎࡲྗ); yuji.setup(box2d.getWorld(), x࠲ඪ, y࠲ඪ (, r)); yuji.draw(); #include "ofxBox2d.h" ofxBox2d box2d; vector <ofxBox2dCircle> Person;ɹ//ಈత഑ྻΛ࢖༻͢ΔɻϜμͳϝϞϦফඅΛ๷͙ ઃఆྫϔομϑΝΠϧଆ ઃఆྫιʔεϑΝΠϧଆ ϝϞɿϓϩάϥϜಈ͔͢ 14೥2݄26೔ਫ༵೔
  22. ·ͱΊ ofxOpenCvݕग़ϥΠϒϥϦ͸xmlΛಡΈࠐΉ͚ͩͳͷͰݪཧͱ͔෼͔Βͳͯ͘΋࢖͑Δɻ͍Ζ͍Ζ ૊Έ߹Θͤͳ͍ͱਫ਼౓ଟ෼͕͋Μͳ͍ إೝূ͸ϋʔυϧߴ͍ͬ͢ɻຊՈͰ΍ͬͨ΄͏͕Αͦ͞͏ addon͕๛෋Ͱɺ૊Έ߹Θͤ࣍ୈͰ͍Ζ͍ΖͰ͖ΔʢMIDI৴߸+෺ཧԋࢉ+KINECTͱ͔ʣ ૊Έ߹Θͤͳ͍ͱHTML5ͷAPIͱ͋Μ·มΘΜͳ͍ɻ ϝϞϦϦʔΫͨ͠ΒམͪΔɻݶք͕ͲΕ͘Β͍ͳͷ͔͸Ϗϧυͯ͠Έͳ͍ͱ෼͔Βͳ͍͠ɺϚγ ϯεϖοΫʹ΋ґଘ ͸͡Ί͔Β៛ີʹઃܭ࣮ͯ͠૷͢ΔΑΓ΋ɺ࡞Γͳ͕Βࢼ͢ʢεέον͢Δʣײ͡Ͱઓͬͨ΄͏ ͕͍͍ɻܭࢉͲ͏Γʹ͸͍͔ͳ͍͜ͱͷ΄͏͕ଟ͍ɻ

    ͋·ΓݫີͳϓϩάϥϜؾʹ͠ͳͯ͘΋͍͍Α͏ʹྑ͖ʹܭΒͬͯ͘ΕͯΔͷͰɺϓϩάϥϜ෼͔ Μͳͯ͘΋ͳΜͱ͔ͳΔɻ 14೥2݄26೔ਫ༵೔
  23. ͓ΘΓ openframeworksͰΩϛ΋ि຤ϓϩάϥϛϯάʂʂ 14೥2݄26೔ਫ༵೔