Browse over 10,000 Electronics Projects using the Page Numbering provided at the bottom of each Page.

OpenCV 3 Python blur detection

OpenCV 3 Python blur detection

logoIn order to detect if picture is in focus modern consumer cameras use complicated phase detection circuitry and specialized sensors. But how to determine if captured picture is in focus after it has been taken. Having this measurement information can help in many ways (select best picture in a sequence, control motorized lens, clean time-lapse video and many other).

In our case Laplacian transformation, while not being perfect solution, can distinguish between same scene focused and blurred frames. While it is hard to describe what Lapliacian function does, you can always read more details on Wikipedia pages.

Again I will be using OpenCV to solve this problem. Let’s capture short video clip and run script to see the results. Script is in a way that displays video file with quality bar at the bottom and saves text file with numerical result for further analysis.

out_13

Note red bar at the bottom indicating focus quality

Whole clip analysis indicated that function can distinguish if in focus very precisely. Unfortunately has hard times determining blur level in extreme conditions.

To display focus/blur distribution over time I used LibreOffice graph function. Below is visual blur over frame nr representation.

7

Focus quality distribution vs time

Script

 

More Articles to Read

avatar
EEWeb
avatar
Dangerous Prototypes
avatar
EEWeb
avatar
Arduino Blog
avatar
Arduino Blog
avatar
Ken Shirrif
avatar
Dangerous Prototypes
avatar
EEWeb
avatar
Arduino Blog
avatar
Freetronics
avatar
Arduino Blog
avatar
Dangerous Prototypes

Top




Shares