1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2018-10-15 20:15:42 +00:00
48 changed files with 2987 additions and 2509 deletions
+5 -5
View File
@@ -502,7 +502,7 @@ bool FeatureEvaluator::setImage( InputArray _image, const std::vector<float>& _s
copyVectorToUMat(*scaleData, uscaleData);
}
if (_image.isUMat() && localSize.area() > 0)
if (_image.isUMat() && !localSize.empty())
{
usbuf.create(sbufSize.height*nchannels, sbufSize.width, CV_32S);
urbuf.create(sz0, CV_8U);
@@ -1072,7 +1072,7 @@ bool CascadeClassifierImpl::ocl_detectMultiScaleNoGrouping( const std::vector<fl
std::vector<UMat> bufs;
featureEvaluator->getUMats(bufs);
Size localsz = featureEvaluator->getLocalSize();
if( localsz.area() == 0 )
if( localsz.empty() )
return false;
Size lbufSize = featureEvaluator->getLocalBufSize();
size_t localsize[] = { (size_t)localsz.width, (size_t)localsz.height };
@@ -1108,7 +1108,7 @@ bool CascadeClassifierImpl::ocl_detectMultiScaleNoGrouping( const std::vector<fl
if( haarKernel.empty() )
{
String opts;
if (lbufSize.area())
if ( !lbufSize.empty() )
opts = format("-D LOCAL_SIZE_X=%d -D LOCAL_SIZE_Y=%d -D SUM_BUF_SIZE=%d -D SUM_BUF_STEP=%d -D NODE_COUNT=%d -D SPLIT_STAGE=%d -D N_STAGES=%d -D MAX_FACES=%d -D HAAR",
localsz.width, localsz.height, lbufSize.area(), lbufSize.width, data.maxNodesPerTree, splitstage_ocl, nstages, MAX_FACES);
else
@@ -1148,7 +1148,7 @@ bool CascadeClassifierImpl::ocl_detectMultiScaleNoGrouping( const std::vector<fl
if( lbpKernel.empty() )
{
String opts;
if (lbufSize.area())
if ( !lbufSize.empty() )
opts = format("-D LOCAL_SIZE_X=%d -D LOCAL_SIZE_Y=%d -D SUM_BUF_SIZE=%d -D SUM_BUF_STEP=%d -D SPLIT_STAGE=%d -D N_STAGES=%d -D MAX_FACES=%d -D LBP",
localsz.width, localsz.height, lbufSize.area(), lbufSize.width, splitstage_ocl, nstages, MAX_FACES);
else
@@ -1304,7 +1304,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
#ifdef HAVE_OPENCL
bool use_ocl = tryOpenCL && ocl::isOpenCLActivated() &&
OCL_FORCE_CHECK(_image.isUMat()) &&
featureEvaluator->getLocalSize().area() > 0 &&
!featureEvaluator->getLocalSize().empty() &&
(data.minNodesPerTree == data.maxNodesPerTree) &&
!isOldFormatCascade() &&
maskGenerator.empty() &&
@@ -510,7 +510,7 @@ void DetectionBasedTracker::process(const Mat& imageGray)
CV_Assert(n > 0);
Rect r = trackedObjects[i].lastPositions[n-1];
if(r.area() == 0) {
if(r.empty()) {
LOGE("DetectionBasedTracker::process: ERROR: ATTENTION: strange algorithm's behavior: trackedObjects[i].rect() is empty");
continue;
}
@@ -550,7 +550,7 @@ void cv::DetectionBasedTracker::getObjects(std::vector<cv::Rect>& result) const
for(size_t i=0; i < trackedObjects.size(); i++) {
Rect r=calcTrackedObjectPositionToShow((int)i);
if (r.area()==0) {
if (r.empty()) {
continue;
}
result.push_back(r);
@@ -564,7 +564,7 @@ void cv::DetectionBasedTracker::getObjects(std::vector<Object>& result) const
for(size_t i=0; i < trackedObjects.size(); i++) {
Rect r=calcTrackedObjectPositionToShow((int)i);
if (r.area()==0) {
if (r.empty()) {
continue;
}
result.push_back(Object(r, trackedObjects[i].id));
+2 -2
View File
@@ -1427,7 +1427,7 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
+ equRect.x + equRect.width;
}
if( scanROI.area() > 0 )
if( !scanROI.empty() )
{
//adjust start_height and stop_height
startY = cvRound(scanROI.y / ystep);
@@ -1442,7 +1442,7 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
ystep, sum->step, (const int**)p,
(const int**)pq, allCandidates, &mtx ));
if( findBiggestObject && !allCandidates.empty() && scanROI.area() == 0 )
if( findBiggestObject && !allCandidates.empty() && scanROI.empty() )
{
rectList.resize(allCandidates.size());
std::copy(allCandidates.begin(), allCandidates.end(), rectList.begin());
+16 -12
View File
@@ -332,7 +332,7 @@ bool QRDetect::localization()
const int width = cvRound(bin_barcode.size().width / coeff_expansion);
const int height = cvRound(bin_barcode.size().height / coeff_expansion);
Size new_size(width, height);
Mat intermediate = Mat::zeros(new_size, CV_8UC1);
Mat intermediate;
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR);
bin_barcode = intermediate.clone();
for (size_t i = 0; i < localization_points.size(); i++)
@@ -833,26 +833,29 @@ void QRDecode::init(const Mat &src, const vector<Point2f> &points)
bool QRDecode::updatePerspective()
{
const Point2f centerPt = QRDetect::intersectionLines(original_points[0], original_points[2],
original_points[1], original_points[3]);
if (cvIsNaN(centerPt.x) || cvIsNaN(centerPt.y))
return false;
const Size temporary_size(cvRound(test_perspective_size), cvRound(test_perspective_size));
vector<Point2f> perspective_points;
perspective_points.push_back(Point2f(0.f, 0.f));
perspective_points.push_back(Point2f(test_perspective_size, 0.f));
perspective_points.push_back(Point2f(static_cast<float>(test_perspective_size * 0.5),
static_cast<float>(test_perspective_size * 0.5)));
original_points.insert(original_points.begin() + 2,
QRDetect::intersectionLines(
original_points[0], original_points[2],
original_points[1], original_points[3]));
perspective_points.push_back(Point2f(test_perspective_size, test_perspective_size));
perspective_points.push_back(Point2f(0.f, test_perspective_size));
Mat H = findHomography(original_points, perspective_points);
Mat bin_original = Mat::zeros(original.size(), CV_8UC1);
perspective_points.push_back(Point2f(test_perspective_size * 0.5f, test_perspective_size * 0.5f));
vector<Point2f> pts = original_points;
pts.push_back(centerPt);
Mat H = findHomography(pts, perspective_points);
Mat bin_original;
adaptiveThreshold(original, bin_original, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 83, 2);
Mat temp_intermediate = Mat::zeros(temporary_size, CV_8UC1);
Mat temp_intermediate;
warpPerspective(bin_original, temp_intermediate, H, temporary_size, INTER_NEAREST);
no_border_intermediate = temp_intermediate(Range(1, temp_intermediate.rows), Range(1, temp_intermediate.cols));
@@ -1054,6 +1057,7 @@ CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &deco
vector<Point2f> src_points;
points.copyTo(src_points);
CV_Assert(src_points.size() == 4);
CV_CheckGT(contourArea(src_points), 0.0, "Invalid QR code source points");
QRDecode qrdec;
qrdec.init(inarr, src_points);
@@ -1061,7 +1065,7 @@ CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &deco
decoded_info = qrdec.getDecodeInformation();
if (straight_qrcode.needed())
if (exit_flag && straight_qrcode.needed())
{
qrdec.getStraightBarcode().convertTo(straight_qrcode,
straight_qrcode.fixedType() ?