Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to capture image from web cam without showing vedio display box.
I am using avicap32.dll.
When I call capDriverConnect(hMyWindow,index) it shows dialog box with capturing devices.

I already fill combo box with capturing devices.

my code is
C++
HWND InitDevice(HWND m_hWnd,int w,int h,int index)   
{   
	wid=w;
	het=h;
	hMyWindow=NULL;
	if(hMyWindow==NULL)
	{
		//"Logitech Webcam Pro 9000"
		//"Microsoft WDM Image Capture (Win32)"
		LPCWCHAR webcamname;//=(LPCWCHAR)"Capture Window";
		//OPTIONAL STEP: Enable callback
		//capSetCallbackOnFrame(hMyWindow, capVideoStreamCallback); //hook callback function
		//|WM_CAP_DLG_VIDEODISPLAY
		hMyWindow = capCreateCaptureWindow(webcamname, WS_CHILD | WS_VISIBLE, 0, 0, wid,het,m_hWnd,0);
	}
	if (hMyWindow == NULL)   
	{   
		//AfxMessageBox("capCreateCaptureWindow error...");   
		return FALSE;   
	}   
	if(!capSetCallbackOnVideoStream(hMyWindow,NULL))  
	{   
		//AfxMessageBox("capSetCallbackOnVideoStream error...");   
		return FALSE;   
	}   
	if(!capSetCallbackOnError(hMyWindow,NULL))
	{
		//AfxMessageBox("capSetCallbackOnError error...");   
		return FALSE;   
	}
	if(!capSetCallbackOnFrame(hMyWindow,NULL))
	{
		//AfxMessageBox("capSetCallbackOnFrame error...");   
		return FALSE;  
	}
	if(!capSetCallbackOnStatus(hMyWindow,NULL))
	{
		//AfxMessageBox("capSetCallbackOnStatus error...");   
        return FALSE;
	}
	if(!capSetCallbackOnWaveStream(hMyWindow,NULL))
	{
		//AfxMessageBox("capSetCallbackOnWaveStream error...");   
        return FALSE;
	}
	if(!capSetCallbackOnYield(hMyWindow,NULL))
	{
		//AfxMessageBox("capSetCallbackOnYield error...");   
        return FALSE;
	}
	//
	if (!capDriverConnect(hMyWindow,index)) 
	{   
		//AfxMessageBox("capDriverConnect error...");   
		return FALSE;   
	}   
	if (!SetCapturePara())   
	{   
		capDriverDisconnect(hMyWindow);   
		return FALSE;   
	}  	
	return hMyWindow;   
} 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900