Esempio n. 1
0
void CSpotsMainDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
	if (img_on_show.rows > 0)//有图才继续走
	{
		cv::Point xy = getMouseXY();
		DrawPicToHDC(bigImg_cache, IDC_IMG_BIG);
		DrawPicToHDC(historyImg_cache, IDC_IMG_HISTORY);
		DrawPicToHDC(SampleImg_cache, IDC_MAIN_SHOWSAMPLE);
		if (xy.x != -1)   //鼠标是否在控件范围之内
		{
			int x = xy.x;
			int y = xy.y;
			if (p_contrller->PauseFlag)//只有暂停的时候能缩放
			{
				////进入放大模式
				//if (zoom == 8)
				//{
				//	zoom = 1;
				//	ShowImgROI(x, y);
				//	point_StartUpLeft = cv::Point(x, y);//记录ROI左上点坐标
				//}
				//else//取消放大模式
				//{
				//	zoom = 8;
				//	ShowImgROI();
				//}
				//else//通过鼠标点击,切换ROI显示的范围
				{
					CPoint mpoint;
					::GetCursorPos(&mpoint);
					point_LButtonDown = mpoint;//记录鼠标按下点坐标

					CRect rect;
					GetDlgItem(IDC_IMG_BIG)->GetClientRect(rect);
					GetDlgItem(IDC_IMG_BIG)->ClientToScreen(rect);//函数是将你打开的APP中客户区的坐标点信息转换为整个屏幕的坐标
					x -= (mpoint.x - rect.left)*zoom;
					y -= (mpoint.y - rect.top)*zoom;
					point_StartUpLeft = cv::Point(x, y);//记录ROI左上点坐标

					//stringstream ss;
					//ss << point_StartUpLeft.x << "," << point_StartUpLeft.y << endl;
					//MFCConsole::Output(ss.str());
					//ShowImgROI(x, y);
				}
			}
		}
	}
	CDialogEx::OnLButtonDown(nFlags, point);
}
Esempio n. 2
0
void CTestModeDlg::OnBnClickedBtnStartObserve()
{

    CString pathWild = m_strTestPicFolderPath + "\\*.jpg";
    struct _finddata_t c_file;
    long hFile;

    if( (hFile = _findfirst( LPCTSTR(pathWild), &c_file )) == -1L )
    {
        return;
    }
    else
    {
        do {
            CString str = m_strTestPicFolderPath;
            str += "\\";
            str += c_file.name;
            m_curTestImage = cvLoadImage((LPSTR)(LPCTSTR)str);
            PMatchShapeContextResult pMatchShpaeContextResult = m_pCharMatch->Match(m_curTestImage);
            if(pMatchShpaeContextResult != null)
            {
                //InertSCTemplateNode(c_file.name, pShpaeContextResult);
                char trainPicPath[1024];
                strcpy(trainPicPath, m_pCharRecoHelper->GetTemplatePath());
                strcat(trainPicPath, pMatchShpaeContextResult->firstMatchResult);
                m_curTrainImage = cvLoadImage(trainPicPath);

                DrawPicToHDC(m_curTestImage, IDC_STATIC_TEST_PIC);
                DrawPicToHDC(m_curTrainImage, IDC_STATIC_TRAIN_PIC);
                Sleep(100);


                cvReleaseImage(&m_curTestImage);
                cvReleaseImage(&m_curTrainImage);

            }

        } while (_findnext(hFile, &c_file) == 0);

    }
    _findclose(hFile);
}
Esempio n. 3
0
void CSpotsMainDlg::ShowImgROI(int x, int y)
{
	if (img_on_show.rows > 0)//有图才继续走
	{
		if (zoom == 8)
		{
			DrawPicToHDC(img_on_show, IDC_IMG_BIG);
			CSliderCtrl *pSlidCtrl = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_IMG_X);
			pSlidCtrl->EnableWindow(0);
			pSlidCtrl = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_IMG_Y);
			pSlidCtrl->EnableWindow(0);
			pSlidCtrl = 0;
		}
		else
		{
			//计算ROI宽度
			CRect rect;
			GetDlgItem(IDC_IMG_BIG)->GetClientRect(rect);
			GetDlgItem(IDC_IMG_BIG)->ClientToScreen(rect);//函数是将你打开的APP中客户区的坐标点信息转换为整个屏幕的坐标
			int idc_width = rect.right - rect.left;//图像控件宽
			int idc_height = rect.bottom - rect.top;//图像控件高
			//根据放大系数转换ROI长宽
			int zoom_width = zoom * idc_width;//实际ROI选取的宽度
			int zoom_height = zoom * idc_height;
			if (zoom_width >= img_on_show.cols || zoom_height >= img_on_show.rows)//若放大系数过小,则显示全图
			{
				zoom = 8;
				ShowImgROI();
				return;
			}

			//设置滚动条
			CSliderCtrl *pSlidCtrlX = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_IMG_X);
			CSliderCtrl *pSlidCtrlY = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_IMG_Y);
			pSlidCtrlX->EnableWindow(1);
			pSlidCtrlY->EnableWindow(1);
			pSlidCtrlX->SetRange(0, img_on_show.size().width - 1 - zoom_width);
			pSlidCtrlY->SetRange(0, img_on_show.size().height - 1 - zoom_height);
			if (x == 0 && y == 0)//如果调用时没有输入坐标,则从slider读取
			{
				x = pSlidCtrlX->GetPos();
				y = pSlidCtrlY->GetPos();
			}
			else//如果调用时设置了坐标,则赋值给slider
			{
				pSlidCtrlX->SetPos(x);
				pSlidCtrlY->SetPos(y);
			}
			pSlidCtrlX = 0;
			pSlidCtrlY = 0;

			//生成ROI
			{
				//防止越界
				if (x < 0)x = 0;
				if (y < 0)y = 0;
				if (x + zoom_width > img_on_show.cols)
					x = img_on_show.cols - zoom_width;
				if (y + zoom_height > img_on_show.rows)
					y = img_on_show.rows - zoom_height;
				//ROI
				cv::Mat roi = img_on_show(cv::Rect(x, y, zoom_width, zoom_height));
				DrawPicToHDC(roi, IDC_IMG_BIG);
				//更新文字描述信息
				refreshPosInfo();
			}
		}
	}
}
Esempio n. 4
0
void CSpotsMainDlg::ShowLogImg(cv::Mat img)
{
	img_on_log = img;
	historyImg_cache = img;
	DrawPicToHDC(img, IDC_IMG_HISTORY);
}
Esempio n. 5
0
void CSpotsMainDlg::ShowBigImg(cv::Mat img)
{
	img_on_show = img;
	bigImg_cache = img;
	DrawPicToHDC(img, IDC_IMG_BIG);
}
Esempio n. 6
0
void CSpotsMainDlg::ShowSampleImg(cv::Mat img)
{
	img_on_show = img;
	SampleImg_cache = img;
	DrawPicToHDC(img, IDC_MAIN_SHOWSAMPLE);
}