Your SlideShare is downloading. ×
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
MobAppDev: Integration of Computer Vision into Android Applications with OpenCV
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

MobAppDev: Integration of Computer Vision into Android Applications with OpenCV

726

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
726
On Slideshare
0
From Embeds
0
Number of Embeds
39
Actions
Shares
0
Downloads
26
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Integration of Computer Vision into Android Applications with OpenCV Vladimir Kulyukin www.vkedco.blogspot.com
  • 2. Outline ● ● Basic Overview of Computer Vision  Pixel Manipulation  Morphological Operations  Line Detection with Hough Transform OpenCV on Android  Installation  Sample Applications  Training Object Classifiers
  • 3. Image & Pixel Manipulation
  • 4. Images & Pixels ● ● ● ● Images consist of pixels Image manipulation is impossible without manipulating pixels Images are matrices of numerical values In OpenCV, images are represented as cv::Mat data structures
  • 5. Grayscale & Color Images ● ● ● Images can be grayscale or color In grayscale images, a pixel is a single number ranging from 0 (black) to 255 (white) In color images, a pixel is an RGB number triplet <r, g, b>, where each component is a number in [0, 255]
  • 6. OpenCV Code Sample #include "stdafx.h" #include <opencv2/ core/ core.hpp> #include <opencv2/ highgui/ highgui.hpp> int main() { cv::M image = cv::imread("E:imagessample.jpg"); at cv::namedW indow("Sample I mage"); cv::imshow(“Sample", image); cv::waitKey(5000); return 1; }
  • 7. Morphological Operations
  • 8. Morphological Filtering ● ● Morphological filter is a shape element (aka structuring element) (e.g., a 3 x 3 matrix) that, when applied to an image, transforms it (gives the image a different look) The value of each pixel is computed as the result of placing the pixel in the middle of the shape element and applying a function to the values of the pixel and those of the pixel's neighbors covered by the shape element
  • 9. Erosion & Dilation ● ● ● Two most common morphological filters are erosion and dilation Erosion replaces the current pixel with the minimum pixel found in the shape element Dilation replaces the current pixel with the maximum pixel found in the shape element
  • 10. Erosion & Dilation ● ● ● Let us suppose that we apply erosion and dilation to a binary image (0 – black, 255 – white) We expect erosion to increase the amount of blackness in the image (since the minimum pixel value is chosen in each shape element) We expect dilation to increase the amount of whiteness in the image (since the maximum pixel value is chosen in each shape element)
  • 11. Erosion & Dilation Image Source: R. Laganiere. “OpenCV 2 Cookbook”, Ch. 05
  • 12. Erosion & Dilation cv::Mat img = cv::imread("E:kulyukinvisionbisons_blackwhite.jpeg"); cv::namedWindow("Original Image"); cv::imshow("Original Image", img); cv::Mat eroded_image; // By default, OpenCV uses a 3x3 square structuring element. // This default is defined by specifying cv::Mat() as the // third argument. cv::erode(img, eroded_image, cv::Mat()); cv::namedWindow("Eroded Image"); cv::imshow("Eroded Image", eroded_image); cv::Mat dilated_image; cv::dilate(img, dilated_image, cv::Mat()); cv::namedWindow("Dilated Image"); cv::imshow("Dilated Image", dilated_image); cv::waitKey();
  • 13. Erosion & Dilation Eroded Image: Number of black pixels has been increased
  • 14. Erosion & Dilation Dilated Image: Number of white pixels has been increased
  • 15. Corner Detection ● ● ● Erosion and dilation can be used to detect corners in images The image is dilated and eroded with two different shape elements The shape elements leave straight edges w/o changing them, but the edges at corner points are changed
  • 16. Corner Detection cv::Mat img = cv::imread("E:kulyukinnutrition_table.jpeg"); cv::Mat gray; cv::cvtColor(img, gray, CV_BGR2GRAY); // convert to grayscale MorphoFeatures morpho; // class that detects corners morpho.setThreshold(30); cv::Mat corners = morpho.getCorners(gray); // detect corners morpho.drawOnImage(corners, gray); // draw corners on image cv::namedWindow("Corners on Image"); // open a window cv::imshow("Corners on Image", gray); // display image in window cv::waitKey(); // wait for the user to press any key to close window
  • 17. Corner Detection Grayscale Image (left); Image with Detected Corners Drawn (right)
  • 18. Line Detection with Hough Transform
  • 19. Hough Transform ● ● ● Paul Hough invented the concept in 1959 and patented it in 1962 Richard Duda and Peter Hart used Hough's idea in image analysis and introduced it to the computer vision and image analysis as the Hough Transform It is used in image processing and computer vision
  • 20. Parameterized Representation of Lines
  • 21. Two Representations Side by Side Plane Representation Parameterized Representation
  • 22. Line Detection with Hough Transform // Apply Hough Transform std::vector<cv::Vec4i> findLines(cv::Mat& binary) { lines.clear(); cv::HoughLinesP(binary,lines,deltaRho,deltaTheta,minVote, minLength, maxGap); return lines; } // Draw the detected lines on an image void drawDetectedLines(cv::Mat &image, cv::Scalar color=cv::Scalar(255,255,255)) { // Draw the lines std::vector<cv::Vec4i>::const_iterator it2= lines.begin(); while (it2!=lines.end()) { cv::Point pt1((*it2)[0],(*it2)[1]); cv::Point pt2((*it2)[2],(*it2)[3]); cv::line( image, pt1, pt2, color); ++it2; } }
  • 23. Line Detection with Hough Transform Original Image Detected Lines
  • 24. Line Detection with Hough Transform Original Image Detected Lines
  • 25. Line Detection with Hough Transform Image with Detected Images (left); Lines detected with Hough Transform (right)
  • 26. OpenCV on Android
  • 27. OpenCV Installation ● ● ● Get the OpenCV4Android SDK. Go to the OpenCV download page on SourceForge and download the latest available version Unzip the contents and import the projects into Eclipse You can read this Tutorial on how to integrate OpenCV
  • 28. Demo Training Object Recognizers
  • 29. Training Object Detector in OpenCV ● ● ● Create a database of positive samples and a database of negative samples. Mark the desired object using objectmarker.exe Build a vector file createsamples.exe out of positive samples ● Run haartraining.exe to build the classifier. ● Run haarconv.exe to convert classifier to .xml file http://www.iem.pw.edu.pl/~domanskj/haarkit.rar using
  • 30. References ● ● ● http://en.wikipedia.org/wiki/OpenCV http://opencv.org/ R. Laganiere. OpenCV 2 Computer Vision Application Programming Cookbook.

×