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

How to set the video feed and still capture to a single channel (monochrome) #45

Open
rajeshamudala opened this issue Dec 11, 2024 · 4 comments

Comments

@rajeshamudala
Copy link

rajeshamudala commented Dec 11, 2024

Hi,

I am running two monochrome cameras using this code. We found that the bitmap data is being generated in RGB format. How can we set the bitmap data to a monochrome format?

I have created a new media subtype:
public static readonly Guid MEDIASUBTYPE_Y8 = new Guid("{17fd9d23-d15f-4e42-9e3e-310b1d4a209b}");
in the DsGuid class and assigned it as follows:

var mt = new DirectShow.AM_MEDIA_TYPE();
mt.MajorType = DirectShow.DsGuid.MEDIATYPE_Video;
//mt.SubType = DirectShow.DsGuid.MEDIASUBTYPE_RGB24;
mt.SubType = DirectShow.DsGuid.MEDIASUBTYPE_Y8;
ismp.SetMediaType(mt);

However, in the CreateSampleGrabber method, the getBitmap() function is returning null.

@secile
Copy link
Owner

secile commented Dec 11, 2024

Hello, thank you for your question.
and you may ask me some other issues. I'm sorry for not replying some issues.

I want to confirm your situation.

(1) You are using monochrome USB camera? not usually USB camera that support RGB colors.
Could you tell me the details of monochrome USB camera, such as product name, maker, URL.

(2) Does your monochrome USB camera is able to use this library?
Can you can get valid image via camera.GetBitmap() method? or invalid image?

@secile
Copy link
Owner

secile commented Dec 11, 2024

As I read your message and message in another issue,
your camera's image format may be Y8 (also called Y800).

There is a 'BufferToBitmap' function in this library.
This function requires 1 argument byte[] buffer.
BuffetToBitmap assumes that buffer image format is RGB24.
But your camera's format is Y8. This is the problem, I think.

So you may have to modify BuffetToBitmap function.
I have never used Y8 format, but as long as I searched in google, it may not so difficult.

@rajeshamudala
Copy link
Author

rajeshamudala commented Dec 13, 2024

Hi, thanks for the reply.

Here are the links to the cameras we are using:

  1. (https://www.e-consystems.com/industrial-cameras/ov2311-monochrome-global-shutter-camera.asp)
  2. (https://www.e-consystems.com/ar0521-monochrome-usb-nir-camera.asp)

When I tried changing to the YUV2 format and modified the bitmap conversion to monochrome, I was able to get the grayscale feed.

However, I am facing an issue with Still Pin Capture:

  1. The captured images are being saved as corrupted.
  2. The images are in RGB format instead of grayscale.

@secile
Copy link
Owner

secile commented Dec 14, 2024

Currently, the library is not support monochrome camera.
I would like to support monochrome USB camera if possible.

(1) let me know result of below, and which format you selected?

foreach (var item in formats) Console.WriteLine(item);

(2) are you define 'USBCAMERA_WPF'? 'USBCAMERA_BYTEARRAY'?

(3) are you use with WinForms? WPF?

(4) if possible, could you upload you modified UsbCamera.cs.

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

2 participants