Skip to content

Commit

Permalink
Merge pull request #9 from wanhuz/main
Browse files Browse the repository at this point in the history
Merge 0.6.1
  • Loading branch information
wanhuz authored May 1, 2023
2 parents e689254 + 1394fd2 commit 3b7f65f
Show file tree
Hide file tree
Showing 31 changed files with 348 additions and 145 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ vs2019/.vs/
.git/
vs2019/x86/
vs2019/x64/
vs2019/vcpkg_installed/
vs2019/Debug/
.vs/

# Prerequisites
*.d
Expand Down
13 changes: 13 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1. Install MS Studio 2022
2. Install Qt 5.15.1
3. Install Vcpkg
4. Build the project from Visual Studio once to download dependencies using Vcpkg
5. Install Mecab from official site, set to UTF-8 during installation
6. To compile and run the program in debug mode, define absolute path to its resource folder in directive in file:
- dict.cpp
- MainWindow.cpp
- mecabKey.cpp
- ocr.cpp
- popup.cpp

x. If the program crash because of Mecab::createTagger, make sure the mecabrc absolute path is correct in mecabKey.cpp
21 changes: 21 additions & 0 deletions CppProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurations": [
{
"inheritEnvironments": [
"msvc_x64"
],
"name": "x64-Debug",
"includePath": [
"${env.INCLUDE}",
"${workspaceRoot}\\**"
],
"defines": [
"WIN32",
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "windows-msvc-x64"
}
]
}
112 changes: 0 additions & 112 deletions Planning.txt

This file was deleted.

