-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathocrforread.cpp
57 lines (49 loc) · 1.75 KB
/
ocrforread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "ocrforread.h"
OCRForRead::OCRForRead(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
setWindowState(Qt::WindowMaximized);//³õʼ»¯´°¿Ú×î´ó»¯
//camera = new QCamera();
qDebug() << tr("debug");
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach(const QCameraInfo &cameraInfo, cameras) {
qDebug() << cameraInfo.deviceName();
qDebug() << "The camera sensor orientation is " << cameraInfo.orientation() << " degrees.";
if (cameraInfo.deviceName() == "@device:pnp:\\\\?\\usb#vid_2b7e&pid_505a&mi_00#6&57bef4d&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global") {
camera = new QCamera(cameraInfo);
}
}
cameraViewFinder = new QCameraViewfinder();
cameraImageCapture = new QCameraImageCapture(camera);
connect(ui.pushButton_browse, SIGNAL(clicked()), this, SLOT(captureBtnResponded()));
connect(ui.pushButton_start, SIGNAL(clicked()), this, SLOT(saveBtnResponded()));
connect(ui.pushButton_stop, SIGNAL(clicked()), this, SLOT(exitBtnResponded()));
connect(cameraImageCapture, SIGNAL(imageCaptured(int, QImage)), this, SLOT(cameraImageCaptured(int, QImage)));
cameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToFile);
camera->setCaptureMode(QCamera::CaptureStillImage);
camera->setViewfinder(cameraViewFinder);
camera->start();
}
OCRForRead::~OCRForRead()
{
}
void OCRForRead::captureBtnResponded()
{
cameraImageCapture->capture();
//Sleep(2000);
}
void OCRForRead::saveBtnResponded()
{
const QPixmap *pixmap = ui.labelshow->pixmap();
if (pixmap) { pixmap->save("D:/workspace/Qt_Project/test/camera/a.jpg"); }
}
void OCRForRead::exitBtnResponded()
{
camera->stop();
this->close();
}
void OCRForRead::cameraImageCaptured(int id, QImage image)
{
ui.labelshow->setPixmap(QPixmap::fromImage(image));
}