SwiftyTesseract / SwiftyTesseract

A Swift wrapper around Tesseract for use in iOS, macOS, and Linux applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Page segmentation modes (--psm)

vfj-khanh opened this issue · comments

Checklist

Is your feature request related to a problem? Please describe.
Like command line usage:

 tesseract imagename outputbase [-l lang] [--oem ocrenginemode] [--psm pagesegmode]

 tesseract --help-psm
Page segmentation modes:
  0    Orientation and script detection (OSD) only.
  1    Automatic page segmentation with OSD.
  2    Automatic page segmentation, but no OSD, or OCR. (not implemented)
  3    Fully automatic page segmentation, but no OSD. (Default)
  4    Assume a single column of text of variable sizes.
  5    Assume a single uniform block of vertically aligned text.
  6    Assume a single uniform block of text.
  7    Treat the image as a single text line.
  8    Treat the image as a single word.
  9    Treat the image as a single word in a circle.
 10    Treat the image as a single character.
 11    Sparse text. Find as much text as possible in no particular order.
 12    Sparse text with OSD.
 13    Raw line. Treat the image as a single text line,
       bypassing hacks that are Tesseract-specific.

Could you make a function to set psm (aka Page segmentation modes) on this library.

Describe the solution you'd like
Like EngineMode, it would be nice if you make TessPageSegMode enum and public function to set
psm setting.
Something like

public enum PageSegMode: TessPageSegMode.RawValue

public func setPageSegMode(_ pageSegMode: PageSegMode) 

Describe alternatives you've considered
Or at least, please make this API public for used.

TESS_API void TESS_CALL TessBaseAPISetPageSegMode(TessBaseAPI* handle,
                                                  TessPageSegMode mode);

I'm all for adding this to the public API, but I don't currently have the cycles now to pick this up. You are more than welcome to implement and make a PR if you have the time and I will happily review it. Otherwise this may sit unaddressed for the foreseeable future as I'm not a heavy user of this framework myself these days.

To anyone who would want to pick this up I would prefer that this be a settable property on SwiftyTesseract similar to the other configuration properties (like the whiteList and blackList)

commented

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@Stale keep open

commented

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Keeping open for now, but in the Swift 5.3 branch there is a method of extending the library without needing to make PRs or fork the project.

In lieu of implementing this as an addition to the API, the library is allowing for more extensibility. You can see how this exact request can be implemented in a new README section. This change is in the develop branch currently and will be released as 4.0.0 when the Xcode 12 GM is available.