RetroZilla/modules/plugin/samples/SanePlugin/test/camera.html

168 lines
3.2 KiB
HTML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<HTML>
<HEAD>
<TITLE>CPia Digital Camera Test Application</TITLE>
</HEAD>
<BODY>
<P>
This is a test page for grabing frames from a USB Cpia camera
using the v4l (Video4Linux) SANE module.
</P>
<TABLE>
<TR>
<TD>
<CENTER>
<EMBED type="application/X-sane-plugin"
name="camera"
onScanComplete="ScanCompleteCallback()"
onInitComplete="InitCompleteCallback()"
device="v4l:/dev/video"
width="400" height="400"
line_width="0" line_style="solid">
</CENTER>
</TD>
<TD>
<CENTER>
<!-- Start grabbing frames once a second -->
<INPUT type="button" onclick="start()" value="Start">
<!-- Stop grabbing frames -->
<INPUT type="button" onclick="stop()" value="Stop">
<!-- Save the current image to a file -->
<INPUT type="button" onclick="save()" value="Save"><BR>
<input type="button" onclick="doDump()" value="Dump">
<input type="button"
onclick="document.camera.nsISanePluginInstance.ScanImage()"
value="Single Shot">
</CENTER>
</TD>
</TR>
</TABLE>
<input type="text" id="status" size="20">
<!--
<textarea id="status" rows="20" cols="80"></textarea>
-->
<SCRIPT>
// globals
var gdelay = 500;
var multigrab = false;
var ingrab = false;
function sdump(str)
{
var status = document.getElementById('status');
status.value = str;
dump(str + "\n");
}
function doDump()
{
var aCamera = new Object;
try {
aCamera = document.camera.nsISanePluginInstance;
sdump("ActiveDevice = " + aCamera.ActiveDevice + "\n" +
"State = " + aCamera.State + "\n" +
"Quality = " + aCamera.Quality + "\n" +
"Method = " + aCamera.Method + "\n" +
"DeviceOptions = " + aCamera.DeviceOptions + "\n" +
"ImageParameters = " + aCamera.ImageParameters + "\n" +
"AvailableDevices = " + aCamera.AvailableDevices + "\n");
} catch (ex) {
sdump("Error trying dump data: " + ex + "\n");
}
}
function grabImage()
{
if (multigrab || ingrab)
return;
try {
document.camera.nsISanePluginInstance.ScanImage();
} catch (ex) {
sdump("Error trying to grab image!\n");
}
}
function save()
{
document.camera.nsISanePluginInstance.SaveImage();
}
function InitCompleteCallback()
{
try {
var aCamera = document.camera.nsISanePluginInstance;
aCamera.Quality = 100;
aCamera.ScanImage();
sdump("Initialization complete!\n");
} catch (ex) {
sdump("Error trying to set additional device specific parameters!" + ex);
}
}
function ScanCompleteCallback()
{
sdump("Scan Complete!\n");
ingrab = false;
if (multigrab)
window.setTimeout("document.camera.nsISanePluginInstance.ScanImage()",
gdelay);
}
function stop()
{
multigrab = false;
}
function start()
{
if (multigrab)
return;
multigrab = true;
if (!ingrab) {
try {
sdump("About to scan image!\n");
ingrab = true;
document.camera.nsISanePluginInstance.ScanImage();
} catch (ex) {
sdump("Error trying to grab frame!\n" + ex + "\n");
}
}
}
</SCRIPT>
</BODY>
</HTML>