Video Capture Problem

A

Arsalan Ahmad

Hi all,

I have written an application in which i have used capXXXX() functions like
capCreateCaptureWindow() and many others etc to capture video frame from
web-cam attached to USB port of my PC. The problem is that right now in
order to grab each frame I have to call capGrabFramNoStop() function, after
calling which my callback function is called with a pointer to videostream
buffer. So I have to call capGrabFrameNoStop() function each time to get the
pointer of the captured frame. I dont want to do this. How can I make my
application to automatically called the callback function whenever a new
frame is captured by my camera, so that there is no need for me to call the
capGrabFraeNoStop() function every time in a timer? Here I would like to
mention that I need the pointer to the captured video buffer.

Thanks,

Arsalan Ahmad
 
T

Tim Roberts

Arsalan Ahmad said:
I have written an application in which i have used capXXXX() functions like
capCreateCaptureWindow() and many others etc to capture video frame from
web-cam attached to USB port of my PC. The problem is that right now in
order to grab each frame I have to call capGrabFramNoStop() function, after
calling which my callback function is called with a pointer to videostream
buffer. So I have to call capGrabFrameNoStop() function each time to get the
pointer of the captured frame. I dont want to do this. How can I make my
application to automatically called the callback function whenever a new
frame is captured by my camera, so that there is no need for me to call the
capGrabFraeNoStop() function every time in a timer?

You want capCaptureSequence to enable streaming capture. Your OnFrame
callback will be called with each frame.
 
A

Arsalan Ahmad

Hi,

Below is the code of my camera class init function.

CMyCamera::Init()
{
// Some code here...

hWnd = capCreateCaptureWindow(_T("MyCamera"), WS_CHILD|WS_CLIPSIBLINGS, x,
y, 320, 240, pParentWnd?pParentWnd->GetSafeHwnd():NULL, 0xffff);
capDriverConnect (hWnd, 0);
memset( &m_caps, 0, sizeof(m_caps));
capDriverGetCaps( hWnd, &m_caps, sizeof(m_caps));
capSetUserData( hWnd, (long)this );
capSetCallbackOnVideoStream( hWnd, Camera_CallbackProc);
::MoveWindow( hWnd, 0, 0, 1, 1, TRUE );
CAPTUREPARMS p;
capCaptureGetSetup(hWnd,&p,sizeof(CAPTUREPARMS));
p.dwRequestMicroSecPerFrame = 33333; // For 30 fps
capCaptureSetSetup(hWnd,&p,sizeof(CAPTUREPARMS));

//capCaptureSequenceNoStop(); // I have used capCaptureSequenceNoStop()
before or after Subclass() but no use
SubclassWindow(hWnd);
capCaptureSequenceNoStop();

return true;
}

I have omitted some portion to make it simple. Now after that init function
I assume that my callback function Camera_CallbackProc() will be called at
every frame but this is not happening. Is there anything I am missing.

Thanks,

Arsalan
 
A

Arsalan Ahmad

Hi,

Is there any other way of capturing the video from a cameara apart from
using VFW. I am looking for any other method(DirectShow or any other etc).
Any Idea...

Thanks,

Arsalan
 
T

Tim Roberts

Arsalan Ahmad said:
Is there any other way of capturing the video from a cameara apart from
using VFW. I am looking for any other method(DirectShow or any other etc).

Absolutely. Even if there is no DirectShow driver for the device,
DirectShow can provide a wrapper around a VFW driver.

However, it isn't going to be easier in DirectShow. DS is incredibly
flexible (my admiration for the original design grows every year), but it
is a lot more work than a VFW app.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top