main.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "YunDaISASImageRecognitionService.h"
  2. #include <QtWidgets/QApplication>
  3. #include "LoadAlgorithm.h"
  4. #include <QCoreApplication>
  5. #include <thread>
  6. #include "HttpServer.h"
  7. #include <iostream>
  8. #include "GloabalVariables.h"
  9. #include <qstring.h>
  10. #include <map>
  11. #include <QtWidgets/qmessagebox.h>
  12. #include <QTextCodec>
  13. #include <QSharedMemory>
  14. #pragma execution_character_set("UTF-8")
  15. using namespace std;
  16. int main(int argc, char *argv[])
  17. {
  18. static QSharedMemory* shareMem = new QSharedMemory("SingleApp"); //创建“SingleApp”的共享内存块
  19. if (!shareMem->create(1))//创建大小1b的内存
  20. {
  21. qApp->quit(); //创建失败,说明已经有一个程序运行,退出当前程序
  22. delete shareMem;
  23. return -1;
  24. }
  25. QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));
  26. try
  27. {
  28. QMessageLogger::QMessageLogger();
  29. QApplication a(argc, argv);
  30. YunDaISASImageRecognitionService window;
  31. //w.pointer_ = &w;
  32. window.show();
  33. //依赖库目录调整
  34. QString dependecePath = QApplication::applicationDirPath() + "/AlgorithmPlugin;";
  35. //QString testPath = QApplication::applicationDirPath() + "/Test;";
  36. //QMessageBox::critical(NULL, "提示", dependecePath);
  37. QString path = dependecePath + qgetenv("Path");
  38. qputenv("Path", path.toLocal8Bit());
  39. LoadAlgorithm loadAlgorithm;
  40. /* loadAlgorithm.Browser = w.GetQTextBrowser();
  41. loadAlgorithm.Browser->append("识别模块加载信息");*/
  42. bool algorithnmInitRes = loadAlgorithm.Init();
  43. if (algorithnmInitRes)
  44. {
  45. std::map<std::string, AlgorithmModel*> m_plugins;
  46. //HttpServer server;
  47. QMapIterator<std::string, AlgorithmModel*> iterator(loadAlgorithm.m_plugins);
  48. while (iterator.hasNext()) {
  49. iterator.next();
  50. m_plugins.insert(std::pair<std::string, AlgorithmModel*>(iterator.key(), iterator.value()));
  51. //HttpServer::m_plugins.clear();
  52. }
  53. GloabalVariables::SetAlgorithnmplugins(m_plugins);
  54. HttpServer::RunHttpServer();
  55. }
  56. return a.exec();
  57. }
  58. catch (const std::exception& ex)
  59. {
  60. int a = 0;
  61. }
  62. }