Object Detection — OpenCV 2.4.6.1 documentation

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.6.1 documentation »
- OpenCV API Reference »
- ocl. OpenCL-accelerated Computer Vision »

# Object Detection

## ocl::OclCascadeClassifier

class `ocl::``OclCascadeClassifier` : public `CascadeClassifier`

Cascade classifier class used for object detection. Supports HAAR cascade classifier in the form of cross link

    class CV_EXPORTS OclCascadeClassifier : public CascadeClassifier
    {
    public:
          OclCascadeClassifier() {};
          ~OclCascadeClassifier() {};
           CvSeq *oclHaarDetectObjects(oclMat &gimg, CvMemStorage *storage,
                                      double scaleFactor,int minNeighbors,
                                      int flags, CvSize minSize = cvSize(0, 0),
                                      CvSize maxSize = cvSize(0, 0));
    };

## ocl::OclCascadeClassifier::oclHaarDetectObjects

Returns the detected objects by a list of rectangles

C++:`` CvSeq* `ocl::OclCascadeClassifier::``oclHaarDetectObjects`(oclMat& gimg, CvMemStorage* storage, double scaleFactor, int minNeighbors, int flags, CvSize minSize=cvSize(0, 0), CvSize maxSize=cvSize(0, 0))

  Parameters: | image – Matrix of type CV_8U containing an image where objects should be detected. imageobjectsBuff – Buffer to store detected objects (rectangles). If it is empty, it is allocated with the defaultsize. If not empty, the function searches not more than N objects, where N = sizeof(objectsBufers data)/sizeof(cv::Rect). scaleFactor – Parameter specifying how much the image size is reduced at each image scale. minNeighbors – Parameter specifying how many neighbors each candidate rectangle should have to retain it. minSize – Minimum possible object size. Objects smaller than that are ignored.

Detects objects of different sizes in the input image,only tested for face detection now. The function returns the number of detected objects.

## ocl::MatchTemplateBuf

struct `ocl::``MatchTemplateBuf`

Class providing memory buffers for `ocl::matchTemplate()` function, plus it allows to adjust some specific parameters.

    struct CV_EXPORTS MatchTemplateBuf
    {
        Size user_block_size;
        oclMat imagef, templf;
        std::vector<oclMat> images;
        std::vector<oclMat> image_sums;
        std::vector<oclMat> image_sqsums;
    };

You can use field user_block_size to set specific block size for `ocl::matchTemplate()` function. If you leave its default value Size(0,0) then automatic estimation of block size will be used (which is optimized for speed). By varying user_block_size you can reduce memory requirements at the cost of speed.

## ocl::matchTemplate

Computes a proximity map for a raster template and an image where the template is searched for.

C++:`` void `ocl::``matchTemplate`(const oclMat& image, const oclMat& templ, oclMat& result, int method)

C++:`` void `ocl::``matchTemplate`(const oclMat& image, const oclMat& templ, oclMat& result, int method, MatchTemplateBuf& buf)

  Parameters: | image – Source image. `CV_32F` and `CV_8U` depth images (1..4 channels) are supported for now. templ – Template image with the size and type the same as `image` . result – Map containing comparison results ( `CV_32FC1` ). If `image` is W x H and `templ` is w x h, then `result` must be W-w+1 x H-h+1. method – Specifies the way to compare the template with the image. buf – Optional buffer to avoid extra memory allocations and to adjust some specific parameters. See `ocl::MatchTemplateBuf`.

  The following methods are supported for the `CV_8U` depth images for now:

  - `CV_TM_SQDIFF`
  - `CV_TM_SQDIFF_NORMED`
  - `CV_TM_CCORR`
  - `CV_TM_CCORR_NORMED`
  - `CV_TM_CCOEFF`
  - `CV_TM_CCOEFF_NORMED`

  The following methods are supported for the `CV_32F` images for now:

  - `CV_TM_SQDIFF`
  - `CV_TM_CCORR`

See also

`matchTemplate()`

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 2.4.6.1 documentation »
- OpenCV API Reference »
- ocl. OpenCL-accelerated Computer Vision »