示例#1
0
void DIANMING::draw_Image(CDC* pDC, HDC hDC, Mat img, CRect rect)
{
	int rw = rect.right - rect.left;// 求出图片控件的宽和高
	int rh = rect.bottom - rect.top;

	int iw = img.size().width;// 读取图片的宽和高
	int ih = img.size().height;
	if (rw > iw && rh > ih)
	{

	}
	else
	{
		CvSize size;
		size.height = rh;
		size.width = rw;
		resize(img, img, size);
		iw = rw;
		ih = rh;
	}
	int tx = (int)(rw - iw) / 2;// 使图片的显示位置正好在控件的正中
	int ty = (int)(rh - ih) / 2;

	SetRect(rect, tx, ty, tx + iw, ty + ih);
	CvvImage cimg;
	IplImage img1 = img;
	cimg.CopyOf(&img1);
	cimg.DrawToHDC(hDC, &rect);


}
示例#2
0
void MyTestDialog::DrawPicToHDC(cv::Mat& img, UINT ID)
{
	//清空
	CStatic* pStatic = (CStatic*)GetDlgItem(ID);
	pStatic->SetBitmap(NULL);
	CRect rect;
	pStatic->GetClientRect(&rect);
	pStatic->GetDC()->FillSolidRect(rect.left ,rect.top ,rect.Width(),rect.Height(), RGB(240, 240, 240));
	////

	CDC* pDC = GetDlgItem(ID)->GetDC();
	HDC hDC = pDC->GetSafeHdc();

	//调整大小
	////////
	float widthRatio = (float)rect.Width() / img.cols;
	float heightRatio = (float)rect.Height() / img.rows;
	float resRatio = widthRatio < heightRatio ? widthRatio: heightRatio;
	int resWidth = img.cols * resRatio;
	int resHeight = img.rows * resRatio;
	cv::resize(img, img, cv::Size(resWidth, resHeight));
	CRect drawRect;
	drawRect.SetRect(rect.TopLeft().x, rect.TopLeft().y, rect.TopLeft().x + img.cols - 1, rect.TopLeft().y + img.rows - 1);
	///////
	IplImage* tmpimg = &img.operator IplImage();
	CvvImage iimg;
	iimg.CopyOf(tmpimg);
	iimg.DrawToHDC(hDC, &drawRect);
	ReleaseDC(pDC);
	iimg.Destroy();
}
void CRenderCenterDlg::OnBnClickedInputmuban()
{
	// TODO: 在此添加控件通知处理程序代码
	string tstring;
	CString tFileName;
	CFileDialog tDlg(TRUE);
	if(tDlg.DoModal()==IDOK)
	{
		tFileName=tDlg.GetPathName();
		tstring=wstring2string(tFileName.GetBuffer(0));
	}
	imgtarget=imread(tstring,1);
	if(!imgtarget.data)
	{
		MessageBox(TEXT("error"),TEXT("no image loaded!"),MB_OK);
		return;
	}
	CWnd *pWnd=GetDlgItem(IDC_MUBAN);
	CDC *pDC=pWnd->GetDC();
	HDC hDC=pDC->GetSafeHdc();
	IplImage img=imgtarget;
	CvvImage cimg;
	cimg.CopyOf(&img);
	CRect rect;
	GetDlgItem(IDC_MUBAN)->GetClientRect(&rect);
	cimg.DrawToHDC(hDC,&rect);
}
示例#4
0
void CAntimonyDlg::showImage(IplImage *image, UINT ID)    // ID 是Picture Control控件的ID号
{
	CvSize ImgSize;
	IplImage *theimg;
	ImgSize.width = picrect.Width();
	ImgSize.height = picrect.Height();
	theimg = cvCreateImage(ImgSize, IPL_DEPTH_8U, 3);
	IplImage *image2 = image;
	resize_image(image2, theimg);

	CDC *pDC = GetDlgItem(ID)->GetDC();
	HDC hDC = pDC->GetSafeHdc();

	int rw = picrect.right - picrect.left;
	int rh = picrect.bottom - picrect.top;
	int iw = theimg->width;
	int ih = theimg->height;
	int tx = (int)(rw - iw) / 2;
	int ty = (int)(rh - ih) / 2;
	SetRect(picrect, tx, ty, tx + iw, ty + ih);
	CvvImage cimg;
	cimg.CopyOf(theimg); // 复制图片
	cimg.DrawToHDC(hDC, &picrect); // 将图片绘制到显示控件的指定区域内
	ReleaseDC(pDC);
}
void CRenderCenterDlg::OnBnClickedRate()
{
	// TODO: 在此添加控件通知处理程序代码
	if(img1.size()!=img2.size())
	{
		MessageBox(TEXT("Two images are not the same size!"),TEXT("error"),MB_OK);
		return;
	}
	RateBlending lp;
	Mat_<Vec3f> l; img1.convertTo(l,CV_32F,1.0/255.0);//Vec3f表示有三个通道,即 l[row][column][depth]  
	Mat_<Vec3f> r; img2.convertTo(r,CV_32F,1.0/255.0);
	Mat_<float> m(l.rows,l.cols,0.0);
	m(Range::all(),Range(0,m.cols/2)) = 1.0; 
	Mat_<Vec3f> blend =lp.RateBlend(l, r, m);
	blend.convertTo(imgfusion,CV_8UC3,255);

	CWnd *pWnd=GetDlgItem(IDC_IMGFUSION);
	CDC *pDC=pWnd->GetDC();
	HDC hDC=pDC->GetSafeHdc();
	IplImage img=imgfusion;
	CvvImage cimg;
	cimg.CopyOf(&img);
	CRect rect;
	GetDlgItem(IDC_IMGFUSION)->GetClientRect(&rect);
	cimg.DrawToHDC(hDC,&rect);
}
示例#6
0
void CMFCCapView::DrawPicToHDC(IplImage *img, UINT ID)
{
	CDC *pDC = GetDlgItem(ID)->GetDC();
	HDC hDC= pDC->GetSafeHdc(); 
	CRect rect;
	GetDlgItem(ID)->GetClientRect(&rect);
	CvvImage cimg;
	cimg.CopyOf(img);
	cimg.DrawToHDC(hDC,&rect);
	ReleaseDC(pDC);
} 
void MFC_SelectCartoonDlg::DrawPicToHDC(IplImage *img, UINT ID)
{
	CDC *pDC = GetDlgItem(ID)->GetDC();
	HDC hDC= pDC->GetSafeHdc();
	CRect rect;
	GetDlgItem(ID)->GetClientRect(&rect);
	CvvImage cimg;
	cimg.CopyOf( img ); // 复制图片
	cimg.DrawToHDC( hDC, &rect ); // 将图片绘制到显示控件的指定区域内
	ReleaseDC( pDC );
}
void CRenderCenterDlg::OnBnClickedHisfusion()
{
	// TODO: 在此添加控件通知处理程序代码
	if(img1.size()!=img2.size())
	{
		MessageBox(TEXT("Two images are not the same size!"),TEXT("error"),MB_OK);
		return;
	}
	Mat hsi1,hsi2,hsi3,p1,p2;
	p1=img1;
	p2=img2;
	hsi1.create(p1.rows,img1.cols,CV_8UC3);
	hsi2.create(p2.rows,img2.cols,CV_8UC3);
	hsi3=hsi1;
	rgb2hsi(p1,hsi1);
	rgb2hsi(p2,hsi2);
	int n1=hsi1.rows;
	int nc=hsi1.cols;
	if(hsi1.isContinuous())
	{
		nc=nc*n1;
		n1=1;
	}
	for(int i=0;i<n1;i++)
	{
		uchar *pl=hsi1.ptr<uchar>(i);
		uchar *pr=hsi2.ptr<uchar>(i);		
		for(int j=0;j<nc;j++)
		{
			uchar t;
			t=pl[3*j+2];
			pl[3*j+2]=pr[3*j+2];
			pr[3*j+2]=t;

		}
	}
	hsi2rgb(hsi1,p1);
	hsi2rgb(hsi2,p2);

	double alpha=0.5;
	double beta=(1.0-alpha);	
	addWeighted(p1,alpha,p2,beta,0.0,imgfusion);

	CWnd *pWnd=GetDlgItem(IDC_IMGFUSION);
	CDC *pDC=pWnd->GetDC();
	HDC hDC=pDC->GetSafeHdc();
	IplImage img=imgfusion;
	CvvImage cimg;
	cimg.CopyOf(&img);
	CRect rect;
	GetDlgItem(IDC_IMGFUSION)->GetClientRect(&rect);
	cimg.DrawToHDC(hDC,&rect);
}
示例#9
0
// CustomDialog 消息处理程序
void CustomDialog::DrawPicToHDC(IplImage *img, UINT ID)
{
	CDC *pDC =	GetDlgItem(ID)->GetDC();
	HDC hDC= pDC->GetSafeHdc();
	CRect rect;
	GetDlgItem(ID)->GetClientRect(&rect);
	CvvImage cimg;
	cimg.CopyOf(img); // 复制图片
	cimg.DrawToHDC(hDC, &rect); // 将图片绘制到显示控件的指定区域内
	cimg.Destroy();
	ReleaseDC(pDC);
}
示例#10
0
//set default contrast value 2.2
void CBrightDlg::OnBnClickedButton1()
{
	int alpha = _ttoi(m_SliderValue);// transfer cstring to int
	Mat temp = autoBrightContrast(m_mat, 2.2, alpha);
	IplImage img = temp;
	CvvImage cimg;
	cimg.CopyOf(&img);

	CPrevDlg dlg;
	dlg.m_image = cimg;
	dlg.DoModal();
	waitKey(0);
	CDialogEx::OnOK();
}
void CHandGestureRecognitionSystemDlg::PlayImage(Mat& image, int ID, CRect& rect)
{
    // get HDC
    CDC* pDC = GetDlgItem(ID)->GetDC(); // 获得显示控件的 DC
    HDC hDC = pDC ->GetSafeHdc();       // 获取HDC(设备句柄)进行绘图操作
    // MAT TO IplImage
    IplImage img = IplImage(image);
    // IplImage TO CvvImage
    CvvImage cimg;
    cimg.CopyOf(&img);                  // 复制图片
    cimg.DrawToHDC(hDC, &rect);         // 将图片绘制到显示控件的指定区域
    // release CDC
    ReleaseDC(pDC);
}
示例#12
0
void CSpotsMainDlg::DrawPicToHDC(cv::Mat& img, UINT ID)
{
	IplImage image(img); //原始图像
	//if (hDC == NULL)
	{
		p_DC = GetDlgItem(ID)->GetDC();
		hDC = p_DC->GetSafeHdc();
	}
	CRect rect;
	GetDlgItem(ID)->GetClientRect(&rect);
	CvvImage cimg;
	cimg.CopyOf(&image); // 复制图片
	cimg.DrawToHDC(hDC, &rect); // 将图片绘制到显示控件的指定区域内
	ReleaseDC(p_DC);
}
示例#13
0
void  CvvImage::CopyOf( CvvImage& image, int desired_color )
{
   IplImage* img = image.GetImage();
   if( img )
   {
      CopyOf( img, desired_color );
   }
}
void CCharTrainDlg::DrawPicToHDC(IplImage* img, UINT ID)
{
	CDC *pDC = GetDlgItem(ID)->GetDC();
	HDC hDC = pDC->GetSafeHdc();
	CRect rect;
	GetDlgItem(ID)->GetClientRect(&rect);

	if (img!=NULL)
	{
		CvvImage cimg;

	cimg.CopyOf(img,3);
	cimg.DrawToHDC(hDC,&rect);

	}
	ReleaseDC(pDC);
}
示例#15
0
//---------------------------------------------------------------------
void ExtPicture::Draw(CDC *pDC)
{
	CRect myrect;
	GetClientRect(&myrect);	//取得客户区尺寸
	if(m_img.data==NULL)
	{
		pDC->Rectangle(&myrect);
		return;
	}

	else 
	{
		IplImage* img=&(IplImage)(m_img);		//将图像转换为IplImage格式,共用同一个内存(浅拷贝)
		CvvImage iimg;								//创建一个CvvImage对象
		iimg.CopyOf(img);

		HDC hDC=pDC->GetSafeHdc();	
		iimg.DrawToHDC(hDC,&myrect);
	}
}
示例#16
0
void LeoPicture_For_AddModel::Draw(CDC *pDC)
{
	if (m_img.empty())
		return;

	cv::Mat showMat=m_img.clone();
	//for (int i = 0; i < ptr_models.size(); i++)
	//{
	//	//int a = ptr_models[i]->m_region.width;
	//	//int b = RectRoi.width;



	//	cv::putText(showMat,ptr_models[i]->m_Describe,cv::Point(ptr_models[i]->m_region.x,ptr_models[i]->m_region.y),CV_FONT_HERSHEY_SIMPLEX,1.5,Scalar(0,0,255));
	//	cv::rectangle(showMat,ptr_models[i]->m_region,cv::Scalar(0,0,255),1);
	//	if(ptr_models[i]->getSmallRegion().area()>0)
	//	{
	//		cv::rectangle(showMat,ptr_models[i]->getSmallRegion(),cv::Scalar(0,255,255),1);
	//	}
	//}


	cv::Mat showImage(showMat,RectRoi);

	CRect myrect;
	GetClientRect(&myrect);	//取得客户区尺寸

	IplImage* img=&(IplImage)showImage;		//将图像转换为IplImage格式,共用同一个内存(浅拷贝)
	CvvImage iimg;								//创建一个CvvImage对象
	iimg.CopyOf(img);

	HDC hDC=pDC->GetSafeHdc();	
	iimg.DrawToHDC(hDC,&myrect);
	

	if(m_RectTracker!=NULL)
		m_RectTracker->Draw(pDC);

	//ReleaseDC( pDC );
}
示例#17
0
/////////////////////////////////////////////////////////////////////////////
// CFaceEncryptView message handlers
void CFaceEncryptView::ShowImage( IplImage* img, UINT ID )    // ID 是Picture Control控件的ID号
{
	CWnd *p=GetDlgItem( ID );
	if(p==NULL)
		AfxMessageBox("GetDlgItem( ID )  failed!!!");
    CDC* pDC = GetDlgItem( ID ) ->GetDC();        // 获得显示控件的 DC
    HDC hDC = pDC ->GetSafeHdc();                // 获取 HDC(设备句柄) 来进行绘图操作
    CRect rect;
    GetDlgItem(ID) ->GetClientRect( &rect );
    int rw = rect.right - rect.left;            // 求出图片控件的宽和高
    int rh = rect.bottom - rect.top;
    int iw = img->width;                        // 读取图片的宽和高
    int ih = img->height;
    int tx = (int)(rw - iw)/2;                    // 使图片的显示位置正好在控件的正中
    int ty = (int)(rh - ih)/2;
    SetRect( rect, tx, ty, tx+iw, ty+ih );

    CvvImage cimg;
    cimg.CopyOf( img );                            // 复制图片
    cimg.DrawToHDC( hDC, &rect );                // 将图片绘制到显示控件的指定区域内
    ReleaseDC( pDC );
}
示例#18
0
void TestCV2()
{
		const char *pszImg = "E:\\02C-2C\\64965输出\\64965_2.tif";
		const char *pszImg2 = "C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\桌面背景\\PrimulaRed.jpg";
		const char *pszImg3 = "D:\\data717\\原始影像\\ZY02C_HRC_E116.7_N40.0_20120201_L1C0000161390.tiff";
		CvvImage cvimg;
		CvRect rect = cvRect(100,100,500,500);
		cvimg.LoadRect(pszImg2,1,rect);
		//cvNamedWindow("TestOpenCVandGdalWnd",CV_WINDOW_AUTOSIZE);
		//cvimg.Show("TestOpenCVandGdalWnd");
		
		IplImage * img =cvimg.GetImage();
		if (img ==NULL)
		{
			printf("构建图像失败!");
			return;
		}
	
		cvNamedWindow("TestOpenCVandGdalWnd",CV_WINDOW_AUTOSIZE);
		cvShowImage("TestOpenCVandGdalWnd",img);
		cvWaitKey();
}
示例#19
0
void CVEDIODS::showImage(Mat &img, UINT ID, CDC* pDC, CRect &rect)
{
	pDC->GetWindow()->GetWindowRect(&rect);
//	CDC* pDC = GetDlgItem(ID)->GetDC();// 获得显示控件的 DC
	HDC hDC = pDC->GetSafeHdc();// 获取 HDC(设备句柄) 来进行绘图操作

//	CRect rect;
//	GetDlgItem(ID)->GetClientRect(&rect);
	int rw = rect.right - rect.left;// 求出图片控件的宽和高
	int rh = rect.bottom - rect.top;

	int iw = img.size().width;// 读取图片的宽和高
	int ih = img.size().height;
	if (rw > iw && rh > ih)
	{
		
	}
	else
	{
		CvSize size;
		size.height = rh;
		size.width = rw;
		resize(img, img, size);
		iw = rw;
		ih = rh;
	}
	int tx = (int)(rw - iw) / 2;// 使图片的显示位置正好在控件的正中
	int ty = (int)(rh - ih) / 2;

	SetRect(rect, tx, ty, tx + iw, ty + ih);


	CvvImage cimg;
	IplImage img1 = img;
	cimg.CopyOf(&img1);
	cimg.DrawToHDC(hDC, &rect);
	ReleaseDC(pDC);
}
示例#20
0
文件: EVUtil.cpp 项目: douzsh/douzsh
void EVUtil::ShowImage( CDialog* pDlg, IplImage* img, UINT ID, CPoint* ptTL )
{
	if(!pDlg->GetSafeHwnd()  || !pDlg->GetDlgItem( ID ))
	{
		return;
	}
	if(!img)
	{
		return;
	}
	CDC* pDC = pDlg->GetDlgItem( ID ) ->GetDC(); 
	if (!pDC )
	{
		return ;
	}
	HDC hDC = pDC ->GetSafeHdc();     

	CRect rect;
	pDlg->GetDlgItem(ID) ->GetClientRect( &rect );
	int rw = rect.right - rect.left;     
	int rh = rect.bottom - rect.top;
	int iw = img->width;                  
	int ih = img->height;
	int tx = (int)(rw - iw)/2;   
	int ty =(int)(rh - ih)/2;
	SetRect( rect, tx, ty, tx+iw, ty+ih );
	if ( ptTL )
	{
		ptTL->x=tx;
		ptTL->y=ty;
	}

	CvvImage cimg;
	cimg.CopyOf( img );    
	cimg.DrawToHDC( hDC, &rect );  

	pDlg->ReleaseDC( pDC );
}
void CRenderCenterDlg::OnBnClickedEnhance()
{
	// TODO: 在此添加控件通知处理程序代码
	if(!img1.data)
	{
		MessageBox(TEXT("no image loaded!"),TEXT("error"),MB_OK);
		return;
	}
	vector<Mat> splitBGR(img1.channels());
	split(img1,splitBGR);
	for(int i=0;i<img1.channels();i++)
		equalizeHist(splitBGR[i],splitBGR[i]);
	merge(splitBGR,img1);	
	CWnd *pWnd=GetDlgItem(IDC_IMGA);
	CDC *pDC=pWnd->GetDC();
	HDC hDC=pDC->GetSafeHdc();
	IplImage img=img1;
	CvvImage cimg;
	cimg.CopyOf(&img);
	CRect rect;
	GetDlgItem(IDC_IMGA)->GetClientRect(&rect);
	cimg.DrawToHDC(hDC,&rect);
}
void CRenderCenterDlg::OnBnClickedRegistry()
{
	// TODO: 在此添加控件通知处理程序代码
	if(!img1.data||!img2.data)
	{
		MessageBox(TEXT("no image loaded!"),TEXT("error"),MB_OK);
		return;
	}
	cv::initModule_nonfree();
	FeatureMatch *sp=NULL;
	bool isWarpPerspective = 0;
	double ransacReprojThreshold = 3;
	Ptr<FeatureDetector> detector = FeatureDetector::create( "SIFT");
	Ptr<DescriptorExtractor> descriptorExtractor = DescriptorExtractor::create( "SIFT");
	Ptr<DescriptorMatcher> descriptorMatcher = DescriptorMatcher::create( "FlannBased");//"BruteForce");
	int mactherFilterType = sp->getMatcherFilterType( "CrossCheckFilter");
	bool eval = false;
	vector<KeyPoint> keypoints1;
	detector->detect( img1, keypoints1 );
	Mat descriptors1;
	descriptorExtractor->compute( img1, keypoints1, descriptors1 );
	RNG rng = theRNG();
	img3=sp->doIteration( img1, img2, isWarpPerspective, keypoints1, descriptors1,
		detector, descriptorExtractor, descriptorMatcher, mactherFilterType, eval,
		ransacReprojThreshold, rng );
	img1=img3;
	CWnd *pWnd=GetDlgItem(IDC_IMGTURN);
	CDC *pDC=pWnd->GetDC();
	HDC hDC=pDC->GetSafeHdc();
	IplImage img=img1;
	CvvImage cimg;
	cimg.CopyOf(&img);
	CRect rect;
	GetDlgItem(IDC_IMGTURN)->GetClientRect(&rect);
	cimg.DrawToHDC(hDC,&rect);
}
void CRenderCenterDlg::OnBnClickedImagefusion()
{
	// TODO: 在此添加控件通知处理程序代码
	if(img1.size()!=img2.size())
	{
		MessageBox(TEXT("Two images are not the same size!"),TEXT("error"),MB_OK);
		return;
	}
	double alpha=0.6;
	double beta=(1.0-alpha);

	addWeighted(img1,alpha,img2,beta,0.0,imgfusion);
	

	CWnd *pWnd=GetDlgItem(IDC_IMGFUSION);
	CDC *pDC=pWnd->GetDC();
	HDC hDC=pDC->GetSafeHdc();
	IplImage img=imgfusion;
	CvvImage cimg;
	cimg.CopyOf(&img);
	CRect rect;
	GetDlgItem(IDC_IMGFUSION)->GetClientRect(&rect);
	cimg.DrawToHDC(hDC,&rect);
}
示例#24
0
void MyTestDialog::DrawPicToHDC(IplImage* img, UINT ID)
{
	//清空
	CStatic* pStatic = (CStatic*)GetDlgItem(ID);
	//pStatic->SetBitmap(NULL);
	CDC* pDC = GetDlgItem(ID)->GetDC();
	CRect rect;
	pStatic->GetClientRect(&rect);
	//pStatic->GetDC()->FillSolidRect(rect.left ,rect.top ,rect.Width(),rect.Height(), RGB(240, 240, 240));
	////
	HDC hDc = pDC->GetSafeHdc();
	//CRect rect;
	//GetDlgItem(ID)->GetClientRect(&rect);
	float widthRatio = (float)rect.Width() / img->width;
	float heightRatio = (float)rect.Height() / img->height;
	float resRatio = widthRatio < heightRatio ? widthRatio: heightRatio;
	int resWidth = img->width * resRatio;
	int resHeight = img->height * resRatio;
	IplImage* img2=cvCreateImage(cvSize(resWidth, resHeight),img->depth, img->nChannels);
	cvResize(img, img2, CV_INTER_NN);

	img = img2;
	CvvImage cimg;
	cimg.CopyOf(img);
	CRect drawRect;
	drawRect.SetRect(rect.TopLeft().x, rect.TopLeft().y, rect.TopLeft().x + img->width - 1, rect.TopLeft().y + img->height - 1);
	cimg.DrawToHDC(hDc, &drawRect);
	ReleaseDC(pDC);
	//cv::imshow("view", img);
	//path1
	//cvShowImage("view",img);

	//path2
//	著作权归作者所有。
//		商业转载请联系作者获得授权,非商业转载请注明出处。
//		作者:匿名用户
//链接:http://www.zhihu.com/question/29611790/answer/45053299
//	来源:知乎

	//cv::Mat img2;
	//cv::Mat img1(img);
	//
	//CRect rect;
	//GetDlgItem(ID)->GetClientRect(&rect);
	//cv::Rect dst(rect.left,rect.top,rect.right,rect.bottom);
	//cv::resize(img1,img2,cv::Size(rect.Width(),rect.Height()));
	//imshow("view",img2);
	//unsigned int m_buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256];	
	//BITMAPINFO* m_bmi = (BITMAPINFO*) m_buffer;
	//BITMAPINFOHEADER* m_bmih = &(m_bmi->bmiHeader);
	//memset(m_bmih, 0, sizeof(*m_bmih));
	//m_bmih->biSize = sizeof(BITMAPINFOHEADER);
	//m_bmih->biWidth = img2.cols;
	//m_bmih->biHeight = -img2.rows;           // 在自下而上的位图中 高度为负
	//m_bmih->biPlanes = 1;
	//m_bmih->biCompression = BI_RGB;
	//m_bmih->biBitCount = 8 * img2.channels();

	//CDC *pDC = GetDlgItem(ID)->GetDC();	
	//::StretchDIBits(
	//	pDC->GetSafeHdc(),
	//	0, 0, rect.Width(), rect.Height(),
	//	0, 0, rect.Width(), rect.Height(),
	//	img2.data,
	//	(BITMAPINFO*) m_bmi,
	//	DIB_RGB_COLORS,
	//	SRCCOPY
	//	);
	//ReleaseDC(pDC);

}
void CRenderCenterDlg::OnBnClickedTarget()
{
	// TODO: 在此添加控件通知处理程序代码
	if(!imgtarget.data)
	{
		MessageBox(TEXT("no target image loaded!"),TEXT("error"),MB_OK);
		_Global_Obj_Ptr->OnBnClickedStop();
		return;
	}
	SiftFeatureDetector siftdtc;
	vector<KeyPoint>kp1,kp2;
	siftdtc.detect(imgtarget,kp1);
	siftdtc.detect(imgfusion,kp2);

	SiftDescriptorExtractor extractor;
	Mat descriptor1,descriptor2;
	extractor.compute(imgtarget,kp1,descriptor1);
	extractor.compute(imgfusion,kp2,descriptor2);

	BruteForceMatcher<L2<float>> matcher;
	vector<DMatch> matches;
	matcher.match(descriptor1,descriptor2,matches);

	int i,j;
	int pointcount=(int)matches.size();
	Mat point1(pointcount,2,CV_32F);
	Mat point2(pointcount,2,CV_32F);
	Point2f point;
	for(i=0;i<pointcount;i++)
	{
		point=kp1[matches[i].queryIdx].pt;
		point1.at<float>(i,0)=point.x;
		point1.at<float>(i,1)=point.y;

		point=kp2[matches[i].trainIdx].pt;
		point2.at<float>(i,0)=point.x;
		point2.at<float>(i,1)=point.y;
	}
	Mat m_fundamental;
	vector<uchar> m_ransacstatus;
	m_fundamental=findFundamentalMat(point1,point2,m_ransacstatus,FM_RANSAC);

	float hhh[9];
	for(i=0;i<9;i++)
		hhh[i]=0;

	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			hhh[i*3+j]=m_fundamental.ptr<float>(i)[j];
		}
	}
	int outlinercount=0;
	for(i=0;i<pointcount;i++)
	{
		if(m_ransacstatus[i]==0)
		{
			outlinercount++;
		}
	}

	vector<Point2f> m_leftinliner;
	vector<Point2f> m_rightinliner;
	vector<DMatch> m_inlinermatches;
	int inlinercount=pointcount-outlinercount;
	m_inlinermatches.resize(inlinercount);
	m_leftinliner.resize(inlinercount);
	m_rightinliner.resize(inlinercount);
	inlinercount=0;
	for(i=0;i<pointcount;i++)
	{
		if(m_ransacstatus[i]!=0)
		{
			m_leftinliner[inlinercount].x=point1.at<float>(i,0);
			m_leftinliner[inlinercount].y=point1.at<float>(i,1);
			m_rightinliner[inlinercount].x=point2.at<float>(i,0);
			m_rightinliner[inlinercount].y=point2.at<float>(i,1);
			m_inlinermatches[inlinercount].queryIdx=inlinercount;
			m_inlinermatches[inlinercount].trainIdx=inlinercount;
			inlinercount++;
		}
	}
	vector<KeyPoint> key1(inlinercount);
	vector<KeyPoint> key2(inlinercount);
	KeyPoint::convert(m_leftinliner,key1);
	KeyPoint::convert(m_rightinliner,key2);

	Mat H=findHomography(m_leftinliner,m_rightinliner,CV_RANSAC);
	std::vector<Point2f> obj_corners(4);
    obj_corners[0]=cv::Point(0,0);obj_corners[1]=cv::Point(imgtarget.cols,0);
    obj_corners[2]=cv::Point(imgtarget.cols,imgtarget.rows);obj_corners[3]=cv::Point(0,imgtarget.rows);
	std::vector<Point2f>scene_corners(4);
	perspectiveTransform(obj_corners,scene_corners,H);
	rectangle(imgfusion,scene_corners[0],scene_corners[2],Scalar(0,0,255,0),1,8,0);


	CWnd *pWnd=GetDlgItem(IDC_IMGFUSION);
	CDC *pDC=pWnd->GetDC();
	HDC hDC=pDC->GetSafeHdc();
	IplImage img=imgfusion;
	CvvImage cimg;
	cimg.CopyOf(&img);
	CRect rect;
	GetDlgItem(IDC_IMGFUSION)->GetClientRect(&rect);
	cimg.DrawToHDC(hDC,&rect);
}