How to remove convexity defects in a Sudoku square?

I have a solution that works, but you’ll have to translate it to OpenCV yourself. It’s written in Mathematica. The first step is to adjust the brightness in the image, by dividing each pixel with the result of a closing operation: src = ColorConvert[Import[“http://davemark.com/images/sudoku.jpg”], “Grayscale”]; white = Closing[src, DiskMatrix[5]]; srcAdjusted = Image[ImageData[src]/ImageData[white]] The next step … Read more

Converting RGB to grayscale/intensity

The specific numbers in the question are from CCIR 601 (see Wikipedia article). If you convert RGB -> grayscale with slightly different numbers / different methods, you won’t see much difference at all on a normal computer screen under normal lighting conditions — try it. Here are some more links on color in general: Wikipedia … Read more

Use pytesseract OCR to recognize text from an image

Here is my solution: import pytesseract from PIL import Image, ImageEnhance, ImageFilter im = Image.open(“temp.jpg”) # the second one im = im.filter(ImageFilter.MedianFilter()) enhancer = ImageEnhance.Contrast(im) im = enhancer.enhance(2) im = im.convert(‘1’) im.save(‘temp2.jpg’) text = pytesseract.image_to_string(Image.open(‘temp2.jpg’)) print(text)

OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection

This is a recurring subject in Stackoverflow and since I was unable to find a relevant implementation I decided to accept the challenge. I made some modifications to the squares demo present in OpenCV and the resulting C++ code below is able to detect a sheet of paper in the image: void find_squares(Mat& image, vector<vector<Point> … Read more

Video Streaming from IP Camera in Python Using OpenCV cv2.VideoCapture

You’re most likely getting that error due to an invalid stream link. Insert your stream link into VLC player to confirm it is working. Here’s a IP camera video streaming widget using OpenCV and cv2.VideoCapture.read(). This implementation uses threading for obtaining frames in a different thread since read() is a blocking operation. By putting this … Read more