forked from flameshot-org/flameshot
-
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.
fix flameshot-org#702 add OCR with tesseract
- Loading branch information
Raul Sampedro
committed
Jan 27, 2023
1 parent
05c3b87
commit 9af54b3
Showing
15 changed files
with
164 additions
and
1 deletion.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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,55 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors | ||
|
||
#include "ocrtool.h" | ||
#include "src/utils/screenshotsaver.h" | ||
#include <QApplication> | ||
#include <QPainter> | ||
#include <QStyle> | ||
#if defined(Q_OS_MACOS) | ||
#include "src/widgets/capture/capturewidget.h" | ||
#include <QWidget> | ||
#endif | ||
|
||
OcrTool::OcrTool(QObject* parent) | ||
: AbstractActionTool(parent) | ||
{} | ||
|
||
bool OcrTool::closeOnButtonPressed() const | ||
{ | ||
return true; | ||
} | ||
|
||
QIcon OcrTool::icon(const QColor& background, bool inEditor) const | ||
{ | ||
Q_UNUSED(inEditor) | ||
return QIcon(iconPath(background) + "ocr.svg"); | ||
} | ||
|
||
QString OcrTool::name() const | ||
{ | ||
return tr("OCR"); | ||
} | ||
|
||
CaptureTool::Type OcrTool::type() const | ||
{ | ||
return CaptureTool::TYPE_OCR; | ||
} | ||
|
||
QString OcrTool::description() const | ||
{ | ||
return tr("OCR the capture"); | ||
} | ||
|
||
CaptureTool* OcrTool::copy(QObject* parent) | ||
{ | ||
return new OcrTool(parent); | ||
} | ||
|
||
void OcrTool::pressed(CaptureContext& context) | ||
{ | ||
emit requestAction(REQ_CLEAR_SELECTION); | ||
emit requestAction(REQ_CAPTURE_DONE_OK); | ||
context.request.addTask(CaptureRequest::OCR); | ||
emit requestAction(REQ_CLOSE_GUI); | ||
} |
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,27 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors | ||
|
||
#pragma once | ||
|
||
#include "abstractactiontool.h" | ||
|
||
class OcrTool : public AbstractActionTool | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit OcrTool(QObject* parent = nullptr); | ||
|
||
bool closeOnButtonPressed() const override; | ||
|
||
QIcon icon(const QColor& background, bool inEditor) const override; | ||
QString name() const override; | ||
QString description() const override; | ||
|
||
CaptureTool* copy(QObject* parent = nullptr) override; | ||
|
||
protected: | ||
CaptureTool::Type type() const override; | ||
|
||
public slots: | ||
void pressed(CaptureContext& context) override; | ||
}; |
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
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