0

ユーザーが Web カメラから画像をキャプチャしてサーバー上のデータベースに保存できる ASP.Net Web サイトを作成しようとしています。TWAIN を使用してみましたが、これをサポートする新しいカメラが見つからないようです。Silverlight と WIA を使用しようとする場合も同様です。誰かがこれを行うことに成功しましたか?

クライアント コンピューターには、私が推奨する Web カメラが搭載されているので、動作するモデルを知っている場合は共有してください。Microsoft LifeCam と Logitech の両方を試しましたが、うまくいきませんでした。

あなたがこれをやったことがあるなら、私は本当に助けていただければ幸いです。ありがとうございました。

4

3 に答える 3

1

If you're targeting the newer browsers (those that support the WebRTC getUserMedia method), then Photobooth.js may be an option for you.

Quoted from WebMonkey: 'The latest WebRTC hotness to catch our eye is developer Wolfram Hempel’s Photobooth.js, a JavaScript library for working with a device’s camera.'

http://www.webmonkey.com/2012/12/add-an-html5-webcam-to-your-site-with-photobooth-js/

And the lib itself:

http://wolframhempel.com/2012/12/02/photobooth-js/

Hope it works for you!

于 2012-12-27T18:00:49.793 に答える
0

asp.netはサーバー側のテクノロジであり、クライアント側のWebカメラに接続する機能はありません。お使いのブラウザは高度にサンドボックス化されており、ユーザーのWebカメラへのアクセスを許可する可能性はほとんどありません。

WebカメラにアクセスするためのFlashまたはSilverlightコンポーネントの構築を検討してください。

これの例外は、多くのモバイルプラットフォームで、ブラウザが<input type="file" />タグを介してカメラと画像ストアにアクセスできることです。これはAndroidでしばらくの間当てはまり、Safariv6のオプションになりました。接続されているWebカメラに直接アクセスできるデスクトップブラウザはありません。

賞の回避策は、ユーザーが写真を撮り、ファイルのアップロードを介してそれらにアクセスすることです。

于 2012-12-27T17:46:26.247 に答える
0

ユーザーに Google Chrome Frame をコンピュータにインストールしてもらい、キャンバス タグを使用して画像を取得することで、私が望んでいたことを達成することができました。ここにいくつかのサンプルコードがあります:

    <div>

        <p id="status" style="color:red">
            <noscript>JavaScript is disabled.</noscript>
        </p>


        <table>
            <tr>
                <td>
                    <input id="btnTakePicture" type="button" value="Take Picture"; />
                </td>
                <td>
                    <input id="btnSave" type="button" value="Save Picture"; />
                </td>
            </tr>
        </table>


        <asp:Button ID="btnSavePicture" runat="server" Text="HiddenSave" OnClick="btnSavePicture_Click" CssClass="hiddencol"  />

        <asp:Panel ID="pnlHide" runat="server" style="display:none" >    
            <textarea id="eventdata" rows="18" cols="1" style="width: 100%" runat="server"></textarea>
        </asp:Panel>

        <script type="text/javascript">

                navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
                navigator.mozGetUserMedia || navigator.msGetUserMedia;

                var webcam = (function () {


                    var video = document.createElement('video'),
                    photo = document.createElement('canvas');

                    function play() {

                        if (navigator.getUserMedia) {

                            navigator.getUserMedia({ video: true, audio: true, toString: function () { return "video,audio"; } }, onSuccess, onError);

                        } else {

                            changeStatus('getUserMedia is not supported in this browser.', true);
                        }

                    }

                    function onSuccess(stream) {

                        var source;

                        if (window.webkitURL) {

                            source = window.webkitURL.createObjectURL(stream);

                        } else {

                            source = stream; // Opera and Firefox
                        }


                        video.autoplay = true;

                        video.src = source;

                        changeStatus('Connected.', false);

                    }

                    function onError() {

                        changeStatus('Please accept the getUserMedia permissions! Refresh to try again.', true);

                    }

                    function changeStatus(msg, error) {
                        var status = document.getElementById('status');
                        status.innerHTML = msg;
                        status.style.color = (error) ? 'red' : 'green';
                    }


                    // allow the user to take a screenshot
                    function setupPhotoBooth() {
                        //var takeButton = document.createElement('button');
                        var takeButton = document.getElementById('btnTakePicture');
                        //takeButton.innerText = 'Take Picture';
                        takeButton.addEventListener('click', takePhoto, true);
                        //document.body.appendChild(takeButton);

                        //var saveButton = document.createElement('button');
                        var saveButton = document.getElementById('btnSave');
                        //saveButton.id = 'btnSave';
                        //saveButton.innerText = 'Save Picture';
                        saveButton.disabled = true;
                        saveButton.addEventListener('click', savePhoto, true);
                        //document.body.appendChild(saveButton);

                    }

                    function takePhoto() {

                        // set our canvas to the same size as our video
                        photo.width = video.width;
                        photo.height = video.height;

                        var context = photo.getContext('2d');
                        context.drawImage(video, 0, 0, photo.width, photo.height);

                        // allow us to save
                        var saveButton = document.getElementById('btnSave');
                        saveButton.disabled = false;

                        var data = photo.toDataURL("image/png");

                        data = data.replace("image/png", "");

                        document.getElementById("<%= eventdata.ClientID %>").value = data;

                    }

                    function savePhoto() {
                        //                        var data = photo.toDataURL("image/png");

                        //                        data = data.replace("image/png", "image/octet-stream");

                        //                        document.getElementById("<%= eventdata.ClientID %>").value = data;
                        //                        document.location.href = data;

                        SendBack();
                    }

                    return {
                        init: function () {

                            changeStatus('Please accept the permissions dialog.', true);

                            video.width = 320;
                            video.height = 240;

                            document.body.appendChild(video);
                            document.body.appendChild(photo);

                            navigator.getUserMedia || (navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia);

                            play();
                            setupPhotoBooth();

                        } ()

                    }


                })();

            function SendBack() {
                var btn = document.getElementById("<%= btnSavePicture.ClientID %>");
                btn.click();
            }

    </script>

    </div>
于 2013-01-23T14:43:37.650 に答える