worst_case: Bild aus Kamera laden

Beitrag lesen

OK ... wird gemacht, Zähne sind auseinander ;-)

Warum die Formatierung hier nicht passt, keine Ahnung. Mir geht es nur um das Bild neu zu laden. Die Steuerung der Kamera funktioniert. (drehen/schwenken/zoom/focus usw.)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Kamera Rechenreiniger</title>
    <meta HTTP-EQUIV="Content-Type" content="text/html ; charset=utf-8">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">

    <link rel="icon" type="image/png" href="gif/favicon/favicon.png">
    <link rel="stylesheet" type="text/css" href="/allgemein.css">

    <script src="/format.js" type="text/javascript"></script>

<style type="text/css">
	table { table-layout:fixed; position:absolute;border-collapse:collapse; border:2px solid #000000; border-collapse:separate ; border-spacing:2px;}
	th {font-family:verdana,Arial; font-size:12pt;border:1px solid #000000; background-color:#6DCEEE; text-align:center;}
	td {font-size:10pt; border:1px solid #000000;}
	.eingabe {color:blue; font-weight:bold; cursor:pointer;}
	.schalter {width:65px; height:50px; display:block; margin-left:auto; margin-right:auto; cursor:pointer;}
	.schaltertext {font-size:7pt; text-align:center;font-weight:bold;background-color:yellow}
	area {cursor:pointer;}
	input {cursor:pointer;}
</style>


<script language="JavaScript" type="text/javascript">
var upcam_url = "/kamera_maschine_1/";

var upcam_ptzObj = {
	"stop" : 0,
	"up" : 1,
	"down" : 2,
	"left" : 3,
	"right" : 4,
	"upleft" : 18,
	"upright" : 19,
	"downleft" : 20,
	"downright" : 21,
	"home" : 23,
	"vscan" : 24,
	"hscan" : 25,
	"zoomin" : 31,
	"zoomout" : 32,
	"focusin" : 33,
	"focusout" : 34 }

var xmlHttp= new XMLHttpRequest();
var xmlfehler=0;
var param;
var httpRequest;
var response;
var zufall;
var counter=0;
var TimerID;
var first_start=0;
var preload = new Image();


function uhrzeit_stellen()
{
const heute = new Date();

    var DatumZeit = heute.getFullYear() + '.' + (heute.getMonth()+1) + '.' + heute.getDate() + '.' + heute.getHours() + '.' + heute.getMinutes() + '.' + heute.getSeconds();
    var kommando = '..' + upcam_url + 'cgi-bin/hi3510/param.cgi?cmd=setservertime&-time=' + DatumZeit + '&-timezone=Europe%2FAthens&-dstmode=off' + '&usr=admin&pwd=admin';
    var camimage_obj = document.getElementById('camimage');
    camimage_obj.src = kommando;
    TimerID = setTimeout(bild_neuladen,1000);
}

function bild_neuladen()
{
    clearTimeout(TimerID);
    var kommando = '..' + upcam_url + 'cgi-bin/hi3510/mjpegstream.cgi?-chn=11' + '&-usr=admin&-pwd=admin';


    if (first_start == 0)
    {
	preload.src = document.getElementById('camimage').src = kommando;
	first_start = 1;
    }
    else
    {
	document.getElementById('camimage').src = preload.src;
	preload.src = kommando;
    }

    var e = document.getElementById("zeit");
    preload.onload = function() { bild_neuladen(); }
}

function upcam_ptzcmdSubmit(casename)
{
    var upcam_xmlhttp;

	if (window.XMLHttpRequest)
	{ // code fuer IE7+, Firefox, Chrome, Opera, Safari
	    upcam_xmlhttp = new XMLHttpRequest();
	}
	else
	{ // code fuer IE6, IE5
	    upcam_xmlhttp = new ActiveObject("Microsoft.XMLHTTP");
	}

	clearTimeout(TimerID);

	var kommando = '..' + upcam_url + 'cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act='+casename+'&-speed=45&usr=admin&pwd=admin';
	upcam_xmlhttp.open("get",kommando, true);
	upcam_xmlhttp.send(null);

	TimerID = setTimeout("bild_neuladen()", 2000);

}

function upcam_auswahl_position(number)
{
	for(i=1;i<=8;i++)
	{ farbe = document.getElementById('pos_' + i).style.backgroundColor = "#DCDCDC"; }
	document.getElementById('pos_' + number).style.backgroundColor = "green";
}
//#########################################################################
function upcam_position_laden()
{
var farbe;

    for(i=1;i<=8;i++)
    {
	farbe = document.getElementById('pos_' + i).style.backgroundColor;
	if (farbe == "green")
	{
	    clearTimeout(TimerID);
	    var  xmlHttp = new XMLHttpRequest();
	    var kommando = '..' + upcam_url + 'cgi-bin/hi3510/param.cgi?cmd=preset&-act=goto&-status=1&-number='+i+'&usr=admin&pwd=admin';
	    xmlHttp.open("get",kommando, true);
	    xmlHttp.send(null);
	    TimerID = setTimeout("bild_neuladen()", 2000);
	    break;
	}
    }
}

function upcam_position_speichern()
{
var farbe;

    for(i=1;i<=8;i++)
    {
	farbe = document.getElementById('pos_' + i).style.backgroundColor;
	if (farbe == "green")
	{
	    var  xmlHttp = new XMLHttpRequest();
	    var kommando = '..' + upcam_url + 'cgi-bin/hi3510/param.cgi?cmd=preset&-act=set&-status=1&-number='+i+'&usr=admin&pwd=admin';
	    xmlHttp.open("get",kommando, true);
	    xmlHttp.send(null);
	    alert("Position " + i + " wurde gespeichert");
	    break;
	}
    }
}

function upcam_position_loeschen()
{
var farbe;

    for(i=1;i<=8;i++)
    {
	farbe = document.getElementById('pos_' + i).style.backgroundColor;
	if (farbe == "green")
	{
	    if (confirm('Wollen Sie die Position: ' + i + ' wirklich löschen ?'))
	    {
		var  xmlHttp= new XMLHttpRequest();
		var kommando = '..' + upcam_url + 'cgi-bin/hi3510/param.cgi?cmd=preset&-act=set&-status=0&-number='+i+'&usr=admin&pwd=admin';
		xmlHttp.open("get",kommando, true);
		xmlHttp.send(null);
		alert("Position " + i + " wurde gelöscht");
		break;
	    }
	}
    }
}

function step_function(keycode)
{
    switch (keycode)
    {
	case 37:	// left
		upcam_ptzcmdSubmit('left');
		break;
	case 35:	// down & left
		upcam_ptzcmdSubmit('downleft');
		break;
	case 36:	// up & left
		upcam_ptzcmdSubmit('upleft');
		break;
	case 38:	// up
		upcam_ptzcmdSubmit('up');
		break;
	case 33:	// up & right
		upcam_ptzcmdSubmit('upright');
		break;
	case 39:	// up
		upcam_ptzcmdSubmit('right');
		break;
	case 34:	// down & right
		upcam_ptzcmdSubmit('downright');
		break;
	case 40:	// down
		upcam_ptzcmdSubmit('down');
		break;
	case 107:	// plus
		upcam_ptzcmdSubmit('zoomin');
		break;
	case 109:	// minus
		upcam_ptzcmdSubmit('zoomout')
		break;
	case 106:	// " mal (x)"
		upcam_ptzcmdSubmit('focusin');
		break;
	case 111:	// "geteilt (/)"
		upcam_ptzcmdSubmit('focusout');
		break;
    }
}
</script>
</head>

<body bgcolor="#DCDCDC" onload="uhrzeit_stellen();" onkeydown="step_function(event.keyCode);" onkeyup="upcam_ptzcmdSubmit('stop');">

<a id="adresse" style="position:absolute ; left:10px; top:25px;">.</a>

<!-- Kamerabild -->
<img src="" id="camimage" alt="Kamerabild" title="meine Kamera" style="position:absolute ; left:10 ; top:60 ; height:640px; width:1024px;">

<!-- Kamerasteuerung -->
    <img src="../gif/kamera/kamerasteuerung.png" usemap="#pt_map" id="ptImg" style="position:absolute; left:1050; top:60;"/>
	<map id="pt_map" name="pt_map">
	    <area id="ptzLeftUp" shape="poly" onMouseDown="upcam_ptzcmdSubmit('upleft')"  onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="6,55,26,24,53,7,74,52,61,60,52,73"/>
	    <area id="ptzUp" shape="poly" onMouseDown="upcam_ptzcmdSubmit('up')" onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="56,8,75,52,89,48,106,52,126,8,88,1"/>
	    <area id="ptzRightUp" shape="poly" onMouseDown="upcam_ptzcmdSubmit('upright')" onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="124,9,106,52,119,63,127,75,171,56,152,27"/>
	    <area id="ptzLeft" shape="poly" onMouseDown="upcam_ptzcmdSubmit('left')" onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="7,57,1,90,8,125,51,109,47,90,52,75"/>
	    <area id="vpatrol" shape="circle" onMouseDown="snapDown()" onmouseup="snapUp()" coords="90,90,39" />
	    <area id="ptzRight" shape="poly" onMouseDown="upcam_ptzcmdSubmit('right')" onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="171,58,128,76,131,89,128,104,172,123,177,88"/>
	    <area id="ptzLeftDown" shape="poly" onMouseDown="upcam_ptzcmdSubmit('downleft')" onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="51,108,9,126,26,154,55,170,73,129,61,120"/>
	    <area id="ptzDown" shape="poly" onMouseDown="upcam_ptzcmdSubmit('down')" onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="124,171,91,177,55,170,76,127,91,132,107,126"/>
	    <area id="ptzRightDown" shape="poly" onMouseDown="upcam_ptzcmdSubmit('downright')" onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="171,126,150,153,124,170,109,126,120,117,128,103"/>
	    <area id="ptzFocusIn" shape="poly" onMouseDown="upcam_ptzcmdSubmit('focusin')"  onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="2,2,52,2,2,52"/>
	    <area id="ptzFocusOut" shape="poly" onMouseDown="upcam_ptzcmdSubmit('focusout')"  onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="2,128,2,178,52,178"/>
	    <area id="ptzZoomIn" shape="poly" onMouseDown="upcam_ptzcmdSubmit('zoomin')"  onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="128,2,178,2,178,52"/>
	    <area id="ptzZoomOut" shape="poly" onMouseDown="upcam_ptzcmdSubmit('zoomout')"  onMouseOut="upcam_ptzcmdSubmit('stop')" onMouseUp="upcam_ptzcmdSubmit('stop')" coords="178,128,178,178,128,178"/>
	</map>

	<table style="position:absolute; left:1050; top:260;">
	    <tr>
		<td colspan="4" align="center" style="font-size:14pt;">Position</td>
	    </tr>

	    <tr>
		<td align="middle"><input id="pos_1" type="button" value="1" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(1)"></td>
		<td align="middle"><input id="pos_2" type="button" value="2" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(2)"></td>
		<td align="middle"><input id="pos_3" type="button" value="3" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(3)"></td>
		<td align="middle"><input id="pos_4" type="button" value="4" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(4)"></td>
	    </tr>
	    <tr>
		<td align="middle"><input id="pos_5" type="button" value="5" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(5)"></td>
		<td align="middle"><input id="pos_6" type="button" value="6" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(6)"></td>
		<td align="middle"><input id="pos_7" type="button" value="7" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(7)"></td>
		<td align="middle"><input id="pos_8" type="button" value="8" style="background-color:#DCDCDC" onMouseDown="upcam_auswahl_position(8)"></td>
	    </tr>

	    <tr>
		<td colspan="2"><input type="button" value="LADEN" onMouseDown="upcam_position_laden()"></td>
		<td colspan="2"><input type="button" value="SETZEN" onMouseDown="upcam_position_speichern()"></td>
	    </tr>
	    <tr>
		<td colspan="4" align="center"><input type="button" value="LÖSCHEN" style="background:red;" onMouseDown="upcam_position_loeschen()"></td>
	    </tr>
	    </table>

</body>
</html>