Josiah Yoder

Email: <yoder2 AT SPAMFREE purdue DOT edu>

I have used OpenCV in my own research area, which is multi-camera computer vision. I think one of the best features in OpenCV is the face detection algorithm and the associated classifier training application.

I created this account because I wish to help make the OpenCV documentation more friendly for first-time users.

My homepage at http://web.ics.purdue.edu/~yoder2/

Stuff to be added (Useful even with C++-style OpenCV2.3.1)

Documentation (long-term)

"See alsos" for my favorite functions

cvConvert: See also:

cvCopy: See also:

cvGEMM: Generalized Matrix Multiplication

cvMul: Elementwise multiplication

cvScale: Scales intensities

cvZero: See also:

Stuff to be Added (C-style)

"Hello World" in OpenCV

Create and show a blank image:

Accessing pixels in OpenCV

I use cvmGet and cvmSet when my image is compatible. Otherwise, I use cvGet2D or cvSet2D.

Try this code in the "Hello World" example above:

Notice how the CV_RGB puts the bytes in the reverse (BGR) order used by OpenCV.

Concerned about speed? Consider this quote:

OpenCV structures

OpenCV has several small, useful structures which appear often. Examples are the structures CvScalar, CvRectangle, and CvPoint. Whenever a function calls for one of these, you can declare it inline if you wish, by using the lower-case "pseudo-constructors:" cvScalar(x), cvRectangle(x,y,w,h), and cvPoint(x,y). For a colored pixel, you can use CV_RGB(r,g,b), which creates a CvScalar object with the red, blue, and green in the reverse (BGR) order used by default in OpenCV.

CvSeq's

CvSeq seems useful, but not sure how to use it with your own data? The source code for cvHaarDetectObjects has a nice example. To initialize, just use

To clean up, use

There is no cvReleaseSeq. To set the length of the sequence to zero, you can use cvClearSeq. But this does not free the memory. It seems valuable to quote the OpenCV source here:

When using cvPartitionFunction, you do not need to initialize the index sequence. If you do initialize it, it will be leaked inside of the storage. In other words, that memory will no longer be available for use until that CvStorage object is released.

Advice I learned the hard way: Only put structures onto a CvSeq which are "complete" in the sense that they don't contain pointers to other data. If you put on a local variable, its contents will mysteriously change. If you put on a "new" variable, it will be memory-leaked. This took me about 3 to 4 hours to figure out.


OpenCVWiki: JosiahYoder (last edited 2012-05-09 22:02:38 by JosiahYoder)