1 / 14

Computer Vision

Computer Vision. Resources: OpenCV David Pycock D.Pycock@bham.ac.uk www.bham.ac.uk/pycockd. OpenCV. Windows program based on Intel IP Library More than 300 functions Features Multi-platform Provides a simple window manager with sliders mouse call backs etc

natashaa
Télécharger la présentation

Computer Vision

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Vision Resources: OpenCV David Pycock D.Pycock@bham.ac.uk www.bham.ac.uk/pycockd

  2. OpenCV • Windows program based on Intel IP Library • More than 300 functions • Features • Multi-platform • Provides a simple window manager with sliders mouse call backs etc • Uses Intel Integrated Performance Primitives to enhance performance • Tutorials & Documentation • Sample code • Download from • sourceforge.net/projects/opencvlibrary/ • Operates under • Windows 95/98/NT/2000/XP • POSIX Linux/BSD/OSX/Win2K/WinXP

  3. Image Input (HighGUI) • Still images from file • Using cvLoadImage() IplImage* cvLoadImage(const char* filename, int iscolor=1); Returns a pointer to an ipl image Filename: the name of the image file iscolor: >0 image is loaded as 3 channel colour 0 image is loaded as grey-level <0 No. of channels determined by file • File formats • Windows bitmaps: bmp, DIB • JPEG files: jpeg, jpg, jpe • Portable Network Graphics: png • Portable image format: pbm, pgm, ppm • Sun raster: sr, ras • Tiff Files: tiff, tif

  4. Load and Display an Image /* usage: prog <image_name> */ #include "cv.h“ /* OpenCV data types and prototypes */ #include "highgui.h“ /* Image read and display*/ int main( int argc, char** argv ) {IplImage* img; if(argc==2 && (img=cvLoadImage(argv[1], 1)) !=0) {cvNamedWindow("Image view", 1); cvShowImage("Image view", img); cvWaitKey(0); /*very important, contains event */ /*processing loop inside */ cvDestroyWindow("Image view"); cvReleaseImage(&img); return 0; } return -1; }

  5. Image Display (HighGUI) • Need to register image window and display it • int cvNamedWindow(const char* name, int flags);name: id name and text on image bannerint: 1, autosize to fit the image • void cvShowImage(const char* name, const CvArr* img);name: id name and text on image bannerimg: pointer to image to be displayed • CvCapture* cvCaptureFromFile(const char* fname);fname: video file name • CvCapture* cvCaptureFromCAM(int index);index: positive integer specifies video source

  6. Other Libraries:(CV) • Image Processing • Edges, filters, morphologic operators, pyramids, histograms, boundary tracing • Structural analysis • Contour processing, computational geometry • Motion Analysis and Object Tracking • Object tracking, optical flow, motion templates • Pattern Recognition • Camera calibration and 3D Reconstruction • Camera calibration, pose estimation, epipolar geometry

  7. Other Libraries:cxcore • Operations on arrays • Linear algebra, statistics, random number generator • Dynamic structures • Trees, graphs, sets, sequences • Drawing • Curves, text, point sets, contours

  8. Other Libraries:ML • Machine Learning • Bayes classifier • K-nearest neighbour classifier • Support Vector Machine • Decision Trees • Boosting • Random Forest • Expectation Maximisation • Neural Networks

  9. Other Libraries:CvCam/Cvaux • CvCam • Video Input / Output • Select and set up a camera • Render a video stream • Control the Video • Process video frames • Multiple cameras under Linux and Windows • Cvaux • Experimental functions

  10. Key tips • IplImage data Types • IPL_DEPTH_8U unsigned 8 bit • IPL_DEPTH_8S signed 8 bit • IPL_DEPTH_16U unsigned 16 bit • IPL_DEPTH_16S signed 16 bit • IPL_DEPTH_32S signed 32 bit • IPL_DEPTH_32F single precision floating point • IPL_DEPTH_ 64F double precision floating point • Channels: 1, 2, 3 or 4 sequence is: b0, g0, r0, b1, g1, r1 • Accessing image pixels • Coordinates are indexed from 0 • Origin is top left or bottom left • To access an element of an 8-bit 1-channel image,I (IplImage* img):I(x,y)~ ((uchar*)(img->imageData + img->widthStep*y)[x]

  11. To access an element of an 8-bit 3-channel image,I (IplImage* img):I(x,y)blue~ ((uchar*)(img->imageData + img->widthStep*y)[x*3]I(x,y)green~ ((uchar*)(img->imageData + img->widthStep*y)[x*3+1]I(x,y)red~ ((uchar*)(img->imageData + img->widthStep*y)[x*3+2] • To access an element of a 32-bit floating point 1-channel image, I (IplImage* img):I(x,y)~ ((float*)(img->imageData + img->widthStep*y)[x]

  12. In general to access an element of an N-channel image of type TI(x,y)c~ ((T*)(img->imageData + img->widthStep*y)[x*N+c] • More simply using the provided macroCV_IMAGE_ELEM(img, T, y, x*N+c) • Efficient way to increment brightness of point(100, 100) by 30CvPoint pt = {100, 100};uchar *tmp_ptr=&((uchar*)(img->ImageData + img->widthStep*pt.y))[x*3];tmp_ptr[0]+=30;tmp_ptr[1]+=30;tmp_ptr[2]+=30;

  13. Key Resources • A brief intro to OpenCV:www.cs.iit.edu/~agam/cs512/lect-notes/ opencv-intro/index.html • A more detailed guide (also describes DirectX/DirectShow):http://www.site.uottawa.ca/~laganier/tutorial/ opencv+directshow/cvision.htm • Wikipediahttp://en.wikipedia.org/wiki/OpenCV • BookLearning OpenCV: Computer Vision with the OpenCV Library (Paperback)Gary Bradski and Adrian KaehlerO'Reilly Media, Inc. (15 Jul 2008) ISBN 0596516134

  14. General Resources • The Computer Vision home page at Carnegie Mellon Universitywww.cs.cmu.edu/afs/cs/project/cil/ftp/html/vision.html • Includes an online publications page:www.cs.cmu.edu/afs/cs/project/cil/www/v-pubs.html • Hyper Media Image Processing Reference (HIPR) at The University of Edinburgh:homepages.inf.ed.ac.uk/rbf/HIPR2/ • Cvonline, a compendium of Computer Vision at Edinburgh University:homepages.inf.ed.ac.uk/rbf/CVonline/ • British Machine Vision Association (BMVA):www.bmva.ac.uk

More Related