OCR in AS3 flash, vectorizing a square
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: OCR in AS3 flash, vectorizing a square

  1. #1
    Senior Member AzraelKans's Avatar
    Join Date
    May 2002
    Location
    Hell... with frequent access to heaven ;)
    Posts
    409

    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. #2
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    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.
    Streets Of Poker - Heads-Up Texas Hold'em Poker Game

  3. #3
    Senior Member rachil0's Avatar
    Join Date
    Jul 2007
    Location
    Columbus, OH.
    Posts
    465
    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. #4
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    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. #5
    Senior Member
    Join Date
    Nov 2003
    Location
    Las Vegas
    Posts
    770
    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. #6
    Junior Member
    Join Date
    Jul 2013
    Posts
    22
    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. #7
    Junior Member
    Join Date
    Nov 2015
    Posts
    1
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center

Poll by Flashkit.com