在DirectShow预览窗口上写文本 [英] Write Text on DirectShow Preview Window
本文介绍了在DirectShow预览窗口上写文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在预览窗口上写一个文字或标签,使用directshow显示网络摄像头预览。
- >当屏幕上有预览或帧时,文本将显示在窗口上。
这里是否有人对此有所了解,怎么做?
谢谢!
I want to write a text or a label on Preview Window that is showing the webcam preview using directshow.
-> Text will be on window when there will be preview or frames on screen.
Is here anyone having idea about this, how to do it?
Thanks!
推荐答案
你通常做的是在视频上叠加文字 - 你不需要添加标签。
有一些过滤器可以让你这样做,例如 C#中的纯.NET DirectShow过滤器 [ ^ ]描述了一个添加文本的过滤器视频。
What you normally do is overlay text on a video - you don''t need to add a label.
There are some filters that would allow you to do this for e.g. Pure .NET DirectShow Filters in C#[^] describes a filter that adds text to a video.
另一个选项是将视频和文本渲染到纹理,SDK中包含如何将视频渲染到纹理的示例:
来源:(SDK root)\ Samples \ C ++ \DirectShow \Players\Texture3D [ ^ ]
要渲染文本,你可以这样做:
启用透明度:
Another option is to render bot the video and the text to a texture, and an example on how to render the video to a texture is included with the SDK:
Source: (SDK root)\Samples\C++\DirectShow\Players\Texture3D[^]
To render the text you do something like this:
Enable transparency:
device.RenderState.AlphaTestEnable = true;
device.RenderState.AlphaFunction = Compare.Greater;
device.RenderState.ReferenceAlpha = 0;
创建字体和精灵:
Create font and sprite:
D3DX10CreateFont(device, 16, 0, FW_BOLD, 0, FALSE,
DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, ANTIALIASED_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, L"Verdana", &font);
D3DX10CreateSprite(device, 256, &sprite);
渲染:
Render:
hr = sprite->Begin(0);
std::wstring left = L"Hurray, text on a sprite!";
RECT r;
r.top = 0;
r.bottom = window->height;
r.left = 0;
r.right = window->width;
hr = font->DrawTextW(sprite, left.c_str(), -1, &r,
DT_LEFT | DT_TOP, D3DXCOLOR(0.0f, 1.0f, 0.0f, 1.0f));
hr = sprite->End();
祝你好运
Espen Harlinn
Best regards
Espen Harlinn
请看我对这个问题的评论。
你能简单地对视频进行标签控制吗?不花哨,但很简单。
否则,挖掘DirectX;但它需要时间和神经......
-SA
Please see my comment to the question.
Could you simply place a label control over the video? Not fancy, but simple.
Otherwise, dig in DirectX; but it will need time and nerve…
—SA
这篇关于在DirectShow预览窗口上写文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文