Gavin S Page OpenCV Tutorial Part IV A Brief Guide to Memory Management (and other Miscellaneous Functions) 02 December 2005.

Slides:



Advertisements
Similar presentations
Tutorial on Matlab and OpenCV Rui Ma TA of CMPT 414 May 14, 2013 Office hours: Fridays 11:00-12:00, CSIL TA Office 1 (ASB 9838)
Advertisements

Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Introduction to Programming Lecture 39. Copy Constructor.
Unions The storage referenced by a union variable can hold data of different types subject to the restriction that at any one time, the storage holds data.
Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
Exception Handling The purpose of exception handling is to permit the program to catch and handle errors rather than letting the error occur and suffer.
Memory Allocation. Memory A memory or store is required in a computer to store programs (or information or data). Data used by the variables in a program.
Histograms and Matching 主講人:虞台文. Content Overview Basic Histogram Structure Accessing Histograms Basic Manipulations with Histograms Color Spaces Histogram.
Gavin S Page OpenCV Tutorial Part II Loading Images and Using Histograms 29 November 2005.
OpenCV- An overview Intel® OPEN SOURCE COMPUTER VISION LIBRARY
Gavin S Page OpenCV Tutorial Part I Using OpenCV with Microsoft Visual Studio.net November 2005.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
Main Index Contents 11 Main Index Contents Pointer Illustration Pointer Illustration Vertical / Horizontal View. Vertical / Horizontal View. Data Addresses.
1 11/8/06CS150 Introduction to Computer Science 1 Arrays Chapter 8 page 477 November 13, 2006.
Gavin S Page OpenCV Tutorial Part 3 Image Correlation.
* The basic components of a web site are: * Content – information displayed or accepted from users * Static – content that doesn’t change for different.
Review of C++ Programming Part II Sheng-Fang Huang.
L.
Input and Output in Console Mode UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) ADNAN BABAR MT14028 CR
Lecture 10 – Image Processing with OpenCV JJCAO
Filtering (I) Dr. Chang Shu COMP 4900C Winter 2008.
OpenCV Open source C omputer V ision library By: Bahare Torkaman Fall 2010.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 10. Pointers & Dynamic Data Structures.
XP 1 Tutorial 5 Using Frames in a Web Site. XP 2 Tutorial Objectives  Describe the uses of frames in a Web site  Lay out frames within a browser window.
XP Using Frames in a Web Site Ali Alfayly. XP Tutorial Objectives Create frames for a Web site Control the appearance and placement of frames Control.
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
1 Further C  Multiple source code file projects  Structs  The preprocessor  Pointers.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Detect Candle.  Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories  Choose "Show directories for: Include.
Multimedia Programming 02: Play with Images Departments of Digital Contents Sang Il Park.
Facial Recognition Alex Newcomb, Tom Stefanyk. Group Members Alex Newcomb In charge of web server, image compression and facial recognition database The.
L. Akshay Masare Piyush Awasthi IMAGE PROCESSING AND OPENCV.
Review C Language Features –control flow –C operators –program structure –data types –I/O and files Problem Solving Abilities.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
Stack and Heap Memory Stack resident variables include:
Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility,
1 Programs Composed of Several Functions Syntax Templates Legal C++ Identifiers Assigning Values to Variables Declaring Named Constants String Concatenation.
Introduction of OpenCV Alireza Shirani Researcher of Medical Image and Signal Processing M. S Electrical Engineering yahoo. com Spring.
VideoForge An image processing system. Contents Current state of the art IntroductionTiers Base Base Core Core Modules Modules User interface Interactive.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
Chapter 7 Pointers: Java does not have pointers. Used for dynamic memory allocation.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Defining a 2d Array A 2d array implements a MATRIX. Example: #define NUMROWS 5 #define NUMCOLS 10 int arr[NUMROWS][NUMCOLS];
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Chapter 3 – Variables and Arithmetic Operations. Variable Rules u Must declare all variable names –List name and type u Keep length to 31 characters –Older.
Object-Oriented Programming (Java), Unit 28 Kirk Scott 1.
Homework due Test the random number generator Create a 1D array of n ints Fill the array with random numbers between 0 and 100 Compute and report the average.
Getting to Know OpenCV 主講人:虞台文. Content Basic Structures Arrays, Matrices, and Images Matrix and Image Operators Drawing Things Drawing Text Data Persistence.
Lecture 01c: C++ review Topics: static arrays array / pointer connection dynamic arrays (and pointers) 2D arrays.
HTML Frames. Advantages to Using Frames n flexibility in design n information in different Web pages n remove redundancy. n site easier to manage. n update.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
Two dimensional arrays A two dimensional m x n array A is a collection of m. n elements such that each element is specified by a pair of integers (such.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
LINKED LISTS.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part R2. Elementary Data Structures.
Stack and Heap Memory Stack resident variables include:
OpenCV Tutorial Part I Using OpenCV with Microsoft Visual Studio .net November 2005 Gavin S Page
Other Kinds of Arrays Chapter 11
A Quick Introduction to the C Interface By David Johnston
CSC 253 Lecture 8.
CSC 253 Lecture 8.
Project 1 Sequence CS 211 – Fall 2017.
Presentation transcript:

Gavin S Page OpenCV Tutorial Part IV A Brief Guide to Memory Management (and other Miscellaneous Functions) 02 December 2005

Gavin S Page 2 Introduction Video, 30 frames per second Each frame is an image Images are arrays of pixels A 640x480 image is 307,200 pixels These must be represented in memory How much memory does your machine have? Why is Managing OpenCV Objects Important? IplImage: Structure from Intel Image Processing Library In addition to representing the image data IplImage holds utilizes a subset of IPL data useful in IP/CV: nSize : Size of Image nChannels : Number of Image Channels (1-4) width, height ROI : Region of Interest (used in Tutorial II) and others (see documentation)… How Does OpenCV Represent Images? CvArr* is a function parameter for several OpenCV functions which accept arrays of more than one type. These are often IplImage*, CvMat*, or CvSeq*. A Top-Level OpenCV Type

Gavin S Page 3 Handling IplImage cvCreateImage( CvSize size, int depth, int channels ); header = cvCreateImageHeader(size,depth,channels); cvCreateData(header); cvCloneImage( const IplImage* image ); cvLoadImage( const char* filename, int iscolor=1 ); Creating an IplImage The first two functions are useful for creating a blank image of the specified parameters. A possible use is in functions that require a pointer to a result. The clone function performs an exact copy of the IplImage* parameter. The load function loads an image from a file. cvReleaseImage( IplImage** image ); cvReleaseData( *image ); cvReleaseImageHeader( image ); Destroying an IplImage cvReleaseImage will work for the 3 single step creation functions The cvReleaseData/cvReleaseImageHeader combination is used when there is separate data and header information An image header is initialized using cvInitImageHeader. When allocating IplImage in a loop be sure to deallocate in the loop as well

Gavin S Page 4 Utilizing IplImage cvSetImageROI( IplImage* image, CvRect rect ); cvResetImageROI( IplImage* image ); cvGetImageROI( const IplImage* image ); Setting the Region of Interest (ROI) Setting the ROI of the image allows the user to select a rectangular region of the image to work with. This is useful after localizing objects for extraction and further processing. While the region is set the rest of the image will be ignored. Meaning any operation directed on the image will act on only the region (including cvShowImage). The IplImage structure makes it possible to target specific regions of an object for processing. This reduces overhead caused by working on the whole image. The selection can occur at both the channel and the region. cvSetImageCOI( IplImage* image, int coi ); cvGetImageCOI( const IplImage* image ); Setting the Channel of Interest (COI) Setting the channel of the image allows the user to work with a particular layer of the image. i.e. The ‘R’ layer of an RGB image or the ‘V’ layer in the HSV format. NOTE: Not all OpenCV functions support this. The CvRect function is used to specify the region in cvSetImageROI. cvRect( int x, int y, int width, int height );

Gavin S Page 5 Other Static Array Types cvCreateMat( int rows, int cols, int type ); mat = cvCreateMatHeader( rows, cols, type ); cvCreateData( mat ); cvCloneMat( const CvMat* mat ); cvReleaseMat( CvMat** mat ); CvMat OpenCV uses the CvMat* as its general purpose matrix structure. It is managed in an equivalent style to IplImage* OpenCV also has built in functions for mult-dimensional arrays (CvMatND) and sparse arrays (CvSparseMat). Specifying the type of a CvMat is done using the syntax CV_ (S|U|F)C i.e. CV_8UC1 for an 8-bit single channel unsigned

Gavin S Page 6 Getting Matrix Information From an IplImage In order for a matrix to be useful it must be populated with data. OpenCV makes it possible to fill a matrix with data from an IplImage. CvRect rect = cvRect(0, 0, 500, 600 ); CvMat* mt = cvCreateMat(500,600, CV_8UC1); CvMat* sRect = cvGetSubRect(grayImage,mt,rect); Extracting Matrix Region The actual parameters of the cvGetSubRect function are ( const CvArr* arr, CvMat* submat, CvRect rect ). This snippet illustrates how to copy matrix header information from the IplImage. The function does make use of ROI so this will be useful in specifying a target region.

Gavin S Page 7 Dynamic Arrays cvCreateSeq( int seq_flags, int header_size, int elem_size, CvMemStorage* storage ); CvSeq OpenCV uses the CvSeq* to as its own representation for growable 1-d arrays. It is similar to IplImage* with regard to the fact that it is a structure with multiple fields which are representative of the data content. This includes a pointer to CvMemStorage which actually holds the sequence. cvCreateMemStorage( int block_size=0 ); cvClearMemStorage( CvMemStorage* storage ) CvMemStorage CvMemStorage is a low-level structure used to store dynamic data objects. The sequence is released by clearing the associated CvMemStorage structure.

Gavin S Page 8 Final Message As with any C++ program it is important to destroy all memory that has been allocated.