Skip to content

Unable to start Camera v1.3 on raspberry pi zero 2 w; Code: 22 #169

@Link-248

Description

@Link-248

I have checked the supported formats for the device using this and attempted to pass it manually as a new VideoCharacteristics onto the capture device (As it can't detect any characteristics as per this issue )

if (descriptor?.Characteristics.Length < 1)
            {
                // Request video characteristics strictly:
                // Will raise exception when parameters are not accepted.
                this.Characteristics = new VideoCharacteristics(
                    PixelFormats.YUYV,
                    640, 480,
                    new FlashCap.Utilities.Fraction(15, 1));
            }
// Characteristics combo box was changed.
    [PropertyChanged(nameof(Characteristics))]
    private async ValueTask OnCharacteristicsChangedAsync(VideoCharacteristics? characteristics)
    {
        Debug.WriteLine($"OnCharacteristicsChangedAsync: Enter: {characteristics?.ToString() ?? "(null)"}");

        this.IsEnabled = false;
        try
        {
            // Close when already opened.
            if (this.captureDevice is { } captureDevice)
            {
                this.captureDevice = null;

                this.UpdateCurrentState(States.NotShown);

                Debug.WriteLine($"OnCharacteristicsChangedAsync: Stopping: {captureDevice.Name}");
                await captureDevice.StopAsync();

                Debug.WriteLine($"OnCharacteristicsChangedAsync: Disposing: {captureDevice.Name}");
                await captureDevice.DisposeAsync();
            }

            // Erase preview.
            this.Image = null;
            this.Statistics1 = null;
            this.Statistics2 = null;
            this.Statistics3 = null;
            this.countFrames = 0;

            // Descriptor is assigned and set valid characteristics:
            if (this.Device is { } descriptor &&
                characteristics is { })
            {
                Console.WriteLine($"PB: {descriptor}, {characteristics}");
                // Open capture device:
                Debug.WriteLine($"OnCharacteristicsChangedAsync: Opening: {descriptor.Name}");
                try
                {
                    this.captureDevice = await descriptor.OpenAsync(
                    characteristics,
                    this.OnPixelBufferArrivedAsync);
                    
                    Console.WriteLine(this.captureDevice.ToJson());
                    Console.WriteLine(this.captureDevice.Characteristics);

                    CancellationToken tokenSource = new CancellationToken();

                    await this.captureDevice.StartAsync(tokenSource);

                    Console.WriteLine($"CD: {this.captureDevice}, {characteristics} ");

                    this.UpdateCurrentState(States.Ready);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

            }
        }
        finally
        {
            this.IsEnabled = true;
            await DisplayVideoFeed();

            Debug.WriteLine($"OnCharacteristicsChangedAsync: Leave: {characteristics?.ToString() ?? "(null)"}");
        }
    }

But If I omit await this.captureDevice.StartAsync(tokenSource); The openAsync never passes through the OnPixelBufferArrivedAsync and on running startAsync I get:

unicam: platform:3f801000.csi: unicam, Characteristics=0, 640x480 [YUYV, 15.000fps]
{"Identity":"/dev/video0","Characteristics":{},"IsRunning":false}
640x480 [YUYV, 15.000fps]
System.ArgumentException: FlashCap: Couldn't start capture: Code=22, DevicePath=/dev/video0
   at FlashCap.Devices.V4L2Device.<OnStartAsync>b__18_0() in /_/FlashCap.Core/Devices/V4L2Device.cs:line 261
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__292_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at FlashCap.CaptureDevice.InternalStartAsync(CancellationToken ct) in /_/FlashCap.Core/CaptureDevice.cs:line 93
   at JARVIS.Avalonia.ViewModels.MainWindowViewModel.OnCharacteristicsChangedAsync(VideoCharacteristics characteristics) in /Users/daniel/Documents/JARVIS/JARVIS/ViewModels/MainWindowViewModel.cs:line 288

Anyone run into this issue and have a solution? Been stuck troubleshooting for a couple of days.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions