HI, I'm using your class to capture a seq of frames. It works fine, but I get few frames per second. Is there any way to make this go faster? Thanks
IB4m trying to print an iamge using sample grabber but I couldnB4t get anything. B?Do you know how I can perform that action?. Thanks.
ReplyYou can do it like this (thank you "person
who brought this method to my attention"):
// Define a timer id
#define IDT_TIMER1 9999
// ...
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// ...
SetTimer(hWnd, IDT_TIMER1, 200, (TIMERPROC)NULL); // five frames a second
switch (message) {
case WM_TIMER: // Replace menu item for grabbing with this
switch(wParam)
{
case IDT_TIMER1:
bmp.LoadBMP();
InvalidateRect(hWnd,NULL,TRUE);
break;
default:
return (DefWindowProc(hWnd, message, wParam, lParam));
}
// Your other case statements
// ...
case WM_DESTROY:
KillTimer(hWnd, IDT_TIMER1);
PostQuitMessage (0);
break;
// ...
}
}
Reply
I think that you can just write a loop e.g.
for(i=0;i<5;i++)
{
// call CaptureDIB
// process bitmap
// display bitmap
// sleep 1/5 of a second
// delete bitmap -- not sure you need to delete 5 times since you are replacing the bitmap each time. Maybe better outside the loop.
}
// destroy capture object
I haven't tried this but will soon and give an update here.
Reply
I find your code very usefull - no MFC!! great. But it only gets a single frame w/ a Logitech cam. How can I continue to get frames w/o using threads? 5 frames / sec would be nice.
ReplyAs I said, I left out a lot of things I didn't need. One of them was the CaptureAVI function. In it, there is code that sets the frames per second like this: // FramesPerSec is input of type FLOAT CAPTUREPARMS CapParms; CapParms.dwRequestMicroSecPerFrame = (DWORD)(1.0E6/FramesPerSec);
ReplyI've only used it with Logitech web cams. You may want to look at Ken's article to see if this is addressed there.
ReplyHai ,I just connected by compaq webcam and found there is no video capture ocuring will it work for all webcam
Reply