create objects mat if empty
This commit is contained in:
parent
d985861462
commit
2e0161c6c5
@ -519,6 +519,8 @@ public:
|
|||||||
|
|
||||||
GpuMat collected;
|
GpuMat collected;
|
||||||
|
|
||||||
|
cv::gpu::GpuMat genRoiTmp;
|
||||||
|
|
||||||
std::vector<device::icf::Octave> voctaves;
|
std::vector<device::icf::Octave> voctaves;
|
||||||
|
|
||||||
DeviceInfo info;
|
DeviceInfo info;
|
||||||
@ -546,29 +548,33 @@ bool cv::gpu::SCascade::load(const FileNode& fn)
|
|||||||
return fields != 0;
|
return fields != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::gpu::SCascade::detect(InputArray image, InputArray _rois, OutputArray _objects, Stream& s) const
|
void cv::gpu::SCascade::detect(InputArray _image, InputArray _rois, OutputArray _objects, Stream& s) const
|
||||||
{
|
{
|
||||||
CV_Assert(fields);
|
CV_Assert(fields);
|
||||||
const GpuMat colored = image.getGpuMat();
|
|
||||||
|
|
||||||
// only color images are supperted
|
// only color images and precomputed integrals are supported
|
||||||
CV_Assert(colored.type() == CV_8UC3 || colored.type() == CV_32SC1);
|
int type = _image.type();
|
||||||
|
CV_Assert(type == CV_8UC3 || type == CV_32SC1 || (!_rois.empty()));
|
||||||
|
|
||||||
|
const GpuMat image = _image.getGpuMat();
|
||||||
|
|
||||||
|
if (_objects.empty()) _objects.create(1, 4096 * sizeof(Detection), CV_8UC1);
|
||||||
|
|
||||||
GpuMat rois = _rois.getGpuMat(), objects = _objects.getGpuMat();
|
GpuMat rois = _rois.getGpuMat(), objects = _objects.getGpuMat();
|
||||||
Fields& flds = *fields;
|
|
||||||
|
|
||||||
if (colored.type() == CV_8UC3)
|
Fields& flds = *fields;
|
||||||
|
if (type == CV_8UC3)
|
||||||
{
|
{
|
||||||
if (!flds.update(colored.rows, colored.cols, flds.shrinkage) || flds.check(minScale, maxScale, scales))
|
if (!flds.update(image.rows, image.cols, flds.shrinkage) || flds.check(minScale, maxScale, scales))
|
||||||
flds.createLevels(colored.rows, colored.cols);
|
flds.createLevels(image.rows, image.cols);
|
||||||
flds.preprocess(colored, s);
|
flds.preprocess(image, s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (s)
|
if (s)
|
||||||
s.enqueueCopy(colored, flds.hogluv);
|
s.enqueueCopy(image, flds.hogluv);
|
||||||
else
|
else
|
||||||
colored.copyTo(flds.hogluv);
|
image.copyTo(flds.hogluv);
|
||||||
}
|
}
|
||||||
|
|
||||||
flds.detect(rois, objects, s);
|
flds.detect(rois, objects, s);
|
||||||
@ -589,8 +595,8 @@ void cv::gpu::SCascade::genRoi(InputArray _roi, OutputArray _mask, Stream& strea
|
|||||||
const GpuMat roi = _roi.getGpuMat();
|
const GpuMat roi = _roi.getGpuMat();
|
||||||
_mask.create( roi.cols / shr, roi.rows / shr, roi.type());
|
_mask.create( roi.cols / shr, roi.rows / shr, roi.type());
|
||||||
GpuMat mask = _mask.getGpuMat();
|
GpuMat mask = _mask.getGpuMat();
|
||||||
cv::gpu::GpuMat tmp;
|
|
||||||
|
|
||||||
|
GpuMat& tmp = (*fields).genRoiTmp;
|
||||||
cv::gpu::resize(roi, tmp, cv::Size(), 1.f / shr, 1.f / shr, CV_INTER_AREA, stream);
|
cv::gpu::resize(roi, tmp, cv::Size(), 1.f / shr, 1.f / shr, CV_INTER_AREA, stream);
|
||||||
cv::gpu::transpose(tmp, mask, stream);
|
cv::gpu::transpose(tmp, mask, stream);
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ GPU_TEST_P(SCascadeTestAll, detect,
|
|||||||
+ "../cv/cascadeandhog/bahnhof/image_00000000_0.png");
|
+ "../cv/cascadeandhog/bahnhof/image_00000000_0.png");
|
||||||
ASSERT_FALSE(coloredCpu.empty());
|
ASSERT_FALSE(coloredCpu.empty());
|
||||||
|
|
||||||
GpuMat colored(coloredCpu), objectBoxes(1, 100000, CV_8UC1), rois(colored.size(), CV_8UC1);
|
GpuMat colored(coloredCpu), objectBoxes, rois(colored.size(), CV_8UC1);
|
||||||
rois.setTo(0);
|
rois.setTo(0);
|
||||||
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
|
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
|
||||||
sub.setTo(cv::Scalar::all(1));
|
sub.setTo(cv::Scalar::all(1));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user