I have clear images of cards vs blurry images of card. My task is to capture photo when the image is not blurry, as you can see from the description I need this code to run in real time on android device.

I have done some background reserarch on this topic 'Identify blurry image'. And found out few interesting solutions.

  1. Apply opencv transforms such as laplace or sobel filter. The blurry image will have less edges. And then using techniques such as SVM to find out which image has less edges
  2. Use other opencv transforms similar to sobel to get edges of images and then find image with less edges.

Although these transforms produce good output. They are badly slow. I need something which has speed similar to tflite object detection using android. Taking this logic in my mind my obvious step was to annotate images 1500(blurred cards) vs 1500(non blurry cards) and retrain ssdmobilenet model using tensorflow object detection api.

My dataset

(clear) enter image description here

(blur) enter image description here

However when I exported the trained model to android I completely messy output, it appears as though the model has not learned anything from the data. My question is Is this problem solvable using object detection api as I mentioned above ? if yes where am I going wrong ? If no what are the fastest alternatives to detect blur in real time

  • 2
    $\begingroup$ The easiest way would be not to use any ML. Just run canny edge detection (it's blazingly fast) and count pixels, which are edges. $\endgroup$ Nov 29, 2019 at 14:37
  • $\begingroup$ @PiotrRarus-ReinstateMonica How do you generalize this problem ? lets say for iowa state I have 75 dots for clear image and 10 dots for blurry image for frame 1 in the video for frame 2 I get 25 dots for clear image and 15 dots for blurry image (this can be due to external lighting conditions) each time these number of dots will change depending on lighting conditions and glare on the card. I dont know how this solution can work out in real world without applying SVM, a step which I want to avoid because I want blur vs no blur in real video footage. $\endgroup$
    – Ajinkya
    Nov 30, 2019 at 5:21

2 Answers 2


One idea is to use a shallow (a handful of layers) CNN. Deep CNN's are good at detecting objects in images. Shallow networks focus on lower-level features, such as edges and textures and colors. So, my suggestion is to train a simpler network on a larger training set by training it on image patches rather than on full cards. If the majority of your patches are classifed as blurry, then you classify your whole card as blurry.


I was searching for something similar. Might help you and others on the way.

For Real-time camera script:

For gallery images:

  • $\begingroup$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review $\endgroup$
    – Ethan
    Mar 30 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.