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

Fast Bitmap Blur For Android SDK

For future Googlers, here is an algorithm that I ported from Quasimondo. It’s kind of a mix between a box blur and a gaussian blur, it’s very pretty and quite fast too. Update for people encountering the ArrayIndexOutOfBoundsException problem : @anthonycr in the comments provides this information : I found that by replacing Math.abs with … Read more

How can I improve my paw detection?

If you’re just wanting (semi) contiguous regions, there’s already an easy implementation in Python: SciPy’s ndimage.morphology module. This is a fairly common image morphology operation. Basically, you have 5 steps: def find_paws(data, smooth_radius=5, threshold=0.0001): data = sp.ndimage.uniform_filter(data, smooth_radius) thresh = data > threshold filled = sp.ndimage.morphology.binary_fill_holes(thresh) coded_paws, num_paws = sp.ndimage.label(filled) data_slices = sp.ndimage.find_objects(coded_paws) return object_slices … Read more

How to resize an image with OpenCV2.0 and Python2.6

If you wish to use CV2, you need to use the resize function. For example, this will resize both axes by half: small = cv2.resize(image, (0,0), fx=0.5, fy=0.5) and this will resize the image to have 100 cols (width) and 50 rows (height): resized_image = cv2.resize(image, (100, 50)) Another option is to use scipy module, … Read more

How to merge a transparent png image with another image using PIL

from PIL import Image background = Image.open(“test1.png”) foreground = Image.open(“test2.png”) background.paste(foreground, (0, 0), foreground) background.show() First parameter to .paste() is the image to paste. Second are coordinates, and the secret sauce is the third parameter. It indicates a mask that will be used to paste the image. If you pass a image with transparency, then … Read more

Simple and fast method to compare images for similarity

Can the screenshot or icon be transformed (scaled, rotated, skewed …)? There are quite a few methods on top of my head that could possibly help you: Simple euclidean distance as mentioned by @carlosdc (doesn’t work with transformed images and you need a threshold). (Normalized) Cross Correlation – a simple metrics which you can use … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)