opencv 图像清晰度判断方法
if (matRaw.empty()) return; matRes = matRaw.clone(); cv::Mat mgray; cv::cvtColor(matRes, mgray, cv::COLOR_BGR2GRAY); QDateTime dtcur = QDateTime::currentDateTime(); cv::Mat mlap; cv::Laplacian(mgray, mlap, CV_16U); // Laplacian梯度方法 // cv::Sobel(mgray, mlap, CV_16U, 1, 1);//Tenengrad梯度方法 qDebug() << "Laplacian cost ms:" << dtcur.msecsTo(QDateTime::currentDateTime()); double meanvalue = cv::mean(mlap)[0]; qDebug() << "meanvalue:" << meanvalue; QString strres = QString("score:%1").arg(meanvalue); cv::putText(matRes, strres.toStdString(), cv::Point(100, 100), CV_FONT_HERSHEY_SIMPLEX, 3, cv::Scalar(0, 0, 255), 3); displayMat(matRes, ui->labelPicResult);