QtBarcodeReader::QtBarcodeReader(QObject *parent,QWidget *viewer) : QObject(parent) { qRegisterMetaType<cv::Mat>("cv::Mat"); converter.setProcessAll(false); cvcapture= new CVCapture(); converter.connect(cvcapture, SIGNAL(matReady(cv::Mat)), SLOT(processFrame(cv::Mat))); BarcodeDecoder.connect(&converter, SIGNAL(imageReady(QImage)), SLOT(decodeImage(QImage))); connect(&BarcodeDecoder,SIGNAL(BarcodeDecodeStatus(BARCODESTATUS,QString)),this, SLOT(NewBarcodeDecodeStatus(BARCODESTATUS,QString))); if (viewer!=0) { viewer->connect(&converter, SIGNAL(imageReady(QImage)), SLOT(setImage(QImage))); } }
extern "C" int qtmn(int argc, char** argv) { #else int main(int argc, char **argv) { #endif try { QApplication app(argc, argv); QSurfaceFormat fmt; fmt.setDepthBufferSize(24); if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) fmt.setSamples(4); if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) { fmt.setVersion(3, 2); fmt.setProfile(QSurfaceFormat::CoreProfile); } QSurfaceFormat::setDefaultFormat(fmt); auto logger = gatherer::graphics::Logger::create("preview-qt"); logger->info("Start"); // Should be created in heap, ownership taken by parent widget GLWidget *glWidget = new GLWidget; // Note: moved creation output of Window for signal connection: #if defined(__ANDROID__) const bool synth = true; // Camera not working on Android (yet) #else const bool synth = false; #endif VideoCapture capture(0, synth); MainWindow mainWindow(glWidget, capture); mainWindow.resize(mainWindow.sizeHint()); int desktopArea = QApplication::desktop()->width() * QApplication::desktop()->height(); int widgetArea = mainWindow.width() * mainWindow.height(); if (((float)widgetArea / (float)desktopArea) < 0.75f) mainWindow.show(); else mainWindow.showMaximized(); // ((((((((((((((((( bEGIN ))))))))))))))))) QThread captureThread; captureThread.start(); capture.moveToThread(&captureThread); qRegisterMetaType< cv::Mat >("cv::Mat"); QObject::connect(&capture, &VideoCapture::started, [](){ qDebug() << "capture started"; }); glWidget->connect(&capture, SIGNAL(matReady(cv::Mat)), SLOT(setImage(cv::Mat))); // ((((((((((((((((( eND ))))))))))))))))) int rc = app.exec(); captureThread.quit(); captureThread.wait(); return rc; } catch (const std::exception& exc) { std::cerr << "Exception catched: " << exc.what() << std::endl; return EXIT_FAILURE; } catch (...) { std::cerr << "Unknown exception catched" << std::endl; return EXIT_FAILURE; } }