8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1. Create a release build using Visual Studio 64-bit
2. Copy release folder (should be in vs2019/x64/release) to another location (example: "C:\Users\xxx\Desktop\Release"
3. Remove everything except melonpan.exe
5. Navigate to Qt 5.15.1 compiler binary folder (e,g, C:\Qt\5.15.1\msvc2019_64\bin)
6. Open Powershell in that folder and run winqtdeploy.exe with argument pointing to location of release folder in 2
- example: .\windeployqt.exe "C:\Users\xxx\Desktop\Release"
7. Copy resource folder (res) from source code to the Release folder
8. Done!
56 changes: 56 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Rough roadmap

1.0


0.9
Modern UI - theming
Dictionary lookup time improvement
Basic OCR Preprocessing? - sharpen image, b/w e,g,

0.8
Configuration Option
Extra character in textbox break search
Automatic font size recognition
Search romaji
FIx searching english word sorted by japanese frequency

0.7
Search speed improvement
Basic settings

0.6.3
Fix horizontal capture for OCR

0.6.2
Bugfix
- Min UI crash
- Memory leak
Revise debug mode

0.6.1
Update to Tess 5 x
Improve Tess accuracy x
Debug mode x
Change default shortcut x ` or ~
Candy
- Good proportion x
- Icon instead of text x
- Application icon x

0.6
Minimize to tray x
Code cleanup x
Improve capturekey performance (important for min mode) x


misc
unit test?
note.

ux improvement
- copy text from column
- double click to select text from column
ux bug
- toggle resize windows
capturekey not safe starting hook. check null val first
Binary file added res/tessdata/jpn_vert_best.traineddata
Binary file not shown.
Binary file added res/tessdata/jpn_vert_zodiac3539.traineddata
Binary file not shown.
4 changes: 4 additions & 0 deletions res/ui/ATTRIBUTION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Icon:
scanner.png: [email protected]
screenshot.png: [email protected]
minimize.png: [email protected]
10 changes: 10 additions & 0 deletions res/ui/buttonicon.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="icon">
<file>minimize.png</file>
<file>scanner.png</file>
<file>screenshot.png</file>
</qresource>
<qresource prefix="appicon">
<file>melonpan.ico</file>
</qresource>
</RCC>
Binary file added res/ui/minimize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/ui/scanner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/ui/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/capturekey/capturekey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void capturekey::run() {
}

int capturekey::setKey() {
keyOCR = VK_LCONTROL;
keyTextGeneric = VK_LCONTROL;
keyOCR = VK_OEM_3;
keyTextGeneric = VK_OEM_3;
return 0;
}

Expand Down
10 changes: 7 additions & 3 deletions src/dict/dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include <qdir.h>
#include <algorithm>


#ifdef DEBUG_MODE
#define ABSPATHTODICT dictPath = "C://xxx//melonpan//res//dict//JMdict_e"
#else
#define ABSPATHTODICT
#endif

Dict::Dict() {
this->initFreqMap();
Expand All @@ -19,8 +23,8 @@ void Dict::load() {
QByteArray dictData;

dictPath = QDir::currentPath();
dictPath = dictPath + "/res/dict/JMdict_e"; //Deployment
//dictPath = "C://Users//WanHuz//source//repos//melonpan//res//dict//JMdict_e"; //Debug Mode
dictPath = dictPath + "/res/dict/JMdict_e";
ABSPATHTODICT;
QFile dictFile(dictPath);

if (!dictFile.open(QIODevice::ReadOnly | QIODevice::Text))
Expand Down
14 changes: 9 additions & 5 deletions src/ocr/ocr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
#include <string>
#include <iostream>
#include <qdir.h>
#include <qdebug.h>


#ifdef DEBUG_MODE
#define ABSTESSDATAPATH tessDataPath = "C:\\xxx\\melonpan\\res\\tessdata\\"
#else
#define ABSTESSDATAPATH
#endif

Ocr::Ocr() {
QString tessDataPath;

api = new tesseract::TessBaseAPI();

//Path to tesseract Data
tessDataPath = QDir::currentPath();
tessDataPath = tessDataPath.replace("/", "\\");
tessDataPath = tessDataPath + "\\res\\tessdata\\";
//tessDataPath = "C:\\Users\\WanHuz\\source\\repos\\melonpan\\res\\tessdata\\"; //Debug Mode

ABSTESSDATAPATH;

QByteArray tessDataPath_char = tessDataPath.toLocal8Bit();
const char* tessDataPath_char2 = tessDataPath_char.data();

if (api->Init(tessDataPath_char2, "jpn_vert")) {
if (api->Init(tessDataPath_char2, "jpn_vert_zodiac3539")) {
QMessageBox err;
err.setText("Could not initialize Tesseract file at " + tessDataPath + "\nProgram will now exit ");
err.setIcon(QMessageBox::Critical);
Expand All @@ -45,7 +50,6 @@ QString Ocr::recognize(Pix* image) {
outText = api->GetUTF8Text();
outstring = QString::fromUtf8(outText);

delete[] outText;
pixDestroy(&image);

return outstring;
Expand Down
15 changes: 13 additions & 2 deletions src/settings/mecabKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#include <qdir.h>
#include <qstring.h>

#ifdef DEBUG_MODE
#define ABSPATHTOMECABRC pathToMecabrc = "C:\\xxx\\melonpan\\res\\mecab\\etc\\mecabrc"
#else
#define ABSPATHTOMECABRC
#endif


using std::optional;
using std::pair;
using std::vector;
Expand Down Expand Up @@ -61,7 +68,9 @@ bool MeCabKey::verifyMeCabKey(std::string usid) {
QString pathToMecabrc = QDir::currentPath();
pathToMecabrc.replace("/", "\\");
pathToMecabrc.append("\\res\\mecab\\etc\\mecabrc");
//pathToMecabrc = "C:\\Users\\WanHuz\\source\\repos\\melonpan\\res\\mecab\\etc\\mecabrc"; //debug mode

ABSPATHTOMECABRC;

std::wstring pathToMecabrcstr = StringToWString(pathToMecabrc.toStdString());

if (key.GetStringValue(mecab) == pathToMecabrc) { //Validate key correctness
Expand All @@ -85,10 +94,12 @@ bool MeCabKey::createMeCabKey(std::string usid) {

RegKey key{ HKEY_USERS, keyPath };

//QString pathToMecabrc = "C:\\Users\\WanHuz\\source\\repos\\melonpan\\res\\mecab\\etc\\mecabrc"; //debug mode
QString pathToMecabrc = QDir::currentPath();
pathToMecabrc.replace("/", "\\");
pathToMecabrc.append("\\res\\mecab\\etc\\mecabrc");

ABSPATHTOMECABRC;

std::wstring pathToMecabrcstr = StringToWString(pathToMecabrc.toStdString());
key.SetStringValue(mecab, pathToMecabrcstr);

Expand Down
Loading

0 comments on commit 3b7f65f

Please sign in to comment.