Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Primer vistazo al computer vision | 4Sessions Feb17

750 views

Published on

Lo cognitivo está de moda, y en el Cloud empresas como Microsoft y Google, con Cloud Vision y Cognitive Services, se están encargando de atraer a muchos desarrolladores para que las cámaras de nuestros dispositivos empiecen a comprender un poquito el mundo que les rodea.

¿Pero estamos hablando realmente de algo nuevo, o es otra excusa para engancharnos a la nube?

En esta sesión hemos analizado las opciones que nos expone el mercado, más allá de las grandes compañías y hemos visto otras con mucha relevancia e historia a sus espaldas en el mercado como OpenCV (Open Source Computer Vision Library).

Qué, con quién y cómo hacer que tus desarrollos vean y comprendan el mundo.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Primer vistazo al computer vision | 4Sessions Feb17

  1. 1. Primer vistazo al COMPUTER VISION#FourSessions Toni Recio
  2. 2. Toni Recio @tonirecio Divulgador tecnológico tonirecio@techdencias.net@
  3. 3. Agenda Computer Vision Las diferentes aproximaciones Benchmarking de API’s en la nube OpenCV Consumir clasificador Detectar vs Identificar Crear un clasificador
  4. 4. Computer Vision
  5. 5. 2 cámaras de foto biológicas Captura de foto cada 200ms En 3 años un niño ha visto cientos de millones de “fotografías”
  6. 6. Pattern Recognition Machine Learning Deep Learning
  7. 7. Applied AI Strong AI
  8. 8. Applied AI Strong AI
  9. 9. Applied AI Strong AI
  10. 10. Applied AI Strong AI
  11. 11. Applied AI Strong AI
  12. 12. Applied AI Strong AI
  13. 13. FUTUROLOGÍA
  14. 14. FUTUROLOGÍA
  15. 15. FUTUROLOGÍA PRESENTOLOGÍA
  16. 16. Las diferentes aproximaciones
  17. 17. Benchmarking API’s en la nube
  18. 18. Vision > Computer Vision
  19. 19. Vision > Computer Vision
  20. 20. a cat sitting in front of a computer keyboard
  21. 21. Vision > Computer Vision
  22. 22. Vision > Computer Vision
  23. 23. Vision > Computer Vision
  24. 24. Vision > Computer Vision
  25. 25. Vision > Computer Vision
  26. 26. Vision > Face
  27. 27. Vision > Face
  28. 28. Vision > Face
  29. 29. Vision > Face
  30. 30. Vision > Face
  31. 31. Vision > Face
  32. 32. Vision > Face
  33. 33. Vision > Emotion
  34. 34. Vision > Emotion
  35. 35. Vision > Emotion
  36. 36. Vision > Video
  37. 37. Vision > Video
  38. 38. Vision > Video
  39. 39. Vision > Video
  40. 40. https://www.microsoft.com/cognitive-services/en-US/subscriptions
  41. 41. var visionClient = new VisionServiceClient("CLAVE_EXTRAIDA_DEL _PORTAL_DE_MCS"); using (Stream imageFileStream = File.OpenRead ("C:CODEComputerVisionSamplesComputerVision.WpfImagescatkeyboard.png")) { var features = new VisualFeature[] { VisualFeature.Adult, VisualFeature.Categories, VisualFeature.Color, VisualFeature.Description, VisualFeature.Faces, VisualFeature.ImageType, VisualFeature.Tags }; var result = await visionClient.AnalyzeImageAsync(imageFileStream, features); }
  42. 42. https://console.cloud.google.com
  43. 43. https://console.cloud.google.com
  44. 44. public static GoogleCredential CreateCredentials(string path) { GoogleCredential credential; using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { var c = GoogleCredential.FromStream(stream); credential = c.CreateScoped(VisionService.Scope.CloudPlatform); } return credential; }
  45. 45. public static VisionService CreateService( string applicationName, IConfigurableHttpClientInitializer credentials) { var service = new VisionService(new BaseClientService.Initializer() { ApplicationName = applicationName, HttpClientInitializer = credentials }); return service; }
  46. 46. public static IList<AnnotateImageResponse> DetectLabels( VisionService vision, string imagePath) { // Convert image to Base64 encoded for JSON ASCII text based request byte[] imageArray = System.IO.File.ReadAllBytes(imagePath); string imageContent = Convert.ToBase64String(imageArray); // Post label detection request to the Vision API var responses = vision.Images.Annotate( new BatchAnnotateImagesRequest() { Requests = new[] { new AnnotateImageRequest() { Features = new [] { new Feature() {Type = "LABEL_DETECTION"}, new Feature() {Type = "TEXT_DETECTION"}, new Feature() {Type = "FACE_DETECTION"}, new Feature() {Type = "LANDMARK_DETECTION"}, new Feature() {Type = "LOGO_DETECTION"}, new Feature() {Type = "SAFE_SEARCH_DETECTION"}, new Feature() {Type = "IMAGE_PROPERTIES"} }, Image = new Image() { Content = imageContent } } } }).Execute(); return responses.Responses; }
  47. 47. var credentails = CreateCredentials("c:archivoscredenciales.json"); var service = CreateService("TEST", credentails); var result = DetectLabels(service, "C:archivosplayoffs2016.jpg");
  48. 48. Open CV
  49. 49. http://opencv.org/
  50. 50. https://github.com/opencv/opencv/tree/master/data
  51. 51. http://www.emgu.com/wiki/index.php/Main_Page
  52. 52. long detectionTime; Mat image = new Mat("C:archivosplayoffs2016.jpg", LoadImageType.Color); List<System.Drawing.Rectangle> faces = new List<System.Drawing.Rectangle>(); using (CascadeClassifier cascadeCla = new CascadeClassifier("Classifiershaarcascade_frontalface_default.xml")) { Rectangle[] faces = cascadeCla.DetectMultiScale( image, 1.1, 8); }
  53. 53. long detectionTime; Mat image = new Mat("C:archivosplayoffs2016.jpg", LoadImageType.Color); List<System.Drawing.Rectangle> faces = new List<System.Drawing.Rectangle>(); using (CascadeClassifier cascadeCla = new CascadeClassifier("Classifiershaarcascade_frontalface_default.xml")) { Rectangle[] faces = cascadeCla.DetectMultiScale( image, 1.1, 8); }
  54. 54. Detectar Vs Identificar
  55. 55. María
  56. 56. 1 2 3 4 5
  57. 57. 1 2 3 4 5
  58. 58. Image<Gray, Byte>[] trainingImages = new Image<Gray, Byte>[5]; trainingImages[0] = new Image<Gray, byte>("C:Imagesalex.png"); trainingImages[1] = new Image<Gray, byte>("C:Imagesarturo.png"); trainingImages[2] = new Image<Gray, byte>("C:Imageslauree.png"); trainingImages[3] = new Image<Gray, byte>("C:Imagesjavier.png"); trainingImages[4] = new Image<Gray, byte>("C:maria.png");
  59. 59. Image<Gray, Byte>[] trainingImages = new Image<Gray, Byte>[5]; trainingImages[0] = new Image<Gray, byte>("C:Imagesalex.png"); trainingImages[1] = new Image<Gray, byte>("C:Imagesarturo.png"); trainingImages[2] = new Image<Gray, byte>("C:Imageslauree.png"); trainingImages[3] = new Image<Gray, byte>("C:Imagesjavier.png"); trainingImages[4] = new Image<Gray, byte>("C:maria.png"); int[] labels = new int[] { 1, 2, 3, 4, 5 };
  60. 60. Image<Gray, Byte>[] trainingImages = new Image<Gray, Byte>[5]; trainingImages[0] = new Image<Gray, byte>("C:Imagesalex.png"); trainingImages[1] = new Image<Gray, byte>("C:Imagesarturo.png"); trainingImages[2] = new Image<Gray, byte>("C:Imageslauree.png"); trainingImages[3] = new Image<Gray, byte>("C:Imagesjavier.png"); trainingImages[4] = new Image<Gray, byte>("C:maria.png"); int[] labels = new int[] { 1, 2, 3, 4, 5 }; var recognizer = new LBPHFaceRecognizer(1, 8, 8, 8, 100); recognizer.Train(trainingImages, labels);
  61. 61. Image<Gray, Byte>[] trainingImages = new Image<Gray, Byte>[5]; trainingImages[0] = new Image<Gray, byte>("C:Imagesalex.png"); trainingImages[1] = new Image<Gray, byte>("C:Imagesarturo.png"); trainingImages[2] = new Image<Gray, byte>("C:Imageslauree.png"); trainingImages[3] = new Image<Gray, byte>("C:Imagesjavier.png"); trainingImages[4] = new Image<Gray, byte>("C:maria.png"); int[] labels = new int[] { 1, 2, 3, 4, 5 }; var recognizer = new LBPHFaceRecognizer(1, 8, 8, 8, 100); recognizer.Train(trainingImages, labels); Image<Gray, Byte> testImage = new Image<Gray, Byte>("C:Imagestest.png");
  62. 62. Image<Gray, Byte>[] trainingImages = new Image<Gray, Byte>[5]; trainingImages[0] = new Image<Gray, byte>("C:Imagesalex.png"); trainingImages[1] = new Image<Gray, byte>("C:Imagesarturo.png"); trainingImages[2] = new Image<Gray, byte>("C:Imageslauree.png"); trainingImages[3] = new Image<Gray, byte>("C:Imagesjavier.png"); trainingImages[4] = new Image<Gray, byte>("C:maria.png"); int[] labels = new int[] { 1, 2, 3, 4, 5 }; var recognizer = new LBPHFaceRecognizer(1, 8, 8, 8, 100); recognizer.Train(trainingImages, labels); Image<Gray, Byte> testImage = new Image<Gray, Byte>("C:Imagestest.png"); var label = recognizer.Predict(testImage);
  63. 63. Image<Gray, Byte>[] trainingImages = new Image<Gray, Byte>[5]; trainingImages[0] = new Image<Gray, byte>("C:Imagesalex.png"); trainingImages[1] = new Image<Gray, byte>("C:Imagesarturo.png"); trainingImages[2] = new Image<Gray, byte>("C:Imageslauree.png"); trainingImages[3] = new Image<Gray, byte>("C:Imagesjavier.png"); trainingImages[4] = new Image<Gray, byte>("C:maria.png"); int[] labels = new int[] { 1, 2, 3, 4, 5 }; var recognizer = new LBPHFaceRecognizer(1, 8, 8, 8, 100); recognizer.Train(trainingImages, labels); Image<Gray, Byte> testImage = new Image<Gray, Byte>("C:Imagestest.png"); var label = recognizer.Predict(testImage);
  64. 64. Crear un clasificador
  65. 65. http://acodigo.blogspot.com.es/2015/12/entrenar-opencv-en-deteccion-de-objetos.html
  66. 66. http://www-cvr.ai.uiuc.edu/ponce_grp/data/
  67. 67. https://github.com/TutorProgramacion/opencv- traincascade/blob/master/image_dataset/images.rar
  68. 68. pos/pos-532.pgm 1 0 0 100 40 pos/pos-166.pgm 1 0 0 100 40 pos/pos-76.pgm 1 0 0 100 40 pos/pos-193.pgm 1 0 0 100 40 pos/pos-0.pgm 1 0 0 100 40 pos/pos-84.pgm 1 0 0 100 40 pos/pos-333.pgm 1 0 0 100 40 pos/pos-15.pgm 1 0 0 100 40 pos/pos-371.pgm 1 0 0 100 40 pos/pos-44.pgm 1 0 0 100 40 pos/pos-172.pgm 1 0 0 100 40 … cars.info neg/neg-225.pgm neg/neg-310.pgm neg/neg-24.pgm neg/neg-119.pgm neg/neg-198.pgm neg/neg-155.pgm neg/neg-31.pgm neg/neg-441.pgm neg/neg-56.pgm neg/neg-455.pgm neg/neg-144.pgm … neg.info
  69. 69. cd C:opencvbuildx86vc11bin opencv_createsamples -info cars.info -num 550 -w 48 -h 24 -vec cars.vec
  70. 70. c:opencvbuildx64vc12bin>opencv_traincascade.exe -data data -vec cars.vec -bg neg.info -numPos 500 -numNeg 500 -numStages 10 -w 48 -h 24 -featureType LBP
  71. 71. c:opencvbuildx64vc12bin>opencv_traincascade.exe -data data -vec cars.vec -bg neg.info -numPos 500 -numNeg 500 -numStages 10 -w 48 -h 24 -featureType LBP
  72. 72. Un vistazo atrás
  73. 73. Toni Recio @tonirecio tonirecio@techdencias.net@ Q&A
  74. 74. GRACIAS
  75. 75. http://www.freepik.com/free-vector/abstract-blue-background-with- triangles_710166.htm#term=glacial&page=1&position=0 http://www.freepik.com/free-vector/computers-and-school- elements_719102.htm#term=learning&page=1&position=37 http://www.freepik.com/free-vector/colorful-brain- icons_764996.htm#term=brain&page=1&position=1
  76. 76. http://www.freepik.com/free-vector/five-senses- icons_837465.htm#term=senses&page=1&position=0 http://www.freepik.com/free-vector/analog-camera- icon_791929.htm#term=camera&page=1&position=1 http://www.freepik.com/free-vector/photos-and- cameras_804428.htm#term=picture&page=1&position=0
  77. 77. http://www.freepik.com/free-vector/magnifying-glass-data- analysis_761448.htm#term=information&page=1&position=4 http://www.freepik.com/free-vector/educational-future- concept_776917.htm#term=future&page=1&position=3 http://www.freepik.com/free-vector/global-education- background_780891.htm#term=logic&page=1&position=0
  78. 78. http://www.freepik.com/free-vector/cartoon-scientist-with-chemical- elements_848470.htm#term=scientist&page=1&position=9 http://www.freepik.com/free-vector/colorful-information- buttons_807853.htm#term=information&page=1&position=5

×