Correctly enable OpenCL mode in tapi's hog example.
authorChuanbo Weng <chuanbo.weng@intel.com>
Mon, 20 Oct 2014 03:50:46 +0000 (11:50 +0800)
committerChuanbo Weng <chuanbo.weng@intel.com>
Mon, 20 Oct 2014 03:50:46 +0000 (11:50 +0800)
commit7452eef6e972cc787d858bca52913fd9d377c693
treed009ccc0ceec1d616a41d01ec2d02052a41fc4fc
parent55f490485bd58dc972de9e0333cdff005fce1251
Correctly enable OpenCL mode in tapi's hog example.

For current OpenCV-CL architecture, if the data buffer
allocated in UMat are cpu buffer(not ocl buffer) under
cpu mode, and then pass this UMat to an OpenCL kernel
as an argument, the OpenCL path will fail and fallback
to cpu mode. Take HOGDescriptor::oclSvmDetector as an example:
    ocl::setUseOpenCL(false);
    //data allocated in hog.oclSvmDetector will be cpu buffer
    hog.setSVMDetector(HOGDescriptor::getDaimlerPeopleDetector());
    ocl::setUseOpenCL(true);
    //We enabled OpenCL, but hog.oclSvmDetector are cpu buffer,
    //so it will fail in the function ocl_classify_hists
    //when reach to this line
    //idx = k.set(idx, ocl::KernelArg::PtrReadOnly(detector));
    hog.detectMultiScale(img, found, hit_threshold, win_stride,
            Size(0, 0), scale, gr_threshold);

Similar problems heppen on img_aux and img. So we should re-define
or re-set these UMat when do mode switch (CPU -> OpenCL) in order
to make their data be allocated by ocl and then OpenCL path will
succeed.

Signed-off-by: Chuanbo Weng <chuanbo.weng@intel.com>
samples/tapi/hog.cpp