Giter Site home page Giter Site logo

Comments (17)

SignalMQ avatar SignalMQ commented on May 23, 2024 1

@kekyo I'm tried to detect my device with V4L2 Devices().Enumerate Descriptors() and surprised for detected 2nd shadow copy of device placed in /dev/video0:

image

Here it seemed strange to me that the devices are listed in reverse order ([/dev/video1, /dev/video0]), or I’m wrong.

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024 1

My problem solved, I use my second device.

from flashcap.

kekyo avatar kekyo commented on May 23, 2024

Thanks for reached out!

If FlashCap is the latest, Characteristics cannot handle are also enumerated as Unknown formats. However, I could not understand why they are not enumerated at all, including them. Can we try other cameras?

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024

I tried code below on my second computer:

using FlashCap;
using SkiaSharp;

var devices = new CaptureDevices();
var descriptor0 = devices.EnumerateDescriptors().ElementAt(0);
byte[] imageData = await descriptor0.TakeOneShotAsync(descriptor0.Characteristics.FirstOrDefault());

using (var ms = new MemoryStream(imageData))
{
    SKBitmap bitmap = SKBitmap.Decode(ms);
    SKFileWStream fs = new("photo.png");
    bitmap.Encode(fs, SKEncodedImageFormat.Png, quality: 100);
}

Other cam:
Logi C270 HD WebCam (USB\VID_046D&PID_0825&MI_00\6&29B00C26&0&0000)

OS:
Windows 11 Enterprise 22H2

Detected and works perfectly, but in my laptop same situation

Result:
photo

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024

Thanks for reached out!

If FlashCap is the latest, Characteristics cannot handle are also enumerated as Unknown formats. However, I could not understand why they are not enumerated at all, including them. Can we try other cameras?

I dont have other cameras on this device, because it's laptop.

from flashcap.

kekyo avatar kekyo commented on May 23, 2024

@SignalMQ On #126 and #127, maybe these issues were a factor. #124 may also affect stable operation, so can I try it after merging these?

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024

@SignalMQ On #126 and #127, maybe these issues were a factor. #124 may also affect stable operation, so can I try it after merging these?

I don't understand, what you meaning in 'so can I try it...'. I'm try these fixes or you?

from flashcap.

kekyo avatar kekyo commented on May 23, 2024

Oh, sorry if it doesn't make sense, I made a mistake in the translation program πŸ˜΅β€πŸ’«
Could you try it with a commit from current develop branch?

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024

image

Hello @kekyo. I am building nupkg from develop branch but this error appears above.

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024
Characteristics [VideoCharacteristics[]]:
{FlashCap.VideoCharacteristics[0]}
Description [string]:
"usb-0000:03:00.4-3: uvcvideo"
DeviceType [DeviceTypes]:
V4L2
Identity [object]:
"/dev/video1"
Name [string]:
"USB2.0 HD UVC WebCam: USB2.0 HD"
Non-Public members

here is my decriptors info

from flashcap.

kekyo avatar kekyo commented on May 23, 2024

@SignalMQ Sorry later, I am interested in what characteristics are enumerated in your camera. The following sections:

https://github.com/kekyo/FlashCap/blob/854186a445e494548480ae0d6b607c1bf009eb57/FlashCap.Core/Devices/V4L2Devices.cs#L184C29-L184C48

                        return (CaptureDeviceDescriptor)new V4L2DeviceDescriptor(
                            devicePath, ToString(caps.card), $"{ToString(caps.bus_info)}: {ToString(caps.driver)}",
                            EnumerateFormatDesc(fd).
                            SelectMany(fmtdesc =>
                                EnumerateFrameSize(fd, fmtdesc.pixelformat).
                                SelectMany(frmsize =>
                                    EnumerateFramesPerSecond(fd, fmtdesc.pixelformat, frmsize.Width, frmsize.Height).
                                    Collect(framesPerSecond =>
                                        NativeMethods_V4L2.CreateVideoCharacteristics(
                                            fmtdesc.pixelformat, frmsize.Width, frmsize.Height,
                                            framesPerSecond.Value, ToString(fmtdesc.description),
                                            frmsize.IsDiscrete && framesPerSecond.IsDiscrete)))).
                            Distinct().
                            OrderByDescending(vc => vc).
                            ToArray());

Here, if a series of SelectMany() returns no result, the number of characteristics is zero. Such a possibility would be if EnumerateFormatDesc(), EnumerateFrameSize(), or EnumerateFramesPerSecond() returned zero elements. Your camera may fall into one of these cases.

This line is written on a single line, so it may be difficult to verify. For example:

var a = EnumerateFormatDesc(fd).ToArray();
var b = a.SelectMany(fmtdesc =>
{
    var c = EnumerateFrameSize(fd, fmtdesc.pixelformat).ToArray();
    var d = c.SelectMany(frmsize =>
    {
        // ...
    });
    // ...
});

to change the enumeration so that you can check the enumeration and be sure of it on the debugger.

from flashcap.

kekyo avatar kekyo commented on May 23, 2024

I was surprised too! I'm not sure why there are multiple /dev/video? enumerations in the first place, but I'm not particularly aware of the order:

Directory.GetFiles("/dev", "video*").

If you select /dev/video1, will it capture correctly?

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024

I was surprised too! I'm not sure why there are multiple /dev/video? enumerations in the first place, but I'm not particularly aware of the order:

Directory.GetFiles("/dev", "video*").

If you select /dev/video1, will it capture correctly?

/dev/video1 - fail
/dev/video0 - sucess

from flashcap.

kekyo avatar kekyo commented on May 23, 2024

According to the screenshot, /dev/video0 has zero characteristics and /dev/video1 enumerates several characteristics, did you succeed in the case of /dev/video0?

Are you saying that you used the value of /dev/video1 as the characteristic in that case?

from flashcap.

SignalMQ avatar SignalMQ commented on May 23, 2024

According to the screenshot, /dev/video0 has zero characteristics and /dev/video1 enumerates several characteristics, did you succeed in the case of /dev/video0?

Are you saying that you used the value of /dev/video1 as the characteristic in that case?

/dev/video0 has 12 characteristics and it's work, but /dev/video1 enumerated in first is not work, because don't have any characteristics listed.

from flashcap.

kekyo avatar kekyo commented on May 23, 2024

I see. As a coping remedy, it seems that we need to ignore devices with zero characteristics.

We could ignore devices with zero characteristics when internal FlashCap enumerates them, but I imagine that would probably make it difficult to identify the problem.
Therefore, I would like to make it a policy that this exclusion is handled by the caller. For example:

if (devices.EnumerateDescriptors().
    FirstOrDefault(d => d.Characteristics.Any(c => c.PixelFormat != PixelFormats.Unknown)) is { } device)
{
    // `device` is valid.
}

from flashcap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.