468,470 Members | 1,476 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,470 developers. It's quick & easy.

Correctly using CapParams

3
Iv been trying to record a video from webcam in C# and iv pretty much got there now, the only problem is i need to be able to click other buttons while the recording is going on. I know that i need to use WM_CAP_SET_SEQUENCE_SETUP for this, and i know it takes structure information such as the yField that i need to alter.
The actual problem though is that im not familiar with structures so my attempts have failed, and because im doing this in C# all of the googled examples iv found have done it differently. Could anyone point me in the right direction with how to correctly set up my sequence setup /w params?

Here's the relevant bits of code iv been trying to write to do this

Expand|Select|Wrap|Line Numbers
  1.  
  2. [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")]
  3.         public static extern int SendMessage2(int webcam1, int Msg, CAPTUREPARMS wParam, [MarshalAs(UnmanagedType.AsAny)] object lParam);
  4.  
  5.  
Expand|Select|Wrap|Line Numbers
  1.  
  2.             CAPTUREPARMS CaptureParams;
  3.             CaptureParams.fYield = true;
  4.             CaptureParams.fAbortLeftMouse = false;
  5.             CaptureParams.fAbortRightMouse = false;
  6.             CaptureParams.dwRequestMicroSecPerFrame = 66667;
  7.             CaptureParams.fMakeUserHitOKToCapture = false;
  8.             CaptureParams.wPercentDropForError = 10;
  9.             CaptureParams.wChunkGranularity  = 0;
  10.             CaptureParams.dwIndexSize = 0;
  11.             CaptureParams.wNumVideoRequested = 10;
  12.             CaptureParams.fCaptureAudio = false;
  13.             CaptureParams.fLimitEnabled = false;
  14.             CaptureParams.fMCIControl = false;
  15.             CaptureParams.fStepMCIDevice = false;
  16.             CaptureParams.dwMCIStartTime = 0;
  17.             CaptureParams.dwMCIStopTime = 0;
  18.             CaptureParams.fStepCaptureAt2x = false;
  19.             CaptureParams.wStepCaptureAverageFrames = 5;
  20.             CaptureParams.dwAudioBufferSize = 0;
  21.  
  22.  
Expand|Select|Wrap|Line Numbers
  1.  
  2.  public struct CAPTUREPARMS
  3.         {
  4.             public bool fYield;
  5.             public bool fAbortLeftMouse;
  6.             public bool fAbortRightMouse;
  7.  
  8.             public int dwRequestMicroSecPerFrame;
  9.             public bool fMakeUserHitOKToCapture;
  10.             public int wPercentDropForError;
  11.             public int wChunkGranularity;
  12.             public int dwIndexSize;
  13.             public int wNumVideoRequested;
  14.             public bool fCaptureAudio;
  15.  
  16.             public bool fLimitEnabled;
  17.             public bool fMCIControl;
  18.             public bool fStepMCIDevice;
  19.             public int dwMCIStartTime;
  20.             public int dwMCIStopTime;
  21.             public bool fStepCaptureAt2x;
  22.             public int wStepCaptureAverageFrames;
  23.             public int dwAudioBufferSize;
  24.  
  25.  
  26.  
  27.             public CAPTUREPARMS(bool fYield, bool fAbortLeftMouse, bool fAbortRightMouse, int dwRequestMicroSecPerFrame, bool fMakeUserHitOKToCapture,
  28.                 int wPercentDropForError, int dwIndexSize, int wChunkGranularity, int wNumVideoRequested, bool fCaptureAudio, bool fLimitEnabled, bool fMCIControl,
  29.                 bool fStepMCIDevice, int dwMCIStartTime, int dwMCIStopTime, bool fStepCaptureAt2x, int wStepCaptureAverageFrames, int dwAudioBufferSize)
  30.             {
  31.                 this.fYield = fYield;
  32.                 this.fAbortLeftMouse = fAbortLeftMouse;
  33.                 this.fAbortRightMouse = fAbortRightMouse;
  34.                 this.dwRequestMicroSecPerFrame = dwRequestMicroSecPerFrame;
  35.                 this.fMakeUserHitOKToCapture = fMakeUserHitOKToCapture;
  36.                 this.wPercentDropForError = wPercentDropForError;
  37.                 this.dwIndexSize = dwIndexSize;
  38.                 this.wChunkGranularity = wChunkGranularity;
  39.                 this.wNumVideoRequested = wNumVideoRequested;
  40.                 this.fCaptureAudio = fCaptureAudio;
  41.                 this.fLimitEnabled = fLimitEnabled;
  42.                 this.fMCIControl = fMCIControl;
  43.                 this.fStepMCIDevice = fStepMCIDevice;
  44.                 this.dwMCIStartTime = dwMCIStartTime;
  45.                 this.dwMCIStopTime = dwMCIStopTime;
  46.                 this.fStepCaptureAt2x = fStepCaptureAt2x;
  47.                 this.wStepCaptureAverageFrames = wStepCaptureAverageFrames;
  48.                 this.dwAudioBufferSize = dwAudioBufferSize;
  49.  
  50.             }
  51.         }
Expand|Select|Wrap|Line Numbers
  1. SendMessage2(webcam1, WM_CAP_SET_SEQUENCE_SETUP, CaptureParams, 0);
Jan 27 '10 #1
1 2056
Plater
7,872 Expert 4TB
Structs don't generally have functions inside them.
Try making a pure struct and passing it in.
Jan 27 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Bore Biko | last post: by
2 posts views Thread by MarkusPoehler | last post: by
7 posts views Thread by Axel Dahmen | last post: by
5 posts views Thread by Cammie Watson | last post: by
9 posts views Thread by PhreakRox | last post: by
5 posts views Thread by Generic Usenet Account | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.