verian

verian

  • NA
  • 1
  • 0

Webcam capture, CapParams issues

Jan 27 2010 4:35 AM

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

[code]
[System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")]
        public static extern int SendMessage2(int webcam1, int Msg, CAPTUREPARMS wParam, [MarshalAs(UnmanagedType.AsAny)] object lParam);
[/code]
[code]
            CAPTUREPARMS CaptureParams;
            CaptureParams.fYield = true;
            CaptureParams.fAbortLeftMouse = false;
            CaptureParams.fAbortRightMouse = false;
            CaptureParams.dwRequestMicroSecPerFrame = 66667;
            CaptureParams.fMakeUserHitOKToCapture = false;
            CaptureParams.wPercentDropForError = 10;
            CaptureParams.wChunkGranularity  = 0;
            CaptureParams.dwIndexSize = 0;
            CaptureParams.wNumVideoRequested = 10;
            CaptureParams.fCaptureAudio = false;
            CaptureParams.fLimitEnabled = false;
            CaptureParams.fMCIControl = false;
            CaptureParams.fStepMCIDevice = false;
            CaptureParams.dwMCIStartTime = 0;
            CaptureParams.dwMCIStopTime = 0;
            CaptureParams.fStepCaptureAt2x = false;
            CaptureParams.wStepCaptureAverageFrames = 5;
            CaptureParams.dwAudioBufferSize = 0;
[/code]
[code]
 public struct CAPTUREPARMS
        {
            public bool fYield;
            public bool fAbortLeftMouse;
            public bool fAbortRightMouse;
            public int dwRequestMicroSecPerFrame;
            public bool fMakeUserHitOKToCapture;
            public int wPercentDropForError;
            public int wChunkGranularity;
            public int dwIndexSize;
            public int wNumVideoRequested;
            public bool fCaptureAudio;
           
            public bool fLimitEnabled;
            public bool fMCIControl;
            public bool fStepMCIDevice;
            public int dwMCIStartTime;
            public int dwMCIStopTime;
            public bool fStepCaptureAt2x;
            public int wStepCaptureAverageFrames;
            public int dwAudioBufferSize;
          

            public CAPTUREPARMS(bool fYield, bool fAbortLeftMouse, bool fAbortRightMouse, int dwRequestMicroSecPerFrame, bool fMakeUserHitOKToCapture,
                int wPercentDropForError, int dwIndexSize, int wChunkGranularity, int wNumVideoRequested, bool fCaptureAudio, bool fLimitEnabled, bool fMCIControl,
                bool fStepMCIDevice, int dwMCIStartTime, int dwMCIStopTime, bool fStepCaptureAt2x, int wStepCaptureAverageFrames, int dwAudioBufferSize)
            {
                this.fYield = fYield;
                this.fAbortLeftMouse = fAbortLeftMouse;
                this.fAbortRightMouse = fAbortRightMouse;
                this.dwRequestMicroSecPerFrame = dwRequestMicroSecPerFrame;
                this.fMakeUserHitOKToCapture = fMakeUserHitOKToCapture;
                this.wPercentDropForError = wPercentDropForError;
                this.dwIndexSize = dwIndexSize;
                this.wChunkGranularity = wChunkGranularity;
                this.wNumVideoRequested = wNumVideoRequested;
                this.fCaptureAudio = fCaptureAudio;
                this.fLimitEnabled = fLimitEnabled;
                this.fMCIControl = fMCIControl;
                this.fStepMCIDevice = fStepMCIDevice;
                this.dwMCIStartTime = dwMCIStartTime;
                this.dwMCIStopTime = dwMCIStopTime;
                this.fStepCaptureAt2x = fStepCaptureAt2x;
                this.wStepCaptureAverageFrames = wStepCaptureAverageFrames;
                this.dwAudioBufferSize = dwAudioBufferSize;
               
            }
        }
[/code]
[code]
SendMessage2(webcam1, WM_CAP_SET_SEQUENCE_SETUP, CaptureParams, 0);
[/code]