Multimedia Programming 02: Play with Images Departments of Digital Contents Sang Il Park.

Slides:



Advertisements
Similar presentations
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Advertisements

Processing Lecture. 1 What is processing?
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Introduction to OpenCV Dr. Chung-Hao Chen Haole Guo Sep 2011.
Gavin S Page OpenCV Tutorial Part I Using OpenCV with Microsoft Visual Studio.net November 2005.
Gavin S Page OpenCV Tutorial Part IV A Brief Guide to Memory Management (and other Miscellaneous Functions) 02 December 2005.
OpenCV Stacy O’Malley CS-590 Summer, What is OpenCV? Open source library of functions relating to computer vision. Cross-platform (Linux, OS X,
*Third party marks and brands are the property of their respective owners Getting Started with OpenCV Yue Gao CS 4758/6758 Robot Learning
Computer Vision 碩二 許富量 Introduction to Intel OpenCV Library.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
BoardMaker Ver 6 Creating Interactive Activities for the Classroom.
INDEX ∞ Image Processing ∞ OpenCV ∞ Download & Setup ∞ Make Project ∞ Show Result ∞ Q & A Setup OpenCV & Tutorial.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
L.
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Chapter 3 Working with Symbols and Interactivity.
Filtering (I) Dr. Chang Shu COMP 4900C Winter 2008.
OpenCV Open source C omputer V ision library By: Bahare Torkaman Fall 2010.
SDL Programming Introduction. Initialization 2  The first thing you must do is initialize SDL  int SDL_Init( SDL_INIT_EVERYTHING )  This will return.
July, 2007 GCB SAGE workshop SAGE Development. July, 2007 GCB SAGE workshop Architecture … Free Space manager provides central control between apps, UI.
Graphic images for computers Stored in files of binary data - Binary blobs Software has to know the binary format to decode the file and render an image.
Lecture 02: Intro to SDL Topics: Downloading / Installing SDL Linking (in general and for SDL) SDL basics References:
Chapter 1 Review Images Links Images II Pictures and Extensions.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
IE 411/511: Visual Programming for Industrial Applications
Introduction to Alice Alice is named in honor of Lewis Carroll’s Alice in Wonderland.
Detect Candle.  Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories  Choose "Show directories for: Include.
CSCE Chapter 5 (Links, Images, & Multimedia) CSCE General Applications Programming Benito Mendoza 1 By Benito Mendoza Department.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
C O M P U T E R G R A P H I C S Jie chen Computer graphic -- OpenGL Howto.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
Multimedia Programming 03: Point Processing Departments of Digital Contents Sang Il Park.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Multimedia Programming 02: Play with Images Departments of Digital Contents Sang Il Park.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
L. Akshay Masare Piyush Awasthi IMAGE PROCESSING AND OPENCV.
Lecture 3 OpenGL.
Faculty Webpage Design Minimum Requirements. Go to: then High Schoolhttp://gcsc.groupfusion.net/
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Multimedia Programming 13: Review and term project Departments of Digital Contents Sang Il Park.
Introduction of OpenCV Alireza Shirani Researcher of Medical Image and Signal Processing M. S Electrical Engineering yahoo. com Spring.
Learning With Computers I (Level Green) ©2012 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Getting Started with Fireworks A few tips: –Before you begin an assignment, be sure to create a folder on your drive for it. –If your canvas is checkered,
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
Project Two Adding Web Pages, Links, and Images Define and set a home page Add pages to a Web site Describe Dreamweaver's image accessibility features.
Getting to Know OpenCV 主講人:虞台文. Content Basic Structures Arrays, Matrices, and Images Matrix and Image Operators Drawing Things Drawing Text Data Persistence.
Multimedia Programming 04: 점, 선, 면
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Optical Flow walk through Aidean Sharghi Spring 14.
Multimedia Programming 10: Mouse, Draw and Morphing Departments of Digital Contents Sang Il Park.
1 Word Processing Intermediate Using Microsoft Office 2000.
Representation of image data
OpenCV Tutorial Part I Using OpenCV with Microsoft Visual Studio .net November 2005 Gavin S Page
Introduction to Computer CC111
Chapter 2 – Introduction to the Visual Studio .NET IDE
C Basics.
A Quick Introduction to the C Interface By David Johnston
Chapter 5 Working with Images
Variables and Arithmetic Operations
Computer Science I CSC 135.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Getting Started with Milestone 2
Windows.
Directions are in slide notes. You can view them in two ways
Presentation transcript:

Multimedia Programming 02: Play with Images Departments of Digital Contents Sang Il Park

Announcement Homepage is now open!

Outline OpenCV How to start Your first OpenCV code: HelloCV Basic Functions Pixel Draw Lines or whatever you want Conclusion

What is OpenCV? OpenCV –Stands for Open Source Computer Vision Library –Includes 500 functions implementing algorithms: Computer vision Image processing General Purpose numeric algorithms –Portable and efficient (C/C++) –Absolutely free!

Who did make this? Being developed at Intel since 1999 Available on Windows, Linux and MacOSX. Extensively used in many companies and research centers Home page:

OpenCV –Intended Applications Computer Human Interaction (HCI) Object Identification Segmentation and Recognition Face Recognition Gesture Recognition Motion Tracking Motion Understanding And so on.

Where you can find this

OpenCV structure CXCORE basic structures and algoritms, XML support, drawing functions CV Image processing and vision algorithms HighGUI GUI, Image and Video I/O We will mostly focus on these two in this presentation

HelloCV: Your First OpenCV Code Loading an image and showing it

Make a new project Start Visual Studio 6.0 or Visual Studio.Net Make a new project –Win32 Console Application Program Compile and run it! (Ctrl + F5)

Initial Setup Directories: –Includes: "C:\Program Files\OpenCV\cv\include" "C:\Program Files\OpenCV\cxcore\include" "C:\Program Files\OpenCV\otherlibs\highgui“ –Libraries: "C:\Program Files\OpenCV\lib“ Library files you need: –cv.lib cxcore.lib highgui.lib

Initial Setup Include Directories (tools  options): "C:\Program Files\OpenCV\cv\include" "C:\Program Files\OpenCV\cxcore\include" "C:\Program Files\OpenCV\otherlibs\highgui“

Initial Setup Library Directories: (tools  options) "C:\Program Files\OpenCV\lib“

Initial Setup Library files you need: –cv.lib cxcore.lib highgui.lib

Initial Set up Include Header files –#include #include #include

HelloCV Type this: #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("HelloCV"); cvShowImage("HelloCV", img); cvWaitKey(); cvDestroyWindow("HelloCV"); cvReleaseImage(&img); return 0; } hellocv.cpp

Error! Copy every dll files –from: C:\Program Files\OpenCV\bin –To: under your debug folder

HelloCV

#include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("HelloCV"); cvShowImage("HelloCV", img); cvWaitKey(); cvDestroyWindow("HelloCV"); cvReleaseImage(&img); return 0; } hellocv.cpp IplImage cvLoadImage cvReleaseImage cvNamedWindow cvShowImage cvDestroyWindow cvWaitKey

Image structure IplImage (Image Processing Library) typedef struct _IplImage { int nSize; /* size of iplImage struct */ int ID; /* image header version */ int nChannels; int alphaChannel; int depth; /* pixel depth in bits */ char colorModel[4]; char channelSeq[4]; int dataOrder; int origin; int align; /* 4- or 8-byte align */ int width; int height; struct _IplROI *roi; /* pointer to ROI if any */ struct _IplImage *maskROI; /*pointer to mask ROI if any */ void *imageId; /* use of the application */ struct _IplTileInfo *tileInfo; /* contains information on tiling*/ int imageSize; /* useful size in bytes */ char *imageData; /* pointer to aligned image */ int widthStep; /* size of aligned line in bytes */ int BorderMode[4]; /* the top, bottom, left,and right border mode */ int BorderConst[4]; /* constants for the top, bottom,left, and right border */ char *imageDataOrigin; /* ptr to full, nonaligned image */ } IplImage;

Image I/O IplImage* cvLoadImage(image_path, colorness_flag); loads image from file, converts to color or grayscle, if need, and returns it (or returns NULL). image format is determined by the file contents. #define CV_LOAD_IMAGE_COLOR 1 #define CV_LOAD_IMAGE_GRAYSCALE 0 #define CV_LOAD_IMAGE_UNCHANGED -1  DEFAULT cvSaveImage(image_path, image); saves image to file, image format is determined from extension. cvReleaseImage(image_path, image); releases memory BMP, JPEG, PNG, TIFF, PPM/PGM formats are supported. IplImage* img = cvLoadImage(“picture.jpeg”,-1); if( img ) cvSaveImage( “picture.bmp”, img );

Windows cvNamedWindow(window_name, fixed_size_flag); creates window accessed by its name. Window handles repaint, resize events. Its position is remembered in registry: cvNamedWindow(“ViewA”); cvMoveWindow(“ViewA”,300,100); cvDestroyWindow(“ViewA”); … cvShowImage(window_name, image); copies the image to window buffer, then repaints it when necessary. {8u|16s|32s|32f}{C1|3|4} are supported. only the whole window contents can be modified. Dynamic updates of parts of the window are done using operations on images, drawing functions etc. cvDestroyWindow(window_name); deletes the window with the given name

User Input int cvWaitKey( int delay=0 ) waits for a pressed key. After waiting for the given delay, it proceeds. Zero delay means waiting forever until user input. –Delay in milliseconds.  Good for animating something Example) swapping between two images

