1

Afroge の directshow でゲインまたは露出を変更する方法を教えてください。

以下に示すものは既に試しましたが、成功しませんでした。私は何を間違っていますか?

前もって感謝します

AForge.Video を使用。AForge.Video.DirectShow を使用します。

... ... ...

VideoCaptureDevice ビデオソース;

private void changeProp(int value) { videoSource.SetCameraProperty(CameraControlProperty.Exposure, value, CameraControlFlags.Auto); }

4

1 に答える 1

0

このコードは私にとってはうまくいきます。ほとんどのコードは Afroge Samples から取得しました。

private VideoCaptureDevice videoDevice;
private FilterInfoCollection videoDevices;
private VideoCapabilities[] videoCapabilities;

public Bool SetCamera(Cameras camera, int camDevice, CameraResolution camResolution,
        int exposureValue, int zoomValue, int focusValue)
    {
        // Enumerate video devices
        videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

        //Select camera according to specified index
        videoDevice = new VideoCaptureDevice(videoDevices[camDevice].MonikerString);

        //Get video capabilities for setting the resoluton
            videoCapabilities = videoDevice.VideoCapabilities;

            if (camera == Cameras.C910)
            {
                switch (camResolution)
                {
                    case CameraResolution.A_640x480:
                        videoDevice.VideoResolution = videoCapabilities[0];
                        break;
                    case CameraResolution.B_800x600:
                        videoDevice.VideoResolution = videoCapabilities[14];
                        break;
                    case CameraResolution.C_960x720:
                        videoDevice.VideoResolution = videoCapabilities[16];
                        break;
                    case CameraResolution.D_1280x720:
                        videoDevice.VideoResolution = videoCapabilities[17];
                        break;
                    case CameraResolution.E_1920x1080:
                        videoDevice.VideoResolution = videoCapabilities[24];
                        break;
                    default:
                        videoDevice.VideoResolution = videoCapabilities[0];
                        break;
                }

            }
            else if (camera == Cameras.C920)
            {
                switch (camResolution)
                {
                    case CameraResolution.A_640x480:
                        videoDevice.VideoResolution = videoCapabilities[0];
                        break;
                    case CameraResolution.B_800x600:
                        videoDevice.VideoResolution = videoCapabilities[10];
                        break;
                    case CameraResolution.C_960x720:
                        videoDevice.VideoResolution = videoCapabilities[12];
                        break;
                    case CameraResolution.D_1280x720:
                        videoDevice.VideoResolution = videoCapabilities[14];
                        break;
                    case CameraResolution.E_1920x1080:
                        videoDevice.VideoResolution = videoCapabilities[16];
                        break;
                    default:
                        videoDevice.VideoResolution = videoCapabilities[0];
                        break;
                }
            }
            else
            {
                videoDevice.VideoResolution = videoCapabilities[0];
            }

        try
        {   
            videoDevice.SetCameraProperty(
                CameraControlProperty.Zoom,
                zoomValue,
                CameraControlFlags.Manual);

            videoDevice.SetCameraProperty(
                CameraControlProperty.Focus,
                focusValue,
                CameraControlFlags.Manual);

            videoDevice.SetCameraProperty(
                CameraControlProperty.Exposure,
                exposureValue,
                CameraControlFlags.Manual);

        }
        catch (Exception ex)
        {
            MessageBox.show(ex.ToString());
        }
于 2014-09-25T17:17:45.387 に答える