ENRIT/InterfaceManager.cpp
@@ -838,13 +838,63 @@
   g_pLog->DisplayMessage(_T("write PLC Result Data : Resut %d,1_L_Theat %d,1_S_Theat %d,2_L_Theat %d,2_S_Theat %d,pResult[10]:%d"),pResult[0],pResult[1],pResult[2],pResult[3],pResult[4], pResult[10]);
   INS_PROFILE_RESULT_INFO *pProfileResult = m_GlassData.GetProfileResultInfo();
   for(int i=0;i<MAX_PROFILE_SETTING_COUNT;i++)
   {
      pProfileResult->nProfileData[i] = pHistory.nProfileDiff[i];
      /*pProfileResult->nProfileData[i] = pHistory.nProfileDiff[i];
      pProfileResult->nChamferUp[i] = pHistory.nChamferThickUp[i];
      pProfileResult->nChamferDn[i] = pHistory.nChamferThickDn[i];
      pProfileResult->nChamferDn[i] = pHistory.nChamferThickDn[i];*/
      //上报测量精度及研磨量数据到CIM
      if (i<10)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[1];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[1];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[1];
      }
      if (i<23&&i>=10)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[2];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[2];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[2];
      }if (i<33&&i>=23)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[3];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[3];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[3];
      }if (i<46&&i>=33)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[0];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[0];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[0];
      }if (i<59&&i>=46)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[4];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[4];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[4];
      }
      if (i<64&&i>=59)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[5];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[5];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[5];
      }if (i<69&&i>=64)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[7];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[7];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[7];
      }if (i<74&&i>=69)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[6];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[6];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[6];
      }if (i<79&&i>=74)
      {
         pProfileResult->nProfileData[i] = pHistory.nAVGProfileDiff[8];
         pProfileResult->nChamferUp[i] = pHistory.nAVGChamferThickUp[8];
         pProfileResult->nChamferDn[i] = pHistory.nAVGChamferThickDn[8];
      }
   }
   m_pControlInterface->SendCIMData((short*)pProfileResult,PLC_ADDR_PROFILE_JUDEMENT,MAX_PROFILE_SETTING_COUNT*3);
