Opencv4nodejs: Detect blurry images with Laplacian Variance

Created on 3 Nov 2018  路  3Comments  路  Source: justadudewhohacks/opencv4nodejs

Hello !

I'm trying to adapt that : cv2.Laplacian(image, cv2.CV_64F).var() from https://www.pyimagesearch.com/2015/09/07/blur-detection-with-opencv/

For yet i'm in : _frame.laplacian(cv.CV_64F), but I don't find variance function to Mat structure.
=> Is there one tip to get that calculation ?

Thanks !

Most helpful comment

Thank you ! Yes it was a part of the answer @justadudewhohacks :)

Here is how the g33k of my team done that :

# Convert to gray
_imgGray = _img.bgrToGray()

# Detect blurry level
_laplacian = _imgGray.laplacian(cv.CV_64F)

# Get the standard deviation
_meanStdDev = _laplacian.meanStdDev()
_stdDevArray = _meanStdDev.stddev.getDataAsArray()
_stdDeviation = _stddevarray[0]

# Get the variation
_variation = Math.pow(_stdDeviation, 2)

And as expected, the threesold of 100 is pertinent

All 3 comments

Hmm maybe this is what you are looking for? http://answers.opencv.org/question/53985/is-there-a-built-in-function-to-calculate-the-variance-of-a-cvmat/

Bindings for Mat.meanStdDev are implemented.

Thank you ! Yes it was a part of the answer @justadudewhohacks :)

Here is how the g33k of my team done that :

# Convert to gray
_imgGray = _img.bgrToGray()

# Detect blurry level
_laplacian = _imgGray.laplacian(cv.CV_64F)

# Get the standard deviation
_meanStdDev = _laplacian.meanStdDev()
_stdDevArray = _meanStdDev.stddev.getDataAsArray()
_stdDeviation = _stddevarray[0]

# Get the variation
_variation = Math.pow(_stdDeviation, 2)

And as expected, the threesold of 100 is pertinent

@G33kLabs - Thanks for sharing the code!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djipco picture djipco  路  7Comments

developer239 picture developer239  路  5Comments

pabx06 picture pabx06  路  4Comments

seanquijote picture seanquijote  路  6Comments

fildaniels picture fildaniels  路  5Comments