background preloader

Introduction to programming with OpenCV

Introduction to programming with OpenCV

Cell Counting - MATLAB & Simulink Example This example shows how to use a combination of basic morphological operators and blob analysis to extract information from a video stream. In this case, the example counts the number of E. Coli bacteria in each video frame. Note that the cells are of varying brightness, which makes the task of segmentation more challenging. Introduction This example illustrates how to use the morphological and BlobAnalysis System objects to segment individual cells and count them. Initialization Use these next sections of code to initialize the required variables and objects. VideoSize = [432 528]; Create a System object™ to read video from avi file. filename = 'ecolicells.avi'; hvfr = vision.VideoFileReader(filename, ... Create two morphological dilation System objects which are used to remove uneven illumination and to emphasize the boundaries between the cells. hdilate1 = vision.MorphologicalDilate('NeighborhoodSource', 'Property', ... hautoth = vision.Autothresholder( ... hblob = vision.BlobAnalysis( ...

Install libfreenect Drivers on Ubuntu libfreenect is the end result of the famous Adafruit Kinect hacking bounty X-Prize winner. After it made its mark on the scene, the OpenKinect community was born and the rest is history. This guide will provide the resources necessary to install the OpenKinect libfreenect drivers for Ubuntu. The original installation guide can be found at OpenKinect's Getting Started Guide. We'll be performing the entire operation using a Terminal app. First up, upon up a Terminal. Installing Dependencies Type in the following to install the required dependencies and packages necessary to install libfreenect. sudo apt-get install git-core cmake freeglut3-dev pkg-config build-essential libxmu-dev libxi-dev libusb-1.0-0-dev This will take a bit of time depending on your internet connection and if you need to install all of these dependencies. Install libfreenect Create a directory in Home called Kinect. mkdir ~/Kinect cd ~/Kinect Use git to download the latest version of libfreenect sudo glview

algorithm - Image Segmentation using Mean Shift explained Getting started with Kinect on Ubuntu 12.04 – OpenNI, Nite , SimpleopenNI and Processing « ramsrigoutham The objective of this tutorial is - 1) To install OpenNI, Nite (drivers that help getting data from the kinect) in Ubuntu 12.04. 2) To set up Processing and SimpleOpenNI ( OpenNI and Nite wrapper for Processing ) using which you can get started with Kinect coding. What you need? Kinect with usb cable and a computer with Ubuntu installed. It is not recommended to run Ubuntu as a wubi installer from Windows when working with Kinect. 1) Installing OpenNI and NITE 1) I highly recommend installing 32 bit versions of all even if yours is a 64 bit system. Tip: Instead of navigating to different folders using cd command you can enable Open in terminal option when you right click in any folder. sudo apt-get install nautilus-open-terminal After installing type : killall nautilus && nautilus in terminal to activate the change immediately. Testing the installation: Connect the kinect and ensure that the green Led on it is blinking. . The output with my Kinect: 1)Download processing for Linux from here.

OpenCV 3 Image Thresholding and Segmentation Thresholding Thresholding is the simplest method of image segmentation. It is a non-linear operation that converts a gray-scale image into a binary image where the two levels are assigned to pixels that are below or above the specified threshold value. cv2.threshold(src, thresh, maxval, type[, dst]) This function applies fixed-level thresholding to a single-channel array. The function returns the computed threshold value and thresholded image. src - input array (single-channel, 8-bit or 32-bit floating point). Picture source: threshold dst - output array of the same size and type as src. Thresholding - code and output The code looks like this: Output: Original images are available : gradient.png and circle.png Adaptive Thresholding Using a global threshold value may not be good choicewhere image has different lighting conditions in different areas. cv.AdaptiveThreshold(src, dst, maxValue, adaptive_method=CV_ADAPTIVE_THRESH_MEAN_C, thresholdType=CV_THRESH_BINARY, blockSize=3, param1=5) where:

