A Flash Developer Resource Site

# Thread: OCR in AS3 flash, vectorizing a square

1. ## OCR in AS3 flash, vectorizing a square

Well, as some of you may know, in trying to create a OCR engine in AS3, first step was to analyze a webcam feed at a nice rate (8-15 fps) and then create "blobs" out of the images in corresponding colors in the screen (threeshold actually) so now I can count blobs on the screen (yay!) now comes the difficult part,

I need to analyze a bitmap and recognize a vector shape. In this case Im going for a square, Ive been looking around for info on how to get vectors of a bitmap shape but so far I havent found much info on that, Ive got a collision box by simply checking the mins and max values, but what I need is a oriented collision box, or more likely 4 points defining the edges of the shape.

Any ideas or tutorials on how to do that?

2. Well, find the first colored pixel in the upper left corner, trace along the top, and define an angle for the top line based on a couple of samples. If you check every pixel horizontally and they are all within a reasonable threshold, assume you're still on the right track, otherwise create a new point here, and continue. Do this for all sides!

I think it's too weak but I'm afraid it's my best bid.

Anyway, I think the key for defining a shape is to define when the line is so far off, that you have changed direction.

3. There's the Hough transform, but it seems parameter sensitive and vulnerable to noise. I have never implemented it myself.

One thing it might be able to do, is help you identify principal axes of your blob, so you can figure out what orientation your oriented bounding box (OBB) should have.

A quick and dirty solution would be to generate lots of OBBs, by rotating the source image and then running using the regular aligned bounding box algorithm. Pick the box that is the "tightest" (I would think you would want to minimize the area of the box?)

Another good idea might be to compute the convex hull of your feature points, then run the quick and dirty algorithm on those points. This would be fast and if you're detecting a convex shape anyway, might as well exploit that.

Actually, from your description, it sounds like convex hull is exactly what you're trying to find anyway ("need to analyze a bitmap and recognize a vector shape").

http://en.wikipedia.org/wiki/Convex_hull
http://en.wikipedia.org/wiki/Convex_hull_algorithms

4. ideas, not much but I guess the key is to find a method that indentifies edges as edges are the key parts of shapes. Perhaps sample some circles or rectangles and check if some color pixels vary after some color reduction (levels in RGB channel reduction).

anyway little drifting off but some nice technology in that area (partly even in flash )
http://vectormagic.stanford.edu/
esspecially the comparison page:
http://vectormagic.stanford.edu/vectorize/comparisons

5. Here's an idea, I've never tried it, but the logic seems sound:

Once you have identified your blob and it's current bounding box, cut out the bounding box to a new bitmap using clipRect. Now rotate the the cut out till it's bounding box is the smallest possible. This should give you proper orientation. Now your points are defined by the bounding box.

6. Ocr engine in a document image managing system can be used to fastly and accuratly apply image recognition function, which converts scanned images into searchable text formats, such as PDF, PDF/A, WORD and any other document formats. Almost all the image formats can be detected and recognized a general OCR control.

7. as i know, common ocr engine can only recognize text from raster image like bmp and jpeg, if you want to detect text in vector image, maybe you need change vector to raster first.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap