1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include "YunDaISASImageRecognitionService.h"
- #include <QtWidgets/QApplication>
- #include "LoadAlgorithm.h"
- #include <QCoreApplication>
- #include <thread>
- #include "HttpServer.h"
- #include <iostream>
- #include "GloabalVariables.h"
- #include <qstring.h>
- #include <map>
- #include <QtWidgets/qmessagebox.h>
- #include <QTextCodec>
- #include <QSharedMemory>
- #pragma execution_character_set("UTF-8")
- using namespace std;
- int main(int argc, char *argv[])
- {
- static QSharedMemory* shareMem = new QSharedMemory("SingleApp"); //创建“SingleApp”的共享内存块
- if (!shareMem->create(1))//创建大小1b的内存
- {
- qApp->quit(); //创建失败,说明已经有一个程序运行,退出当前程序
- delete shareMem;
- return -1;
- }
-
- QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));
- try
- {
- QMessageLogger::QMessageLogger();
- QApplication a(argc, argv);
- YunDaISASImageRecognitionService window;
- //w.pointer_ = &w;
-
- window.show();
- //依赖库目录调整
- QString dependecePath = QApplication::applicationDirPath() + "/AlgorithmPlugin;";
- //QString testPath = QApplication::applicationDirPath() + "/Test;";
- //QMessageBox::critical(NULL, "提示", dependecePath);
- QString path = dependecePath + qgetenv("Path");
- qputenv("Path", path.toLocal8Bit());
- LoadAlgorithm loadAlgorithm;
- /* loadAlgorithm.Browser = w.GetQTextBrowser();
- loadAlgorithm.Browser->append("识别模块加载信息");*/
- bool algorithnmInitRes = loadAlgorithm.Init();
- if (algorithnmInitRes)
- {
- std::map<std::string, AlgorithmModel*> m_plugins;
- //HttpServer server;
- QMapIterator<std::string, AlgorithmModel*> iterator(loadAlgorithm.m_plugins);
- while (iterator.hasNext()) {
- iterator.next();
- m_plugins.insert(std::pair<std::string, AlgorithmModel*>(iterator.key(), iterator.value()));
- //HttpServer::m_plugins.clear();
- }
- GloabalVariables::SetAlgorithnmplugins(m_plugins);
- HttpServer::RunHttpServer();
- }
- return a.exec();
- }
- catch (const std::exception& ex)
- {
- int a = 0;
- }
-
- }
|