Hi Chris,

Thanks for your answer, but I am sorry, I can't find any missing hyphen on line 23.
Qt Code:
  1. LIBS += -L"C:/Program Files/MATLAB/MATLAB Compiler Runtime/v713/extern/lib/win32/microsoft" -lmclmcrrt
To copy to clipboard, switch view to plain text mode 

My MTF.cpp file is

Qt Code:
  1. #include "MTF.h"
  2.  
  3. int MaxX = 255;
  4.  
  5.  
  6. Chart * chart;
  7. Chart::Chart(PluginAnalysisIO * IO): QObject(IO)
  8. {
  9. pluginIO = IO;
  10. // return;
  11. //QWidget * parentWidget = pluginIO->outputWidgets[0];
  12.  
  13. // QVBoxLayout *layout1 = new QVBoxLayout(parentWidget);
  14. // layout1->addWidget(plot);
  15. // QGridLayout * grid = new QGridLayout(parentWidget);
  16. // layout1->addLayout(grid);
  17. // if(!LibTI_MTFInitializeWithHandlers(DefaultErrorHandler, DefaultPrintHandler)) {
  18. if(!LibTI_MTFInitialize()){
  19. //mclTerminateApplication();
  20. QMessageBox::critical(0,"Error", "Error initializing Matlab engine!\nPlease try to restart application.");
  21. //return 2;
  22. } else{
  23. //return 0;
  24. }
  25. }
  26.  
  27. int main(int a,char** ){ return 0;}
  28.  
  29. Chart::~Chart(){
  30. LibTI_MTFTerminate();
  31. }
  32.  
  33.  
  34.  
  35. void Chart::showChart(){
  36.  
  37. QString imageFileName = pluginIO->imageFileName.toLower();
  38. QDir tempDir(QDir::tempPath());
  39. // QString tempPath = tempDir.canonicalPath();
  40. QString tempPath = tempDir.absolutePath();
  41.  
  42. QString outPrefix = tempPath+"/MTF_Images_";
  43. QString CoordinatesFile = outPrefix + "coordinates.txt";
  44. #if defined(Q_OS_WIN)
  45. outPrefix.replace("/","\\");
  46. imageFileName.replace("/","\\");
  47. CoordinatesFile.replace("/","\\");
  48. #endif
  49.  
  50. mxArray * cols = mxCreateDoubleScalar(pluginIO->rawWidth);
  51. mxArray * rows = mxCreateDoubleScalar(pluginIO->rawHeight);
  52. mxArray * phase = mxCreateDoubleScalar(pluginIO->rawColorPattern);
  53. mxArray * dcsub = mxCreateDoubleScalar(0);
  54. mxArray * R = NULL;
  55. mxArray * infilename = mxCreateString(imageFileName.toStdString().c_str());
  56. mxArray * rotate = mxCreateDoubleScalar(0);
  57. mxArray * figurePref = mxCreateString(outPrefix.toStdString().c_str());
  58. mxArray * filename_coords = mxCreateString(CoordinatesFile.toStdString().c_str());
  59. QFile::remove(pluginIO->fileNames[0]);
  60. QFile::remove(pluginIO->fileNames[1]);
  61. pluginIO->fileNames[0] = "";
  62. pluginIO->fileNames[1] = "";
  63.  
  64. FILE* coordinates = fopen(CoordinatesFile.toStdString().c_str(),"w");
  65. if (coordinates != NULL){
  66. fprintf(coordinates,"%d, %d, %d, %d\r\n",pluginIO->selectedRect.topLeft().x(), pluginIO->selectedRect.bottomRight().x(),pluginIO->selectedRect.topLeft().y(), pluginIO->selectedRect.bottomRight().y());
  67. fclose(coordinates);
  68. if (imageFileName.endsWith(".raw",Qt::CaseInsensitive)|| imageFileName.endsWith(".rawle",Qt::CaseInsensitive)){
  69. mlfRawmtfse(1, &R, infilename, cols, rows, phase, dcsub, figurePref, filename_coords);
  70. } else
  71. if (imageFileName.endsWith(".jpg",Qt::CaseInsensitive)|| imageFileName.endsWith(".bmp",Qt::CaseInsensitive)||imageFileName.endsWith(".jpeg",Qt::CaseInsensitive)){
  72. mlfImgmtfse(1, &R, infilename, rotate, figurePref, filename_coords);
  73.  
  74. } else {
  75. QMessageBox::critical(0,"Error", tr("Improper image type selected! \nAcceptable file extensions are: \n *.jpg, *.bmp, *.raw, *.rawLE") );
  76. goto end;//-->
  77. }
  78.  
  79. if (R == NULL){
  80. QString parameters = "\nFile = " + QString(mxArrayToString(infilename));
  81. parameters += " \nfigurePref = " + QString(mxArrayToString(figurePref));
  82. parameters += " \nfilename_coords = " + QString(mxArrayToString(filename_coords));
  83. parameters += " \ncols = " + QString::number(* mxGetPr(cols));
  84. parameters += " \nrows = " + QString::number(* mxGetPr(rows));
  85. parameters += " \nphase = " + QString::number(* mxGetPr(phase));
  86. parameters += " \ndcsub = " + QString::number(* mxGetPr(dcsub));
  87. QFile coordinates_txt(CoordinatesFile);
  88. coordinates_txt.open(QIODevice::ReadOnly);
  89. QString coords(coordinates_txt.readAll());
  90. coordinates_txt.close();
  91. parameters += "\nRect: "+ coords;
  92. QMessageBox::critical(0,"Error", tr("MatLab returned error!") + parameters);
  93. }else
  94. if (* mxGetPr(R) != -1){
  95. pluginIO->fileNames[0] = outPrefix+"figure_1.jpeg";
  96. pluginIO->fileNames[1] = outPrefix+"figure_2.jpeg";
  97. mxDestroyArray(R);
  98. }
  99. else if (* mxGetPr(R) == -1){
  100. QMessageBox::critical(0,"Error", tr("Cannot evaluate function! \nPlease try selecting another area!"));
  101. }
  102. else QMessageBox::critical(0,"Error", tr("Unrecognized error!"));
  103. } else {
  104. QMessageBox::critical(0,"Error",tr("Error creating coordinates file: ") + CoordinatesFile);
  105. }
  106. end:
  107. mxDestroyArray(infilename);
  108. mxDestroyArray(rotate);
  109. mxDestroyArray(figurePref);
  110. mxDestroyArray(filename_coords);
  111.  
  112. }
  113.  
  114. extern "C"
  115. {
  116. MTFSHARED_EXPORT int init(PluginAnalysisIO * IO){
  117. chart = new Chart(IO);
  118. return 0;
  119. }
  120.  
  121. MTFSHARED_EXPORT void show(){
  122. chart->showChart();
  123. }
  124. }
  125.  
  126. int DefaultPrintHandler(const char *s)
  127. {
  128. return strlen(s);//->
  129. return mclWrite(1 /* stdout */, s, sizeof(char)*strlen(s));
  130. }
  131.  
  132. int DefaultErrorHandler(const char *s)
  133. {
  134. int written = 0;
  135. size_t len = 0;
  136. len = strlen(s);
  137.  
  138. return len;//->
  139. written = mclWrite(2 /* stderr */, s, sizeof(char)*len);
  140. if (len > 0 && s[ len-1 ] != '\n')
  141. written += mclWrite(2 /* stderr */, "\n", sizeof(char));
  142. return written;
  143. }
To copy to clipboard, switch view to plain text mode