-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab953a0
commit 0ce7084
Showing
6 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.o | ||
StripeReassembly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
OPT_FLAGS = -O3 | ||
CXX = g++ | ||
CXX_FLAGS = $(OPT_FLAGS) --std=c++17 -Wall | ||
|
||
LIBS = -llept -ltesseract | ||
INCLUDES = -I./include/ | ||
|
||
src_dir = ./src/ | ||
dst_dir = ./ | ||
src = $(wildcard $(src_dir)*.cpp) | ||
obj = $(patsubst %.cpp, %.o, $(src)) | ||
|
||
default: StripeReassembly | ||
.PHONY: clean | ||
|
||
StripeReassembly: $(obj) | ||
$(CXX) $< $(LIBS) -o $(dst_dir)$@ | ||
|
||
%.o: %.cpp | ||
$(CXX) $< $(CXX_FLAGS) $(INCLUDES) -c -o $@ | ||
|
||
clean: | ||
rm $(dst)StripeReassembly $(src_dir)*.o |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef GENERATE_STRIPES_H | ||
#define GENERATE_STRIPES_H | ||
|
||
class GenerateStripes { | ||
|
||
public: | ||
GenerateStripes(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include <generate_stripes.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <tesseract/baseapi.h> | ||
#include <leptonica/allheaders.h> | ||
|
||
int main() | ||
{ | ||
|
||
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI(); | ||
// Initialize tesseract-ocr with English, without specifying tessdata path | ||
if (api->Init(NULL, "eng+chi_sim")) { | ||
fprintf(stderr, "Could not initialize tesseract.\n"); | ||
exit(1); | ||
} | ||
|
||
// Open input image with leptonica library | ||
Pix *image = pixRead("./data/test0.png"); | ||
api->SetImage(image); | ||
|
||
// Get OCR result | ||
// char * outText = api->GetUTF8Text(); | ||
// int conf = api->MeanTextConf(); | ||
// printf("OCR output:\n%s", outText); | ||
// printf("Confidence: %d\n", conf); | ||
// delete [] outText; | ||
|
||
api->Recognize(0); | ||
tesseract::ResultIterator* ri = api->GetIterator(); | ||
tesseract::PageIteratorLevel level = tesseract::RIL_SYMBOL; | ||
if (ri != 0) { | ||
do { | ||
const char* word = ri->GetUTF8Text(level); | ||
float conf = ri->Confidence(level); | ||
int x1, y1, x2, y2; | ||
ri->BoundingBox(level, &x1, &y1, &x2, &y2); | ||
printf("word: '%s'; \tconf: %.2f; BoundingBox: %d,%d,%d,%d;\n", | ||
word, conf, x1, y1, x2, y2); | ||
delete[] word; | ||
} while (ri->Next(level)); | ||
} | ||
|
||
// Destroy used object and release memory | ||
api->End(); | ||
pixDestroy(&image); | ||
|
||
return 0; | ||
} |