Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AForge.Video.DirectShow VideoCaptureDevice selectable SubType and 'raw' data mode #50

Open
JoJoBond opened this issue Jan 21, 2022 · 0 comments

Comments

@JoJoBond
Copy link

Currently the DirectShow VideoCaptureDevice will request RGB24 (or when available Mjpeg) MediaSubType. It would be great to be able to select the desired MediaSubType via properties. This however would be a problem if we try to convert some of the more obscure MediaSubType to Images. For this a 'raw' data mode could be added that simply passes the raw frame data as byte array instead of Image.

This would be useful for devices that have obscure MediaSubTypes or devices that send metadata within its image. E.g. thermal cameras, these often have a raw mode that sends raw sensor data instead of pixel values. That data can only be used properly if it remains in its original MediaSubType. If the original MediaSubType is e.g. YUY2 and we request RGB24, DirectShow will request YUY2 internally and convert to YUY2. This process involves rounding and is thus not reversible, rending the the data useless.

I would suggest to add two properties VideoCaptureDevice 'VideoFormat' and 'SnapshotFormat' typed with an Enum that holds different MediaSubTypes.
Since almost everything but RGB24 isn't 1:1 convertible to Image, these formats would have to be 'raw' mode only. For RGB24 and all other formats that can be converted to Image, I'd suggest for them to have an additional Enum value for when you'd like to get the raw data instead.
My idea for passing the raw data to the caller would be to extend NewFrameEventArgs with a RawData byte array property. The Frame property could be changed to be loaded 'lazy' when it is needed and would throw NotSupportedException if the data can't be converted to Image.

Please let me know if agree with my approach or if you would like to see it being done differently. I can then implement all the changes and open a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant