a lot of stuff related to ocr/ofd method

This commit is contained in:
2024-11-22 23:19:04 +03:00
parent 02e4465075
commit 2b9ad2fcae
95 changed files with 57786 additions and 112 deletions

51
imageview/imageview.cpp Normal file
View File

@@ -0,0 +1,51 @@
#include <QWheelEvent>
#include "imageview.h"
#include <iostream>
ImageView::ImageView(QWidget *parent) :
QLabel(parent) {
// std::cout << this->geometry().height() << " " << this->geometry().width() << std::endl;
}
// ImageView::ImageView(QWidget *parent, std::string path):
// QLabel(parent) {
// this->setPixmap(QPixmap(QString::fromStdString(path)));
// }
void ImageView::wheelEvent(QWheelEvent *event) {
QPointF shift = event->position();
QRegion r = QRegion();
// this->pixmap(Qt::ReturnByValueConstant::ReturnByValue).scroll(10, 10, this->rect(), &r);
this->scroll(shift.x(), shift.y(), this->rect());
// this->setPixmap(QPixmap());
// pm.scroll(shift.x(), shift.y(), this->rect());
// pm.scroll();
// this->setPixmap(pm);
//this->pixmap(Qt::ReturnByValueConstant::ReturnByValue).scroll(shift.x(), shift.y(), this->pixmap()->rect());
QPoint numDegrees = event->angleDelta() / 8;
std::cout << numDegrees.x() << std::endl;
event->accept();
}
void ImageView::setImage(std::string image){
//Commented is a way of scaling that is, as I understand, is lossless. If there'll be problems with current method's losses, I'll return to commented method
maxHeight = this->height();
maxWidth = this->width();
QPixmap pixmap = QPixmap(QString::fromStdString(image));
// double scaleFactor = pixmap.height() > pixmap.width()? static_cast<double>(maxHeight) / pixmap.height() : static_cast<double>(maxWidth) / pixmap.width();
pixmap = pixmap.scaled(maxWidth, maxHeight, Qt::AspectRatioMode::KeepAspectRatio);
this->setPixmap(pixmap);
// this->setGeometry(this->geometry().x(), this->geometry().y(), pixmap.width() * scaleFactor, pixmap.height() * scaleFactor);
// this->setScaledContents(true);
}

19
imageview/imageview.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef IMAGEVIEW_H
#define IMAGEVIEW_H
#include <QLabel>
#include <QObject>
#include <QWidget>
class ImageView : public QLabel
{
Q_OBJECT
double maxHeight, maxWidth;
public:
ImageView(QWidget *parent=nullptr);
// ImageView(QWidget *parent=nullptr, std::string path="");
void wheelEvent(QWheelEvent*);
void setImage(std::string);
};
#endif // IMAGEVIEW_H