Author: Ren chengming,Hua Qing vision embedded training center lecturer.
1. Compile the HTML webpage: video.html.
The webpage content is as follows:
<! 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) In the early stage, mjpg-streamer was transplanted to obtain the video stream.
(2) Run "http: // 192.168.1.200: 8080 /? Action = stream to view video stream capture.
<TD Height = "500"> </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>
& Lt; TD width = "195" & gt; & lt; P & gt;
<Label> </label>
<A href = "choose.html"> choose/A> <br/>
</P> </TD>
& Lt; TD width = "289" & gt;
<Div align = "center">
(3) port The Boa Server in the early stage.
(4) Click the "single shot" button on the webpage and call CGI: picture. cgi on the server to collect image data.
<Input type = "Submit" name = "button3" id = "button3" value = "picture"/> & nbsp; <a href = "cgi-bin/picture. cgi "> single shot </a> </div> </TD>
</Tr>
</Table>
</Form> </TD>
</Tr>
</Table>
</Body>
</Html>
2. cgi program used to obtain images: picture. C.
CGI program content is as follows:
# 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) Use the corresponding operation variable of the folder in the file system:
Dir * dir;
Struct dirent * dirp;
(2) The CGI program displays the relevant webpage information in the browser:
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/5o/xhtml\ "> 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> Fprintf (cgiout, "<body> ");
Fprintf (cgiout, "<H1 align = \" Left \ "> history picture:
(3) Write a CGI program to read image files in the file system
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) display the image file to the webpage through CGI program:
Fprintf (cgiout, "<Div align = \" center \ "> d_name );
Fprintf (cgiout, "</div> ");
}
}
Fprintf (cgiout, "</body> Return 0;
}
For embedded and 3G related resources and learning, click: Embedded Development Video Android training 3G training QT Development Video Iot training IoT technology video embedded learning