What else HighGUI can do? “Smart” windows Image I/O, rendering Processing keyboard and other events, timeouts Trackbars Mouse callbacks Video I/O

Pixel Accessing Image Coordinate System Color Value: CvScalar –A container for 1-,2-,3- or 4-tuples of numbers –typedef struct CvScalar { double val[4]; } CvScalar; Example) CvScalar s; s.val[0] = 200;(Blue) s.val[1] = 11;(Green) s.val[2] = 123;(Red) x y (0,0)(8,2)

Pixel Accessing CvScalar cvGet2D (image, y, x) Gets color value at (x,y). –Example)CvScalar s; s = cvGet2D(img, 30, 40); void cvSet2D (image, y, x, CvScalar) Sets color value at (x,y). –Example)CvScalar s = cvScalar(100,0,0); cvSet2D(img, 30, 40, s); OR cvSet2D(img, 30, 40, cvScalar(100,0,0)); OR cvSet2D(img, 30, 40, CV_RGB(0,0,100));

Create an empty canvas IplImage* cvCreateImage( CvSize size, int depth, int channels ); –Depth: color depth: IPL_DEPTH_8U –Channels: 1,2,3,4 (1=grey, 3=color) –Example) IplImage * img; img = cvCreateImage(cvSize(200,100), IPL_DEPTH_8U,3); cvSet(image, CvScalar) –Fill canvas with a color –Example) cvSet(img, CV_RGB(255,255,255));

