Beispiel #1
0
        private Camera()
        {
            // You can select other size and other format, this is a very basic one supported by all types of webcams including old ones
            VideoConnectionSettings settings = new VideoConnectionSettings(0, (640, 480), Iot.Device.Media.PixelFormat.JPEG);

            Device    = VideoDevice.Create(settings);
            IsRunning = true;
            new Thread(() => { TakePictures(); }).Start();
        }
Beispiel #2
0
        /// <summary>
        /// Initiate the camera
        /// </summary>
        public Camera()
        {
            // You can select other size and other format, this is a very basic one supported by all types of webcams including old ones
            VideoConnectionSettings settings = new VideoConnectionSettings(0, (640, 480), Iot.Device.Media.PixelFormat.JPEG);

            _device = VideoDevice.Create(settings);
            // if the device has sufficent ram, enabling pooling significantly improves frames per second by preventing GC.
            _device.ImageBufferPoolingEnabled = true;
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            VideoConnectionSettings settings = new VideoConnectionSettings(0)
            {
                CaptureSize  = (2560, 1920),
                PixelFormat  = PixelFormat.JPEG,
                ExposureType = ExposureType.Auto
            };

            using VideoDevice device = VideoDevice.Create(settings);

            // Get the supported formats of the device
            foreach (PixelFormat item in device.GetSupportedPixelFormats())
            {
                Console.Write($"{item} ");
            }
            Console.WriteLine();

            // Get the resolutions of the format
            foreach ((uint Width, uint Height) in device.GetPixelFormatResolutions(PixelFormat.YUYV))
            {
                Console.Write($"{Width}x{Height} ");
            }
            Console.WriteLine();

            // Query v4l2 controls default and current value
            VideoDeviceValue value = device.GetVideoDeviceValue(VideoDeviceValueType.Rotate);

            Console.WriteLine($"{value.Name} Min: {value.Minimum} Max: {value.Maximum} Step: {value.Step} Default: {value.DefaultValue} Current: {value.CurrentValue}");

            string path = Directory.GetCurrentDirectory();

            // Take photos
            device.Capture($"{path}/jpg_direct_output.jpg");

            // Change capture setting
            device.Settings.PixelFormat = PixelFormat.YUV420;

            // Convert pixel format
            Color[] colors = VideoDevice.Yv12ToRgb(device.Capture(), settings.CaptureSize);
            Bitmap  bitmap = VideoDevice.RgbToBitmap(settings.CaptureSize, colors);

            bitmap.Save($"{path}/yuyv_to_jpg.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
        }
    }
Beispiel #4
0
        static void Main(string[] args)
        {
            CompareType <v4l2_capability>();
            CompareType <v4l2_fmtdesc>();
            CompareType <v4l2_requestbuffers>();
            CompareType <int>();
            CompareType <v4l2_control>();
            CompareType <v4l2_queryctrl>();
            CompareType <v4l2_cropcap>();
            CompareType <v4l2_crop>();
            CompareType <v4l2_format>();
            CompareType <v4l2_format_aligned>();
            CompareType <v4l2_frmsizeenum>();
            CompareType <v4l2_buffer>();

            VideoConnectionSettings settings = new VideoConnectionSettings(0)
            {
                CaptureSize  = (1920, 1080),
                PixelFormat  = PixelFormat.MJPEG,
                ExposureType = ExposureType.Auto
            };

            using VideoDevice device = VideoDevice.Create(settings);

            string path = Directory.GetCurrentDirectory();

            // Take photos
            device.Capture($"{path}/jpg_direct_output.jpg");

            // Change capture setting
            // device.Settings.PixelFormat = PixelFormat.YUV420;

            // Convert pixel format
            //  Color[] colors = VideoDevice.Yv12ToRgb(device.Capture(), settings.CaptureSize);
            //  Bitmap bitmap = VideoDevice.RgbToBitmap(settings.CaptureSize, colors);
            //  bitmap.Save($"{path}/yuyv_to_jpg.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
        }
    }