Directdraw:旋转视频流

发布于 2024-08-22 01:05:45 字数 1107 浏览 10 评论 0原文

问题

Windows Mobile / Directdraw:旋转视频流

视频预览正在工作,我现在需要的只是旋转图像的方法。我认为处理这个问题的唯一方法是编写一个基于 CTransformFilter 的自定义过滤器,它将为您旋转相机图像。如果您可以帮助我解决这个问题,例如帮助我用我有限的 DirectDraw 知识开发这个过滤器,那么赏金就是您的。

背景/上一个问题

我目前正在为移动设备(HTC HD2、Windows Mobile 6)开发应用程序。该程序需要做的事情之一是使用内置相机拍照。以前,我使用 Windows Mobile 6 SDK 提供的 CameraCaptureDialog 来完成此操作,但我们的客户想要一个更加用户友好的解决方案。

这个想法是在控件中预览相机的视频流,并在单击控件时使用相机的照片功能拍摄高分辨率图片(> = 2 兆像素)。我们对此主题进行了一些研究,发现实现此目的的最佳方法似乎是使用 Direct Draw。

缺点是我从未真正使用过任何本机 Windows API,而且我的 C++ 水平相当糟糕。除此之外,我在某处读到 HTC 手机的 Direct Draw 支持特别糟糕,您将不得不使用未记录的本机 HTC 库调用来拍摄高质量的照片。

好消息是,一家公司邀请我们开发符合上述规格的控件。他们估计大约需要 10 天,这引发了我们是否可以在合理的时间内自行开发这种控制的讨论。

现在我的工作是研究哪种替代方案更好。不用说,研究整个架构的时间太少了开发一个演示,这让我想到了以下问题:

问题不再相关!

  • 你们中有人有类似项目的经验吗?您有什么建议?
  • 是否有一个很好的 Direct Draw 源代码示例来处理视频预览和图像捕获?

Problem

Windows Mobile / Directdraw: Rotate video stream

The video preview is working, all I need now is a way to rotate the image. I think the only way to handle this is to write a custom filter based on CTransformFilter that will rotate the camera image for you. If you can help me to solve this problem, e.g. by helping me to develop this filter with my limited DirectDraw knowledge, the bounty is yours.

Background / Previous question

I'm currently developing an application for a mobile device (HTC HD2, Windows Mobile 6). One of things the program needs to do is to take pictures using the built-in camera. Previously I did this with the CameraCaptureDialog offered by the Windows Mobile 6 SDK, but our customer wants a more user-friendly solution.

The idea is to preview the camera's video stream in a control and take a high resolution picture (>= 2 megapixels) using the camera's photo function, when the control is clicked. We did some research on the topic and found out the best way to accomplish this seems to be using Direct Draw.

The downsides are that I never really used any native windows API and that my C++ is rather bad. In addition to this I read somewhere that the Direct Draw support of HTC phones is particularity bad and you will have to use undocumented native HTC libraries calls to take high quality pictures.

The good news is that a company offered us to develop a control that meets the specifications stated above. They estimated it would take them about 10 days, which lead to the discussion if we could develop this control ourself within a reasonable amount of time.

It's now my job to research which alternative is better. Needless to say it's far too less time to study the whole architecture and develop a demo, which lead me to the following questions:

Questions no longer relevant!

  • Does any of you have experience with similar projects? What are your recommendations?
  • Is there a good Direct Draw source code example that deals with video preview and image capturing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坠似风落 2024-08-29 01:05:45

如果您查看 EZRGB24 示例,您就会了解简单视频转换过滤器的基础知识。

您需要对示例执行两件事,以使其达到您想要的效果。

1) 您需要将 x,y 复制到 y,x。
2) 您需要告诉媒体样本,样本现在是高度 x 宽度,而不是宽度 x 高度。

请记住,最终图像将具有完全相同的像素数。

解决1比较简单。您可以通过执行“x + (y * Width)”来计算像素的位置。因此,您可以通过这种方式逐步计算每个 x 和 y 的位置,然后将其写入“y + (x * Height)”。这将转置图像。当然,如果没有步骤2,这看起来会完全错误。

要解决问题 2,您需要获取输入样本的 AM_MEDIA_TYPE。然后,您需要找出 formatType 是什么(可能是 FormatType_VideoInfo 或 FormatType_VideoInfo2)。因此,您可以将 AM_MEDIA_TYPE 的 pbFormat 成员强制转换为 VIDEOINFOHEADER 或 VIDEOINFOHEADER2 (取决于 FormatType)。您现在需要将 VIDEOINFOHEADER[2]::bmiHeader.biWidth 和 biHeight 设置为输入媒体样本的 biHeight 和 biWidth(分别)。其他所有内容都应与输入 AM_MEDIA_TYPE 相同。

我希望这能有所帮助。

Well if you look at the EZRGB24 sample you get the basics of a simple video transform filter.

There are 2 things you need to do to the sample to get it to do what you want.

1) You need to copy x,y to y,x.
2) You need to tell the media sample that the sample is now Height x Width instead of Width x Height.

Bear in mind that the final image will have exactly the same number of pixels.

To solve 1 is relatively simple. You can calculate the position of a pixel by doing "x + (y * Width)". So you step through each x and y calculate the position that way and then write it to "y + (x * Height)". This will transpose the image. Of course without step2 this will look completely wrong.

To solve 2 you need to get the AM_MEDIA_TYPE of the input sample. You then need to find out what the formatType is (Probably FormatType_VideoInfo or FormatType_VideoInfo2). You can thus cast the pbFormat member of AM_MEDIA_TYPE to either a VIDEOINFOHEADER or a VIDEOINFOHEADER2 (Depending on the FormatType). You need to now set VIDEOINFOHEADER[2]::bmiHeader.biWidth and biHeight to the biHeight and biWidth (respectively) of the input media sample. Everything else should be the same as the input AM_MEDIA_TYPE.

I hope that helps a bit.

じ违心 2024-08-29 01:05:45

这个问题将帮助您了解有关 DirectDraw 的一些详细信息。我前段时间对此做了一些研究,我能找到的最好的就是这个博客 post(在上面的问题中也提到过)。这篇文章介绍了 SDK 中 CameraCapture 示例的扩展。

不过,不要抱有太高的期望。看来预览和拍摄的照片只能在小分辨率下工作。尽管 DirectDraw 确实描述了配置分辨率的方法,不能保证驱动程序能够正确实现这一点。

因此,根据我的经验,您所读到的内容是真实的。唯一的方法是使用 HTC 驱动程序。因此,如果您不想花费无尽的时间进行逆向工程以获得可疑的结果,请让其他人为您完成这项工作。如果您想尝试一下,请尝试 xda-developers 论坛

This question will help you get some details about DirectDraw. I did some research about this some time ago and the best I could find was this blog post (also mentioned in the above question). The post presents an extension of the CameraCapture sample in the SDK.

However, don't have high expectations. It seems that the preview and the picture taken will only work in small resolution. Although DirectDraw does describe a way of configuring the resolution, there is no guarantee that this will be properly implemented by the driver.

So from my experience what you have read is true. The only way to do it will be to use HTC drivers. So, if you don't want to spend endless days in reverse engineering for a doubtful result, let someone else do the job for you. If you want to give it a shot, try xda-developers forum.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文