Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

28
  • 77
    +1 Long post, but very educational. This should go to opencv tag info Commented Apr 17, 2012 at 17:50
  • 17
    in case anyone's interested, I made a proper OO engine from this code, along with some bells and whistles: github.com/goncalopp/simple-ocr-opencv Commented Oct 14, 2012 at 3:01
  • 18
    Note that there is no need for using SVM and KNN when you have a well defined perfect font. For instance, the digits 0, 4, 6, 9 form one group, the digits 1, 2, 3, 5, 7 form another, and 8 another. This group is given by the euler number. Then "0" has no endpoints, "4" has two, and "6" and "9" are distinguished by centroid position. "3" is the only one, in the other group, with 3 endpoints. "1" and "7" are distinguished by the skeleton length. When considering the convex hull together with the digit, "5" and "2" have two holes and they can be distinguished by the centroid of largest hole. Commented Jan 28, 2013 at 5:23
  • 25
    A stellar tutorial. Thank you! There are a few changes needed to get this to work with the latest (3.1) versjon of OpenCV: contours,hierarchy = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) => _,contours,hierarchy = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE), model = cv2.KNearest() => model = cv2.ml.KNearest_create(), model.train(samples,responses) => model.train(samples,cv2.ml.ROW_SAMPLE,responses), retval, results, neigh_resp, dists = model.find_nearest(roismall, k = 1) => retval, results, neigh_resp, dists = model.find_nearest(roismall, k = 1) Commented Aug 9, 2016 at 11:44
  • 7
    @JohannesBrodwall Thanks for your update, quick note - your last correction is slightly off and should read: retval, results, neigh_resp, dists = model.find_nearest(roismall, k = 1) => retval, results, neigh_resp, dists = model.findNearest(roismall, k = 1) Commented Nov 14, 2016 at 11:56