MFC联合HAlcon双相机单帧采集图片

这里写自定义目录标题


问题:程序运行时首次采集都能行,再次点击CCD1,CCD2采集按钮,MFC界面的Picture Contrl控件直接黑屏了,但是我在if(CCD1==0){ }内增加了状态显示程序,显示已经进入到了if(){}语句内,但是图像就是显示不了,不清楚为什么?有木有大神知道原因
//CCD1采集按钮的程序
void CCounterPointsDlg::OnBnClickedCcd1PictureGet()
{
// TODO: 在此添加控件通知处理程序代码

//CCD1相机打开
OpenFramegrabber("DahengCAM", 1, 1, 0, 0, 0, 0, "interlaced", 8, "gray", -1, "false",
	"HV-13xx", "1", 1, -1, &hv_AcqHandle_CCD1);

//CCD1相机准备采集
GrabImageStart(hv_AcqHandle_CCD1, -1);
GrabImageAsync(&ho_Image_UP, hv_AcqHandle_CCD1, -1);

GetImageSize(ho_Image_UP, &hv_Width_CCD1, &hv_Height_CCD1);

if (HDevWindowStack::IsOpen())
	SetPart(HDevWindowStack::GetActive(), 0, 0, hv_Height_CCD1 - 1, hv_Width_CCD1 - 1);
//CCD1显示窗口大小设置
HTuple hv_Expection;
//CCD1显示窗口不为空,则关闭窗口
if (m_CCD1 != 0)
{
	HDevWindowStack::SetActive(hv_WindowHandle);
	ClearWindow(HDevWindowStack::GetActive());
	m_CCD1 = FALSE;
	CString str;
	str.Format(_T("CCD1窗口已清空"), str);
	m_status.SetPaneText(0, str, TRUE);
}
//CCD1显示窗口为空,则打开窗口显示
if (m_CCD1 == 0)
{
	m_CCD1 = TRUE;
	HWND CCD1_hwndl;
	CRect Rect_CCD1;
	GetDlgItem(IDC_CCD1_Picture_Show)->GetWindowRect(&Rect_CCD1);
	CCD1_hwndl = GetDlgItem(IDC_CCD1_Picture_Show)->m_hWnd;
	Hlong lWWindow_CCD1_ID = (Hlong)CCD1_hwndl;
	Width = Rect_CCD1.Width();
	Height = Rect_CCD1.Height();

	OpenWindow(0, 0, Width, Height, lWWindow_CCD1_ID, "", "", &hv_WindowHandle);
	HDevWindowStack::Push(hv_WindowHandle);
	HDevWindowStack::SetActive(hv_WindowHandle);
	
	//if (HDevWindowStack::IsOpen())
		DispObj(ho_Image_UP, hv_WindowHandle);
	UpdateData(TRUE);
	CString str;
	str.Format(_T("CCD1窗口已显示"), str);
	m_status.SetPaneText(0, str, TRUE);
}
//关闭相机CCD1句柄
CloseFramegrabber(hv_AcqHandle_CCD1);

//使得匹配按键可用
::EnableWindow(GetDlgItem(IDC_Picture_Match)->GetSafeHwnd(), TRUE);

}
//CCD2采集按钮的程序
void CCounterPointsDlg::OnBnClickedCcd2PictureGet()
{
// TODO: 在此添加控件通知处理程序代码

//CCD2相机打开
OpenFramegrabber("DahengCAM", 1, 1, 0, 0, 0, 0, "interlaced", 8, "gray", -1, "false",
	"HV-13xx", "2", 1, -1, &hv_AcqHandle_CCD2);
//CCD2相机准备采集
GrabImageStart(hv_AcqHandle_CCD2, -1);
GrabImageAsync(&ho_Image_DOWN, hv_AcqHandle_CCD2, -1);
GetImageSize(ho_Image_DOWN, &hv_Width_CCD2, &hv_Height_CCD2);

if (HDevWindowStack::IsOpen())
	SetPart(HDevWindowStack::GetActive(), 0, 0, hv_Height_CCD2 - 1, hv_Width_CCD2 - 1);
//CCD1显示窗口大小设置
//CCD1显示窗口不为空,则关闭窗口
if (m_CCD2 != 0)
{
	HDevWindowStack::SetActive(hv_WindowHandle1);
	ClearWindow(HDevWindowStack::GetActive());
	m_CCD2 = FALSE;
	CString str;
	str.Format(_T("CCD2窗口已清空"), str);
	m_status.SetPaneText(0, str, TRUE);
}
//CCD1显示窗口为空,则打开窗口显示
if (m_CCD2 == 0)
{
	m_CCD2 = TRUE;
	HWND CCD2_hwndl;
	CRect Rect_CCD2;
	GetDlgItem(IDC_CCD2_Picture_Show)->GetWindowRect(&Rect_CCD2);
	CCD2_hwndl = GetDlgItem(IDC_CCD2_Picture_Show)->m_hWnd;
	Hlong lWWindow_CCD2_ID = (Hlong)CCD2_hwndl;
	Width = Rect_CCD2.Width();
	Height = Rect_CCD2.Height();
	
	OpenWindow(0, 0, Width, Height, lWWindow_CCD2_ID, "", "", &hv_WindowHandle1);
	HDevWindowStack::Push(hv_WindowHandle1);
	HDevWindowStack::SetActive(hv_WindowHandle1);
	//if (HDevWindowStack::IsOpen())
		DispObj(ho_Image_DOWN, hv_WindowHandle1);
	UpdateData(TRUE);
	CString str;
	str.Format(_T("CCD2窗口显示"), str);
	m_status.SetPaneText(0, str, TRUE);
}
//关闭相机CCD2句柄
CloseFramegrabber(hv_AcqHandle_CCD2);

}
附上我用MFC做的UI界面,刚学MFC没多久,让各位大神见笑了
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值