起航学习网

- 让每个人都能学到最前沿新知识、新技能!
起航学习网
当前位置: 起航学习网 > 短期培训 > 编程语言 > 如何通过html和cgi实现拍照显示功能

如何通过html和cgi实现拍照显示功能

时间:2018-08-13 13:27:34来源:编程网 作者:IT培训网 已有: 名学员访问该课程

  快捷搜索:htmlcgi

前言:通过html和cgi实现拍照显示功能,这个难做吗,什么是cgi呢?

通过html和cgi实现拍照显示功能,这个难做吗,什么是cgi呢?

1. 编写html网页 :video.html。

网页内容如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>video</title>

<style type="text/css">

<!--

.STYLE1 {

font-size: xx-large;

font-style: italic;

color: #0033FF;

}

-->

</style>

</head>

<body>

<table width="652" height="163" background="images/h3.png" border="0" align="center">

<tr>

<td><span class="STYLE1">example</span></td>

</tr>

</table><tr>

<div align="center">video</div>

<table width="500" align="center" height="561" border="0">

<tr>

(1)前期移植了mjpg-streamer 来获得视频流。

(2)通过“ http://192.168.1.200:8080/?action=stream”来查看视频流的捕获情况。

<td height="500"><img src="http://192.168.1.200:8080/?action=stream"/></td>

</tr>

<tr>

<td height="55"><form id="form3" name="form3" method="post" action="./cgi-bin/capture.cgi">

<table width="500" border="1" bgcolor="#CCFFFF" bordercolor="#5500FF">

<tr>

<td width="195"><p>

<label></label>

<a href="choose.html">choose /a><br />

</p></td>

<td width="289">

<div align="center">

(3)前期移植了boa服务器。

(4)点击网页上的“单拍”按钮后,调用服务器中的cgi:picture.cgi,对图像数据进行采集。

<input type="submit" name="button3" id="button3" value="picture" />&nbsp;&nbsp;&nbsp;<a href="cgi-bin/picture.cgi">单拍 </a></div></td>

</tr>

</table>

</form></td>

</tr>

</table>

</body>

</html>

2. 用于获取图片的cgi程序:picture.c .

Cgi程序内容如下:

#include <stdio.h>

#include"cgic.h"

#include <string.h>

#include <stdlib.h>

#include <unistd.h>

#include <errno.h>

#include <stddef.h>

#include <sys/stat.h>

#include <dirent.h>

#include <iconv.h>

#include <sys/types.h>

#include <sys/wait.h>

int cgiMain()

{

(1)使用文件系统中的文件夹相应的操作变量:

DIR *dir;

struct dirent *dirp;

(2)cgi程序将相关的网页信息到浏览器中显示:

cgiHeaderContentType("text/html");

fprintf(cgiOut, "<HTML>\n");

fprintf(cgiOut, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");

fprintf(cgiOut, " <html xmlns=\"http://www.w3.org/1999/xhtml\"><head>");

fprintf(cgiOut, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");

fprintf(cgiOut, "<link rel=\"stylesheet\" href=\"../images/style.css\" type=\"text/css\" /> <title>history Picture</title></head>");

fprintf(cgiOut, "<body>");

fprintf(cgiOut, "<H1 align=\"left\">history Picture:<H1>");

(3)编写cgi程序读取文件系统中的图片文件

if((dir = opendir("../pice/")) == NULL)

{

perror("fail to opendir");

return -1;

}

if(dir != NULL)

{

while((dirp = readdir(dir)) != NULL)

{

if(dirp->d_name[0] == '.') continue;

fprintf(cgiOut, "<div align=\"center\">");

fprintf(cgiOut,"%s",dirp->d_name);

fprintf(cgiOut, "</div>");

(4)通过cgi程序显示图片文件到网页:

fprintf(cgiOut, "<div align=\"center\"><img src=\"../pice/%s\" width=\"320\" height=\"240\" />",dirp->d_name);

fprintf(cgiOut, "</div>");

}

}

fprintf(cgiOut, "</BODY></HTML>");

return 0;

}

文章出自:http://qh.itpxw.cn/peixun/software/201842411.html

文章标题:如何通过html和cgi实现拍照显示功能



免责声明:本站文章均由入驻起航学习网的会员所发或者网络转载,所述观点仅代表作者本人,不代表起航学习网立场。如有侵权或者其他问题,请联系举报,必删。侵权投诉

(责任编辑:IT培训网)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
培训学校
IT培训网 访问该机构站点 报名留言 加为好友 用户等级:注册会员 用户级别:10 机构名称:IT培训网 联 系 人:罗老师 联系电话:13783581536 联系手机:13783581536 在线客服:起航学习网客服 在 线 QQ:起航学习网客服 电子邮件: 网站域名:http://www.itpxw.cn 注册时间:2016-07-18 11:07 最后登录:2024-02-20 13:02
推荐内容