Merge branch 'master' into LWQ
# Conflicts:
# ENRIT/ENRIT.rc
| | |
| | | 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; |
| | |
| | | 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; |
| | | } |
| | |
| | | } |
| | | 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; |
| | | } |
| | |
| | | |
| | | SetSlashText(GLOBAL_DEFINE::emText, _T("Image Loading Start"), RGB(0,0,0)); |
| | | |
| | | if(iSide > -1) |
| | | { |
| | | if(iSide > -1) { |
| | | |
| | | CString strGlsID, strTmp , strExt; |
| | | |
| | |
| | | |
| | | char str_filename[200]; |
| | | |
| | | for(int i = 0 ; i < 6 ; i++) |
| | | { |
| | | for(int i = 0 ; i < 6 ; i++) { |
| | | strPath.Format(_T("%s\\%s__%s_%d.%s"),strTmp,strGlsID,PANEL_SIDE[iSide],i,strExt); |
| | | USES_CONVERSION; |
| | | sprintf_s(str_filename, "%s", W2A(strPath)); |
| | | if(access(str_filename, 0) == 0) |
| | | { |
| | | nHeight = LoadFullImage(strPath,iSide,nStartY); |
| | | if(nHeight == -1) |
| | | if(access(str_filename, 0) == 0) { |
| | | nHeight = LoadFullImage(strPath, iSide, nStartY); |
| | | if (nHeight == -1) { |
| | | break; |
| | | } |
| | | |
| | | nStartY += nHeight; |
| | | } |
| | | else |
| | | else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if(pGlassData != NULL) |
| | | { |
| | | if(pGlassData != NULL) { |
| | | INS_EDGE_RESULT_INFO *pResInfo = pGlassData->GetEdgeResultInfo((DimensionDir)iSide); |
| | | if(pResInfo != NULL) |
| | | { |
| | | if(pResInfo != NULL) { |
| | | pResInfo->nGlassStartLine = 0; |
| | | pResInfo->nGlassEndLine = nStartY; |
| | | } |
| | | |
| | | } |
| | | |
| | | if(_Func != nullptr) |
| | | { |
| | | if(_Func != nullptr) { |
| | | _Func(iSide); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | |
| | | CString strGlsID, strTmp , strExt; |
| | | |
| | |
| | | g_pBase->m_strHPanelID = strGlsID; |
| | | |
| | | char str_filename[200]; |
| | | for(int i = 0; i < MAX_PANEL_SIDE * UPDN_TYPE; i++) |
| | | { |
| | | for(int i = 0; i < MAX_PANEL_SIDE * UPDN_TYPE; i++) { |
| | | strTmp = dlg.GetPathName(); |
| | | strTmp = strTmp.Left( strTmp.ReverseFind(_T('\\'))); |
| | | |
| | | nStartY = 0, nHeight = 0; |
| | | |
| | | for(int j = 0 ; j < 6 ; j++) |
| | | { |
| | | strPath.Format(_T("%s\\%s__%s_%d.%s"),strTmp,strGlsID,PANEL_SIDE[i],j,strExt); |
| | | for(int j = 0 ; j < 6 ; j++) { |
| | | strPath.Format(_T("%s\\%s__%s_%d.%s"), strTmp, strGlsID, PANEL_SIDE[i], j, strExt); |
| | | |
| | | USES_CONVERSION; |
| | | sprintf_s(str_filename, "%s", W2A(strPath)); |
| | | if(access(str_filename, 0) == 0) |
| | | { |
| | | if(access(str_filename, 0) == 0) { |
| | | nHeight = LoadFullImage(strPath,i,nStartY); |
| | | if(nHeight == -1) |
| | | if (nHeight == -1) { |
| | | break; |
| | | } |
| | | |
| | | nStartY += nHeight; |
| | | } |
| | | else |
| | | else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if(pGlassData != NULL) |
| | | { |
| | | if(pGlassData != NULL) { |
| | | INS_EDGE_RESULT_INFO *pResInfo = pGlassData->GetEdgeResultInfo((DimensionDir)i); |
| | | if(pResInfo != NULL) |
| | | { |
| | | if(pResInfo != NULL) { |
| | | pResInfo->nGlassStartLine = 0; |
| | | pResInfo->nGlassEndLine = nStartY; |
| | | } |
| | | |
| | | } |
| | | if(_Func != nullptr) |
| | | { |
| | | if(_Func != nullptr) { |
| | | _Func(i); |
| | | } |
| | | } |
| | |
| | | BEGIN_MESSAGE_MAP(CViewScanImage, CDialogEx) |
| | | ON_WM_VSCROLL() |
| | | ON_WM_HSCROLL() |
| | | |
| | | ON_WM_SHOWWINDOW() |
| | | ON_WM_TIMER() |
| | | ON_WM_PAINT() |
| | | ON_WM_MOUSEWHEEL() |
| | | ON_BN_CLICKED(IDC_BTN_LOAD1, &CViewScanImage::OnBnClickedBtnLoad1) |
| | | ON_BN_CLICKED(IDC_BTN_SAVE1, &CViewScanImage::OnBnClickedBtnSave1) |
| | | ON_BN_CLICKED(IDC_BTN_LOAD2, &CViewScanImage::OnBnClickedBtnLoad2) |
| | |
| | | ON_BN_CLICKED(IDC_BTN_SAVE4, &CViewScanImage::OnBnClickedBtnSave4) |
| | | ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_ZOOM, &CViewScanImage::OnNMCustomdrawSliderZoom) |
| | | ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_ZOOM, &CViewScanImage::OnNMReleasedcaptureSliderZoom) |
| | | ON_WM_MOUSEWHEEL() |
| | | ON_BN_CLICKED(IDC_UPDN_WIDTH1, &CViewScanImage::OnBnClickedUpdnWidth1) |
| | | |
| | | ON_BN_CLICKED(IDC_UPDN_WIDTH2, &CViewScanImage::OnBnClickedUpdnWidth2) |
| | | ON_BN_CLICKED(IDC_UPDN_WIDTH3, &CViewScanImage::OnBnClickedUpdnWidth3) |
| | | ON_BN_CLICKED(IDC_UPDN_WIDTH4, &CViewScanImage::OnBnClickedUpdnWidth4) |
| | |
| | | ON_BN_CLICKED(IDC_BTN_SAVE7, &CViewScanImage::OnBnClickedBtnSave7) |
| | | ON_BN_CLICKED(IDC_BTN_LOAD8, &CViewScanImage::OnBnClickedBtnLoad8) |
| | | ON_BN_CLICKED(IDC_BTN_SAVE8, &CViewScanImage::OnBnClickedBtnSave8) |
| | | ON_BN_CLICKED(IDC_CHECK_AUTO_SIZE, &CViewScanImage::OnBnClickedCheckAutoSize) |
| | | ON_WM_SHOWWINDOW() |
| | | ON_WM_TIMER() |
| | | ON_WM_PAINT() |
| | | ON_MESSAGE(WM_POCESS_STATUS , OnProcessStatus) |
| | | ON_BN_CLICKED(IDC_CHECK_AUTO_SIZE, &CViewScanImage::OnBnClickedCheckAutoSize) |
| | | ON_MESSAGE(WM_POCESS_STATUS , &CViewScanImage::OnProcessStatus) |
| | | ON_MESSAGE(WM_BATCH_PROCESS_NEXT, &CViewScanImage::OnBatchProcessNext) |
| | | END_MESSAGE_MAP() |
| | | |
| | | BEGIN_EVENTSINK_MAP(CViewScanImage, CDialogEx) |