@@ -2363,43 +2413,44 @@
   return TRUE;
}
#define IMAGE_COMPRESSRATIO      50
#define IMAGE_COMPRESSRATIO   50
int CInterfaceManager::LoadFullImage(CString strPath,int iSide,int nStartY, CGlass_Data *pGlassData,const bool bIsDebugImg)
{
   int  nHeight = -1;
   int nHeight = -1;
   if (strPath.IsEmpty() || iSide < 0 || iSide > MAX_DIMENSION_COUNT) {
      g_pLog->DisplayMessage(_T("Load Full Image Fail(%s, %d)"), strPath, iSide);
      return nHeight;
   }
#if 0
   USES_CONVERSION;
   char str_filename[200];
   sprintf_s(str_filename, "%s", W2A(strPath));
   IplImage *Iplimg = cvLoadImage(str_filename, CV_LOAD_IMAGE_GRAYSCALE);
   LPBYTE      lpImg = NULL;
   LPBYTE lpImg = NULL;
   IplImage* Iplimg = cvLoadImage(str_filename, CV_LOAD_IMAGE_GRAYSCALE);
   g_pLog->DisplayMessage(_T("Image Size: %d x %d"), Iplimg->width, Iplimg->height);
   if(Iplimg)
   {
      if(bIsDebugImg == true) //Debug image
      {
         UINT uiReadLine = 0;
   if (Iplimg) {
      if (bIsDebugImg == true) {
         UINT uiReadLine = 0;
         //          lpImg = GetGrabBuffer((DimensionDir)iSide,nStartY);
         //          if(lpImg != NULL)
         //          {
         //             memcpy(lpImg, &Iplimg->imageData[0] , Iplimg->widthStep*Iplimg->height);
         //          }
         //
         for(int i = 0; i < Iplimg->height; i++)
         {
            lpImg = GetGrabBuffer((DimensionDir)iSide,nStartY+i);
            if(lpImg == NULL)
         //lpImg = GetGrabBuffer((DimensionDir)iSide, nStartY);
         //if (lpImg != NULL) {
         //   memcpy(lpImg, &Iplimg->imageData[0], Iplimg->widthStep * Iplimg->height);
         //}
         for (int i = 0; i < Iplimg->height; i++) {
            lpImg = GetGrabBuffer((DimensionDir)iSide, nStartY + i);
            if (lpImg == NULL)
               break;
            memcpy(lpImg, &Iplimg->imageData[uiReadLine] , Iplimg->widthStep);
            uiReadLine += Iplimg->widthStep;
            memcpy(lpImg, &Iplimg->imageData[uiReadLine], Iplimg->widthStep);
            uiReadLine += Iplimg->widthStep;
         }
         if(pGlassData != NULL)
         {
            INS_EDGE_RESULT_INFO *pResInfo =  pGlassData->GetEdgeResultInfo((DimensionDir)iSide);
            if(pResInfo != NULL)
         if (pGlassData != NULL) {
            INS_EDGE_RESULT_INFO* pResInfo = pGlassData->GetEdgeResultInfo((DimensionDir)iSide);
            if (pResInfo != NULL)
            {
               pResInfo->nGlassStartLine = 0;
               pResInfo->nGlassEndLine = Iplimg->height + nStartY;
@@ -2409,35 +2460,31 @@
         nHeight = Iplimg->height;
         cvReleaseImage(&Iplimg);
      }
      else //Full image
      {
      else {
         //Full image
         const double dRatio = 1.0 - static_cast<double>(IMAGE_COMPRESSRATIO / 100.0);
         IplImage *resizeImage = cvCreateImage(cvSize((int)(Iplimg->width/dRatio), (int)(Iplimg->height/dRatio)), IPL_DEPTH_8U, 1);
         IplImage* resizeImage = cvCreateImage(cvSize((int)(Iplimg->width / dRatio), (int)(Iplimg->height / dRatio)), IPL_DEPTH_8U, 1);
         cvResize(Iplimg, resizeImage, CV_INTER_CUBIC);
         lpImg = GetGrabBuffer((DimensionDir)iSide,nStartY);
         if(lpImg != NULL)
         {
            memcpy(lpImg, &Iplimg->imageData[0] , resizeImage->widthStep*resizeImage->height);
         lpImg = GetGrabBuffer((DimensionDir)iSide, nStartY);
         if (lpImg != NULL) {
            memcpy(lpImg, &Iplimg->imageData[0], resizeImage->widthStep * resizeImage->height);
         }
         //          UINT uiReadLine = 0;
         //          for(int i = 0; i < resizeImage->height; i++)
         //          {
         //             lpImg = GetGrabBuffer((DimensionDir)iSide,nStartY+i);
         //             if(lpImg == NULL)
         //                break;
         //             memcpy(lpImg, &resizeImage->imageData[uiReadLine] , resizeImage->widthStep);
         //             uiReadLine += resizeImage->widthStep;
         //          }
         //UINT uiReadLine = 0;
         //for (int i = 0; i < resizeImage->height; i++) {
         //   lpImg = GetGrabBuffer((DimensionDir)iSide, nStartY + i);
         //   if (lpImg == NULL)
         //      break;
         //   memcpy(lpImg, &resizeImage->imageData[uiReadLine], resizeImage->widthStep);
         //   uiReadLine += resizeImage->widthStep;
         //}
         if(pGlassData != NULL)
         {
            INS_EDGE_RESULT_INFO *pResInfo =  pGlassData->GetEdgeResultInfo((DimensionDir)iSide);
            if(pResInfo != NULL)
            {
         if (pGlassData != NULL) {
            INS_EDGE_RESULT_INFO* pResInfo = pGlassData->GetEdgeResultInfo((DimensionDir)iSide);
            if (pResInfo != NULL) {
               pResInfo->nGlassStartLine = 0;
               pResInfo->nGlassEndLine = Iplimg->height + nStartY;
            }
@@ -2449,12 +2496,72 @@
      }
      strPath.Append(_T("_OK"));
   }
   else
   else {
      strPath.Append(_T("_NG"));
   }
#else
   // 加载灰度图像
   std::string strFilename = CT2A(strPath);
   cv::Mat img = cv::imread(strFilename, cv::IMREAD_GRAYSCALE);
   g_pLog->DisplayMessage(_T("%s"),(TCHAR*)(LPCTSTR)strPath);
   if (!img.empty()) {
      g_pLog->DisplayMessage(_T("Image Size: %d x %d"), img.cols, img.rows);
   SetSlashText(GLOBAL_DEFINE::emText, strPath, RGB(0,0,0));
      if (bIsDebugImg) {
         for (int i = 0; i < img.rows; ++i) {
            LPBYTE lpImg = GetGrabBuffer((DimensionDir)iSide, nStartY + i);
            if (lpImg == NULL) {
               break;
            }
            memcpy(lpImg, img.ptr(i), img.cols);
         }
         if (pGlassData != NULL) {
            INS_EDGE_RESULT_INFO* pResInfo = pGlassData->GetEdgeResultInfo((DimensionDir)iSide);
            if (pResInfo != NULL) {
               pResInfo->nGlassStartLine = 0;
               pResInfo->nGlassEndLine = img.rows + nStartY;
            }
         }
         nHeight = img.rows;
      }
      else {
         // 按比例缩放
         const double dRatio = 1.0 - static_cast<double>(IMAGE_COMPRESSRATIO) / 100.0;
         int newWidth = static_cast<int>(img.cols / dRatio);
         int newHeight = static_cast<int>(img.rows / dRatio);
         cv::Size newSize(newWidth, newHeight);
         cv::Mat resized;
         cv::resize(img, resized, newSize, 0, 0, cv::INTER_CUBIC);
         LPBYTE lpImg = GetGrabBuffer((DimensionDir)iSide, nStartY);
         if (lpImg != NULL) {
            memcpy(lpImg, resized.data, resized.cols * resized.rows);
         }
         if (pGlassData != NULL) {
            INS_EDGE_RESULT_INFO* pResInfo = pGlassData->GetEdgeResultInfo((DimensionDir)iSide);
            if (pResInfo != NULL) {
               pResInfo->nGlassStartLine = 0;
               pResInfo->nGlassEndLine = resized.rows + nStartY;
            }
         }
         nHeight = resized.rows;
      }
      strPath.Append(_T("_OK"));
   }
   else {
      strPath.Append(_T("_NG"));
   }
#endif // 0
   g_pLog->DisplayMessage(_T("%s"), (TCHAR*)(LPCTSTR)strPath);
   SetSlashText(GLOBAL_DEFINE::emText, strPath, RGB(0, 0, 0));
   return nHeight;
}