Link to home
Start Free TrialLog in
Avatar of kishan66
kishan66Flag for United States of America

asked on

Webcam With VC++ 2008

How can i capture video through webcam and display on the screen using C++/Vc++.
I have SDk (may be aug/2008) version and Directx Sdk(June 2008). Do you think i can use DirectShow Api for this. does Microsoft SDK or Directx Sdk has it?


Avatar of jkr
jkr
Flag of Germany image

Sorry, but isn't that the same as in http:Q_24130290.html ?
Avatar of kishan66

ASKER

sorry.
 I thought for every question i have to make a new Post.
i will continue asking here regarding my issue.

can you tell (guide) how to do this Video capturing using vc++2008.
Take a look at MS' samples listed at http://msdn.microsoft.com/en-us/library/dd377437(VS.85).aspx ("PlayCap Sample") and http://msdn.microsoft.com/en-us/library/dd373424(VS.85).aspx ("AmCap Sample"). You'll find the on your disk as part of the DirectShow samples in "[SDK Root]\Samples\Multimedia\DirectShow\Capture\PlayCap" and "[SDK Root]\Samples\Multimedia\DirectShow\Capture\AmCap"
I checked in the link .....but SDK root folder doesn't have /Samples folder .
SDK has only "C:\Program Files\Microsoft SDKs\Windows\V5.0 or V6.0A
so no sample programs to look at.
can you give me some other link..
Any chance that you haven't installed the samples during the SDK setup? They should be there, more info at http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/fb552ee7-5637-43d5-8cda-7884dd15e63f/
BTW, while you are trying to locate these samples, take a look at http://www.codeproject.com/KB/directx/LiveVideo.aspx ("Capture Live Video from various Video Devices.")
when i am trying to look through some examples using " directshow" , i came across this statements..

#if !defined(AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_)
#define AFX_VMR_CAPTURE_H__186091F3_30FA_4FAA_AC8B_EF25E8463B9A__INCLUDED_

i can not find any good answer from net. can you explain me what does this say?

These are so called "header guards", see http://www.cs.niu.edu/~mcmahon/cs241/c241man/node90.html for more. Their purpose is to prevent header files from being multiply included, which would result in "symbol already defined" errors. The "strange" names result from the fact that these have been automatically generated, the numeric part is a so-called "GUID"(http://en.wikipedia.org/wiki/Globally_Unique_Identifier)
what Does the Timer functions in afxWin.h indicate? when do we use them

SetTimer() & KillTimer()

Can i use them to caliculate the latency? i mean frame latency?
please explain me in brief.
No, these timer functions are meant to be used for triggering actions, not measuring time. For the latter, the easiest way might be 'GetTickCount()' (http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx), e.g.
DWORD dwStart = GetTickCount();
 
// ... some lengthy task here ...
 
DWORD dwEnd = GetTickCount();
 
DWORD dwElapsedTime = dwEnd - dwStart;

Open in new window

unable to call OnTimer() from a button click.

I am trying to capture live video and show it on the same screen using webcam.
i have two buttons. "Start" & "Show" .
when clicked "Start" i can see my live video working but when i click on the "Show" button, which  i trying to call a OnTimer(UINT nIDEvent) function ...which will show up the captured live video on the screen, is not working.
No errors are displayed. using debugging i find that the function is "OnTimer()"  not at all called.

can you tell me where am i going wrong.

im using vc++2008.
void CDialogDlg::OnShow()
{
	// TODO: Add your control notification handler code here
 
	this->KillTimer (TIMER_ID);
	this->SetTimer (TIMER_ID,TIMER_DELAY,NULL);
}
 
void CDialogDlg::OnTimer(UINT nIDEvent) 
{
	
	DWORD dwSize;
	
	dwSize=this->m_VMRCap.GrabFrame ();
	if(dwSize>0)
	{
		BYTE *pImage;
		this->m_VMRCap.GetFrame(&pImage);
		this->m_ctrlCaptureIMG.ShowImage(pImage);
	}
	
	CDialog::OnTimer(nIDEvent);
}

Open in new window

What is your timer ID, the interval, and even more important: What return value do you get from

UINT ret =         this->SetTimer (TIMER_ID,TIMER_DELAY,NULL);

?
#define TIMER_DELAY 10
#define TIMER_ID 1

// Timer Functions in   << afxwin.h >>
      UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse,
            void (CALLBACK* lpfnTimer)(HWND, UINT, UINT_PTR, DWORD));
      BOOL KillTimer(UINT_PTR nIDEvent);

please let me know if you need any thing
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial