Our application uses a DirectShow C# wrapper to do video capture from color
cameras (using MEDIASUBTYPE_UYVY), which we then convert to black and white
for further processing. We now want our application to support true
monochrome cameras, which obviously do not support YUV, however I cannot find
a MEDIASUBTYPE_* mode corresponding to monochrome (256 shades of gray). I
was hoping for a monochrome mode that both color and monochrome cameras would
support alike.
The wrapper defines the following GUIDs for media sub-types. Is it missing
values for monochrome or am I going the wrong way about it?
MEDIASUBTYPE_YUYV
MEDIASUBTYPE_UYVY
MEDIASUBTYPE_IYUV
MEDIASUBTYPE_DVSD
MEDIASUBTYPE_RGB1
MEDIASUBTYPE_RGB4
MEDIASUBTYPE_RGB8
MEDIASUBTYPE_RGB565
MEDIASUBTYPE_RGB555
MEDIASUBTYPE_RGB24
MEDIASUBTYPE_RGB32
MEDIASUBTYPE_Avi
MEDIASUBTYPE_Asf
And - just in case - here is my code for setting up the video header :
int width = CaptureHeight;
int height = CaptureWidth;
int bytesPerPixel = 3;
int imageSize = ((width + 3) & ~3)*height*bytesPerPixel;
AMMediaType media = new AMMediaType();
media.majorType = MediaType.Video;
media.subType = MediaSubType.UYVY;
media.formatType = FormatType.VideoInfo;
media.formatSize = Marshal.SizeOf(typeof(VideoInfoHeader));
media.formatPtr = Marshal.AllocCoTaskMem(media.formatSize);
VideoInfoHeader video = new VideoInfoHeader();
video.BmiHeader.Size = Marshal.SizeOf(typeof(VideoInfoHeader));
video.BmiHeader.Width = width;
video.BmiHeader.Height = height;
video.BmiHeader.ImageSize = imageSize;
video.BmiHeader.Planes = 1;
video.BmiHeader.BitCount = 24;
video.AvgTimePerFrame = 666666;
Marshal.StructureToPtr(video, media.formatPtr, false);
IAMStreamConfig streamConfig = DsUtils.FindStreamConfigInterface(bld, flt);
streamConfig.SetFormat(media);
****************
Thanks in advance for any hint...
Best regards,
Mathieu
Regards,
Mathieu
gr. Pjotr
If you simply remove the U and V channels, all that'd be left is
monochrome. So one option for media output for a "256 shade of gray"
monochrome output would actually be any 8-bit YUV format, with the U
and V channels set to black. This isn't too surprising, given that
YUV's major appeal was once its backwards compatibility with black and
white television sets.
I've never heard of Y_MONO, but were I to speculate, the "Y" probably
corresponds with the luma channel in YUV formats.
First, thank you very much for your reply. I didn't know companies could
create custom mediasubtypes. In our case, we only need to support cameras
from a specific manufacturer (up to now), and both the color and B/W cameras
from that manufacturer support the "Y_MONO" subtype.
So I guess the question now is, how could I find out the GUID associated
with that custom "Y_MONO" subtype? Because if I knew the GUID, I could
support it easily... GraphEdit does not display any guid for that pixel
format. I have also searched the registry for the string "Y_MONO", just in
case it would be registered there, with no success.
Unless you have any idea how to obtain that information, I guess I will have
to contact the manufacturer...
Thanks again...
Regards,
Mathieu
Thank you very much for your reply. It really makes sense, and in fact
that's exactly what we are already doing for our color cameras (discarding
the U and V channels), because we only want a monochrome output, even with
color cameras.
Unfortunately, it appears that the monochrome camera does not accept any of
the YUV formats (as if it was too picky!). So I guess I will have to find
the GUID for the "Y_MONO" format.
--
Mathieu Frenette
Software Architect
SolarisLabs.com
*********
Hello Mathieu,
For Y_MONO operation our filters commonly use the MEDIASUBTYPE_Y800 GUID. If
you don't have it defined in any of the headers it can be defined as:
DEFINE_GUID(MEDIASUBTYPE_Y800, 0x30303859, 0x0000, 0x0010, 0x80, 0x00,
0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
Since in the future you might want to support the Y_MONO_16 format as well,
let me inform you that MEDIASUBTYPE_Y160 is used for it, defined as:
DEFINE_GUID(MEDIASUBTYPE_Y160, 0x30363159, 0x0000, 0x0010, 0x80, 0x00,
0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
Regards,
Konstantinos Sambanis
Senior Software Engineer
Unibrain
*********
So I will try defining that GUID in my code and post the results!
Thanks to all...
Regards,
Mathieu.
> If anybody hits a similar problem, let me include here the reply that I've
> got from the Unibrain support team (we are using Unibrain's Fire-I cameras)...
...
Thank you for posting this. It will be useful for others :)
--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution
The problem with Y800 is that, as far as I know, there is no standard codec
to convert it to RGB. I'm working with a company that has a mono camera,
and I'm expanding it to UYVY in the driver because of this.
If anybody has a simple Y800 codec, I'd change it back.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
Honestly, I don't know what the benefit of using such an obscure
output type would be. Many (most?) filters probably wouldn't accept
Y800 as an input type, so from a design standpoint, it seems like this
could be pretty restrictive. I'd much sooner use UYVY, YV12, YUY2,
etc. I suppose one could argue that it's more efficient, but going to
a 12 or 16 bpp format would have a negligible impact on performance,
especially on any modern PC.
As for converting, once the U and V channels are set to black (I think
128 would be the value), couldn't you just use the regular conversion
method?
...the Y channel is factored into each of the RGB components, so it
seems like it'd work. But maybe I'm not understanding the issue.
>If anybody hits a similar problem, let me include here the reply that I've
>got from the Unibrain support team (we are using Unibrain's Fire-I cameras)...
>
>*********
>
>Hello Mathieu,
>
>For Y_MONO operation our filters commonly use the MEDIASUBTYPE_Y800 GUID. If
>you don't have it defined in any of the headers it can be defined as:
> DEFINE_GUID(MEDIASUBTYPE_Y800, 0x30303859, 0x0000, 0x0010, 0x80, 0x00,
>0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
>
>Since in the future you might want to support the Y_MONO_16 format as well,
>let me inform you that MEDIASUBTYPE_Y160 is used for it, defined as:
> DEFINE_GUID(MEDIASUBTYPE_Y160, 0x30363159, 0x0000, 0x0010, 0x80, 0x00,
>0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
>
The YUV transform filter at www.gdcl.co.uk supports FOURCC Y800 for
8-bit monochrome and FOURCC('Y16 ') for 16-bit monochrome and converts
between these and other yuv and rgb formats. It doesn't recognise the
FOURCC('Y160') format.
G