public Form1() :base("GDI Video", 10, 10, 640, 480) { // Show a dialog box on the screen so the user // can select which camera to use if they have // multiple attached. CaptureDeviceDescription capDescription = new CaptureDeviceDescription(); CameraSelection camForm = new CameraSelection(); camForm.ShowDialog(); //// Get the chosen configuration from the dialog //// and use it to create a capture device. object config = camForm.SetupPage.GetConfiguration(); m_CaptureDevice = (VideoCaptureDevice)capDescription.CreateVideoSource(config); // Another way to get a hold of a capture device //m_CaptureDevice = VideoCaptureDevice.CreateCaptureDeviceFromIndex(0, 320, 240); m_CamControl = new CameraControl(m_CaptureDevice); //Console.WriteLine("Capabilities: {0}", m_CaptureDevice.Capabilities.Count); // Let the capture device know what function to call // whenever a frame is received. m_CaptureDevice.NewFrame += OnFrameReceived; // Start the capture device on its own thread m_CaptureDevice.Start(); fStick = new Joystick(winmm.JOYSTICKID1); dispatcher = new TimedDispatcher(1.0 / 2, OnJoystickDispatch, null); dispatcher.Start(); }
public JoyWindow(int width, int height) : base("Joystick Test", 10, 10, 640, 480) { CheckRawInputDevices(); fStick = new Joystick(winmm.JOYSTICKID1); //fStick.Offset = -0.5f; PrintJoystickReport(fStick); dispatcher = new TimedDispatcher(1.0 / 5, OnDispatch, null); dispatcher.Start(); }
public Form1() :base("GDI Video", 10, 10, 1024, 480) { fScreenContext = GDIContext.CreateForDefaultDisplay(); fCamera = new VfwCameraDevice(0, 320, 240, 15, User32.WS_CHILD | User32.WS_VISIBLE, this.Handle); //fCamera = new VfwCameraDevice(320, 240); fCamera.FrameDelegate = FrameReceived; fBitmapInfo = fCamera.GetBitmapInfo(); fDecompressor = VfwDeCompressor.Create(Vfw.ICTYPE_VIDEO); // Allocate a pixel buffer to receive decompressed bits //fPixelBuffer = new PixelBuffer24(fCamera.Width, fCamera.Height); //fCamera.StartStreaming(); fCamera.PreviewRate = 33; //fCamera.ShowPreviewWindow(); fCaptureDispatcher = new TimedDispatcher(1.0 / 15, CaptureFrame, null); fCaptureDispatcher.Start(); }
public void OnJoystickDispatch(TimedDispatcher dispatcher, double time, object[] dispatchParams) { JoystickActivityArgs currentState = fStick.GetCurrentState(); m_CamControl.PanToAbsolute((float)currentState.R); }
void CaptureFrame(TimedDispatcher dispatcher, double time, Object[] dispatchParams) { //Console.WriteLine("CaptureFrame: {0}", time); fCamera.GrabSingleFrame(); }
public void OnDispatch(TimedDispatcher dispatcher, double time, object[] dispatchParams) { JoystickActivityArgs currentState = fStick.GetCurrentState(); PrintStickState(currentState); }