Projections of Reality Training Haar Cascades | memememe For better or worse, most cell phones and digital cameras today can detect human faces, and, as seen in our previous post, it doesn’t take too much effort to get simple face detection code running on an Android phone (or any other platform), using OpenCV. This is all thanks to the Viola-Jones algorithm for face detection, using Haar-based cascade classifiers. There is lots of information about this online, but a very nice explanation can be found on the OpenCV website. (image by Greg Borenstein, shared under a CC BY-NC-SA 2.0 license) It’s basically a machine learning algorithm that uses a bunch of images of faces and non-faces to train a classifier that can later be used to detect faces in realtime. The algorithm implemented in OpenCV can also be used to detect other things, as long as you have the right classifiers. Actually, that last link is for more than just iPhones. Similar to what we want, but since we have a very specific phone to detect, we decided to train our own classifier. 1.

Coding Robin Open this page, allow it to access your webcam and see your face getting recognized by your browser using JavaScript and OpenCV, an "open source computer vision library". That's pretty cool! But recognizing faces in images is not something terribly new and exciting. Wouldn't it be great if we could tell OpenCV to recognize something of our choice, something that is not a face? Let's say... a banana? That is totally possible! Here's the good news: we can generate our own cascade classifier for Haar features. But now for the best of news: keep on reading! The following instructions are heavily based on Naotoshi Seo's immensely helpful notes on OpenCV haartraining and make use of his scripts and resources he released under the MIT licencse. Let's get started The first thing you need to do is clone the repository on GitHub I made for this post. git clone You'll also need OpenCV on your system. Samples How many images do we need?

Tutorial: OpenCV haartraining (Rapid Object Detection With A Cascade of Boosted Classifiers Based on Haar-like Features) - Naotoshi Seo Tutorial: OpenCV haartraining (Rapid Object Detection With A Cascade of Boosted Classifiers Based on Haar-like Features) Objective The OpenCV library provides us a greatly interesting demonstration for a face detection. Furthermore, it provides us programs (or functions) that they used to train classifiers for their face detection system, called HaarTraining, so that we can create our own object classifiers using these functions. It is interesting. However, I could not follow how OpenCV developers performed the haartraining for their face detection system exactly because they did not provide us several information such as what images and parameters they used for training. My working environment is Visual Studio + cygwin on Windows XP, or on Linux. FYI: I recommend you to work haartrainig with something different concurrently because you have to wait so many days during training (it would possibly take one week). A picture from the OpenCV website History Data Prepartion Positive (Face) Images

Image Segmentation pff's homepage Below is a C++ implementation of the image segmentation algorithm described in the paper: Efficient Graph-Based Image Segmentation Pedro F. Felzenszwalb and Daniel P. The source code is available as a tgz file segment.tgz, or zip (updated on 3/21/07). Example segmentation results: Segmentation parameters: sigma = 0.5, K = 500, min = 50. Segmentation parameters: sigma = 0.5, K = 1000, min = 100. Computer Vision Software » Blog Archive » FAQ: OpenCV Haartraining Hi All, before posting your question, please look at this FAQ carefully! Also you can read OpenCV haartraining article. If you are sure, there is no answer to your question, feel free to post comment. Also please, put comments about improvement of this post. Positive images Why positive images are named so? Because a positive image contains the target object which you want machine to detect. What’s vec file in OpenCV haartraining? During haartraining positive samples should have the same width and height as you define in command “-w -h size”. Is it possible to merge vec files? Yes, use Google, there are free tools, written by OpenCV’s community. I have positive images, how create vec file of positive samples? There is tool in C:\Program Files\OpenCV\apps\HaarTraining\src createsamples.cpp. createsamples -info positive_description.txt -vec samples.vec -w 20 -h 20 What’s positive description file? The matter is that, on each positive image, there can be several objects. or Negative images No.

Color Detection & Object Tracking Object detection and segmentation is the most important and challenging fundamental task of computer vision. It is a critical part in many applications such as image search, scene understanding, etc. However it is still an open problem due to the variety and complexity of object classes and backgrounds.The easiest way to detect and segment an object from an image is the color based methods . The object and the background should have a significant color difference in order to successfully segment objects using color based methods. Simple Example of Detecting a Red Object In this example, I am going to process a video with a red color object and create a binary video by thresholding the red color. You can download this OpenCV visual c++ project from here. Explanation OpenCV usually captures images and videos in 8-bit, unsigned integer, BGR format. Usually, one can think that BGR color space is more suitable for color based segmentation. Arguments - Simple Example of Tracking Red objects