首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用网络摄像头拍摄照片,并将照片直接或自动上传到我的php表单中

问如何使用网络摄像头拍摄照片,并将照片直接或自动上传到我的php表单中
EN

Stack Overflow用户
提问于 2014-05-16 01:34:44
回答 1查看 13K关注 0票数 2

我一直在尝试构建一个数据捕获和生物识别(指纹)表单,其中网络摄像头连接到PC,这样当您单击添加/上传图像按钮时,系统将自动启动网络摄像头,当您使用网络摄像头拍摄时,图像会自动上传到表单。

一个简单的例子是申请新驾照的过程。警察会要求你填写一张表格,表格数据会被传输到软件中,然后你会被要求站在相机前拍照。在某些情况下,申请人的指纹也会被采集并上传到系统中。

我正在开发的web应用程序使用Dreamweaver,PHP和MySQL。现在我只熟悉PHP。不懂Java编程。

欢迎您的提示,并提前感谢您

麦克

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-26 20:19:13

请尝试使用此代码获取图像捕获from agurchand on TheOnlyTutorials.com

index.html

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
    <title>WebCam jQuery and PHP script</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
 
    <style>
        #camera_wrapper, #show_saved_img{float:left; width: 650px;}
    </style>
 
    <script type="text/javascript" src="scripts/webcam.js"></script>
    <script>
        $(function(){
            //give the php file path
            webcam.set_api_url( 'saveimage.php' );
            webcam.set_swf_url( 'scripts/webcam.swf' );
            webcam.set_quality( 100 ); // Image quality (1 - 100)
            webcam.set_shutter_sound( true ); // play shutter click sound
 
            var camera = $('#camera');
            camera.html(webcam.get_html(600, 460));
 
            $('#capture_btn').click(function(){
                //take snap
                webcam.snap();
            });
 
            //after taking snap call show image
            webcam.set_hook( 'onComplete', function(img){
                $('#show_saved_img').html('<img src="' + img + '">');
                //reset camera for next shot
                webcam.reset();
            });
 
        });
    </script>
</head>
<body>
    <h1>Capture photo with Web Camera - PHP Script</h1>
 
    <!-- camera screen -->
    <div id="camera_wrapper">
    <div id="camera"></div>
    <br />
    <button id="capture_btn">Capture</button>
    </div>
    <!-- show captured image -->
    <div id="show_saved_img" ></div>
</body>
</html>


Saveimage.php

<?php
 
//set random name for the image, used time() for uniqueness
 
$filename =  time() . '.jpg';
$filepath = 'saved_images/';
 
//read the raw POST data and save the file with file_put_contents()
$result = file_put_contents( $filepath.$filename, file_get_contents('php://input') );
if (!$result) {
    print "ERROR: Failed to write data to $filename, check permissionsn";
    exit();
}
 



echo $filepath.$filename;
?>

有关the source部分,请参阅PHP。

还可以从https://code.google.com/p/jpegcam/下载webcam.js库

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23685086

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档