You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用OpenCvSharp检测图像模糊存在误判,请求代码审核

图像模糊检测代码调试求助

我首次使用OpenCvSharp实现图像模糊检测功能,但部分实际模糊的图像被判定为清晰。烦请审核以下代码,确认我对OpenCvSharp的使用是否正确:

public static bool IsBlurry(string imagePath, double threshold = 100.0)
{
    // Load the image
    var image = Cv2.ImRead(imagePath, ImreadModes.Grayscale);
    
    // Compute the Laplacian of the image
    var laplacian = new Mat();
    Cv2.Laplacian(image, laplacian, MatType.CV_64F);

    // Compute the variance of Laplacian
    Cv2.MeanStdDev(laplacian, out _, out var stddev);

    var varianceValue = stddev.Val0 * stddev.Val0; // Variance = standard deviation squared

    // Check if the image is blurred
    return varianceValue < threshold;
}

参考图片:
Image1
Image2
Image3

感谢您的帮助。

内容的提问来源于stack exchange,提问作者Sandeep Reddy Pinniti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 06:27:20