So far what you’ve learned: IplImage cvLoadImage (file_name) cvCreateImage (size, depth, channels) cvSaveImage (file_name, image) cvReleaseImage (image) cvNamedWindow (window_name) cvShowImage (window_name, image) cvDestroyWindow (window_name) cvWaitKey (delay) cvGet2D (image, y, x) cvSet2D (image, y, x, cvScalar)

Put everything together! int _tmain(int argc, _TCHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("HelloCV"); cvShowImage("HelloCV", img); cvWaitKey(); int x,y; for(x=0; x<100; x++) for(y=0; y<100; y++) { CvScalar s = cvGet2D(img, y,x); s.val[0] +=50; s.val[1] +=50; s.val[2] +=50; cvSet2D(img,y,x,s); } cvShowImage("HelloCV", img); cvWaitKey(); cvDestroyWindow("HelloCV"); cvReleaseImage(&img); return 0; } HelloCV2.cpp

A Simple Function: Line Drawing Horizontal line drawing: –void DrawHLine (IplImage * img, int y, int st, int ed, CvScalar color) image

Do more! Design a function that draws a rectangle –void DrawRectangle (IplImage * img, int x, int y, int w, int h, CvScalar color) –Don’t forget to make sure a pixel is inside the image 0 width 0 height If done, try to draw 50 random boxes with random colors! (x,y) w h

For those who want more OpenCV Wiki-pages: For HighGUI: – For cxcore: – Supplied documentation: OpenCV/docs/index.htm, faq.htm A Korean Community:

Program Assignment #1 Long long times ago in Russian Empire –Sergei Mikhailovich Prokudin-Gorskii ( ) –A man who pursuing a colorful future in

Program Assignment #1 His invention A cameraHis camera

Program Assignment #1 His pictures with the current digital technology

Program Assignment #1 Recover the colorful world in 1907 by yourself! 1I3 align B G R

Program Assignment #1 4 Images can be found in the class homepage: – Make a team of two students Due date: 9/11 before the class –Submit a written report and the codes and a execution file Type the filename in the cmd window, then generate a color image! Grading Policy: –Making a color image: 60 –Automatic alignment: 40