简体   繁体   English

Windows Mobile:使用C#的手机摄像头

[英]Windows Mobile: using phone's camera with C#

I want to show the image that mobile phone's camera its taking on a control in a WinForm. 我想在WinForm中显示手机摄像头拍摄控件的图像。 The idea is that my application works like camera's program. 我的想法是我的应用程序像摄像机程序一样工作。 I want to show the image like if the user is going to take a photo. 我想要显示图像,如果用户要拍照。

How can I do that? 我怎样才能做到这一点? Can I do that? 我能这样做吗?

If you need more details ask me. 如果您需要更多细节,请问我。

Thank you! 谢谢!

Not very sure what you need, but you may try using Microsoft.WindowsMobile.Forms.CameraCaptureDialog: 不太确定你需要什么,但你可以尝试使用Microsoft.WindowsMo​​bile.Forms.CameraCaptureDialog:

    string originalFileName;
    using (CameraCaptureDialog dlg = new CameraCaptureDialog()) {
        dlg.Mode = CameraCaptureMode.Still;
        dlg.StillQuality = CameraCaptureStillQuality.Low;
        //dlg.Resolution = new Size(800, 600);
        dlg.Title = "Take the picture";
        DialogResult res;
        try {
            res = dlg.ShowDialog();
        }
        catch (Exception ex) {
            Trace.WriteLine(ex);
            return null;
        }

        if (res != DialogResult.OK)
            return null;
        this.Refresh();
        originalFileName = pictureFileName = dlg.FileName;
    }

Later Edit: Some of you might find useful this link, too: http://community.intermec.com/t5/General-Development-Developer/CN50-MS-Camera-Capture-Dialog-generates-error/mp/12881#M4083 稍后编辑:你们中的一些人也可能会发现这个链接很有用: http//community.intermec.com/t5/General-Development-Developer/CN50-MS-Camera-Capture-Dialog-generates-error/mp/12881# M4083

What you want is a preview, not the capture, which is far more difficult. 你想要的是预览,而不是捕捉,这要困难得多。 The best (and maybe only) solution is to insert a DShow Filter into the filtergraph to pipe the preview window to where you want. 最好的(也许是唯一的)解决方案是在过滤器图形中插入一个DShow过滤器,将预览窗口传送到您想要的位置。

COM is a bear in the Compact Framework, and DShow is tough no matter what platform you're on. COM是Compact Framework中的一只熊,无论您使用什么平台,DShow都很难。 There are some resources online, like the DShow.NET library at sourceforge , and Alex Mogurenko's blog , but nothing specific to creating a capture. 网上有一些资源,比如sourceforge上DShow.NET库Alex Mogurenko的博客 ,但没有具体的创建捕获。

There is a native capture sample in the WinMo SDK that would be a useful guide to getting you there. WinMo SDK中有一个本机捕获示例,它可以帮助您实现目标。

I think you should program against the hardware directly using a sdk or something similar. 我认为你应该使用sdk或类似的东西直接对硬件进行编程。

Since programming against hardware directly is usually in c/c++ the sdk will probably be native. 由于直接针对硬件编程通常是用c / c ++编写的,因此sdk可能是原生的。 So either you probably have to use pinvoke and the unsafe keyword. 所以要么你可能必须使用pinvoke和unsafe关键字。

But first you should find the way to access the camera, and since this is hardware dependant you can start on the website of the phone's manufacturere. 但首先你应该找到访问相机的方法,因为这取决于硬件,你可以从手机制造商的网站开始。

OpenNetCF.org检查SmartDeviceFramework有一些PocketPC工具,包括从Camera捕获帧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM