-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
349 additions
and
92 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
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,50 @@ | ||
# lldb | ||
|
||
```bash | ||
|
||
|
||
|
||
lldb ./imgclass_test | ||
run | ||
bt | ||
|
||
(lldb) run # run debugger | ||
(lldb) quit # quit debugger | ||
|
||
# Examine Once Crash Happens | ||
|
||
(lldb) frame variable # or fv : Displays local variables in the current stack frame. | ||
(lldb) print *this # non static contexts | ||
(lldb) print variable_name | ||
|
||
# frame 2 calls fr1 , f1 calls f0 , etc. | ||
(lldb) bt # get backtrace of execution | ||
frame select 0 # shows top stack frame | ||
register read x8 # from stack frame - check memory addr read | ||
|
||
|
||
|
||
(lldb) bt | ||
|
||
# print <variable_name> or p <variable_name>: Prints the value of a variable. | ||
|
||
(lldb) print variable_name | ||
|
||
## Example Output for Debugging | ||
|
||
- Shows us the top frame of the stack | ||
|
||
frame select 0 | ||
|
||
# output : -> 0x10000ab10 <+120>: ldr x8, [x8, #0x8] | ||
|
||
- Then view the register at address x8 | ||
|
||
register read x8 | ||
|
||
# output x8 = 0x0000000000000000 => NULL MEMORY ADDRESS | ||
|
||
quit | ||
|
||
|
||
``` |
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
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,21 @@ | ||
|
||
#include <leptonica/allheaders.h> | ||
#include <llvm/Support/raw_ostream.h> | ||
#include <tesseract/baseapi.h> | ||
#include <tesseract/renderer.h> | ||
|
||
// tesseract.h | ||
#ifndef TESSERACT_H | ||
#define TESSERACT_H | ||
|
||
void createPDF(const std::string &input_path, | ||
const std::string &output_path, | ||
const char *tessdata_path, | ||
bool text_only = false); | ||
|
||
auto extractTextFromImageFileLeptonica(const std::string &file_path, | ||
const std::string &lang = "eng") -> std::string; | ||
|
||
auto extractTextLSTM(const std::string &file_path, const std::string &lang = "eng") -> std::string; | ||
|
||
#endif // TESSERACT_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,60 @@ | ||
|
||
#include <gtest/gtest.h> | ||
#include <src/fs.h> | ||
#include <textract.h> | ||
|
||
namespace imgclass_test_constants { | ||
static constexpr auto tempDirectory = "temporary_dir"; | ||
constexpr auto *const imgFolder = IMAGE_FOLDER_PATH; | ||
constexpr auto *const inputOpenTest = INPUT_OPEN_TEST_PATH; | ||
} // namespace imgclass_test_constants | ||
|
||
using namespace imgclass_test_constants; | ||
|
||
class Imgclasstest: public ::testing::Test { | ||
protected: | ||
// static std::vector<std::string> static_memb; | ||
static std::vector<std::string> fpaths; | ||
static std::unique_ptr<imgstr::ImgProcessor> app; | ||
|
||
void SetUp() override { | ||
// runs per test | ||
} | ||
void TearDown() override { | ||
// runs per test | ||
} | ||
|
||
static void SetUpTestSuite() { | ||
// Once for whole Fixture | ||
|
||
app = std::make_unique<imgstr::ImgProcessor>(1000); // Adjust parameters as needed | ||
|
||
// static_member = initializeStaticMember(); | ||
fpaths = getFilePaths(imgFolder).get(); | ||
} | ||
|
||
static void TearDownTestSuite() { | ||
// Once for Whole Fixture | ||
} | ||
|
||
public: | ||
std::string tempDir = "tempImgClass"; | ||
}; | ||
|
||
// Definition of static members | ||
std::vector<std::string> Imgclasstest::fpaths; | ||
std::unique_ptr<imgstr::ImgProcessor> Imgclasstest::app; | ||
|
||
TEST_F(Imgclasstest, BasicAssertions) { | ||
// implement test | ||
|
||
ASSERT_FALSE(fpaths.empty()); // Ensure there is at least one path to work with | ||
if (!fpaths.empty()) { | ||
ASSERT_NO_THROW(app->convertImageToTextFile(fpaths[0], tempDir)); | ||
} | ||
} | ||
|
||
auto main(int argc, char **argv) -> int { | ||
testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
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
Oops, something went wrong.