Ejemplo n.º 1
0
        public string GetHtml(string camId, IPCameraBase cam)
        {
            PTZProfile profile = GetProfile();

            if (profile == null)
            {
                return("PTZ Profile Not Found");
            }
            if (typeof(PTZSpecV1) == profile.spec.GetType())
            {
                PTZSpecV1 spec = (PTZSpecV1)profile.spec;

                HtmlOptions options = new HtmlOptions();
                options.showPtzArrows    = true;
                options.showPtzDiagonals = spec.EnableDiagonals;

                options.panDelay  = (int)(spec.PanRunTimeMs * 0.9);
                options.tiltDelay = (int)(spec.TiltRunTimeMs * 0.9);

                options.showZoomButtons = spec.EnableZoom;

                options.showZoomInLong   = !string.IsNullOrWhiteSpace(spec.zoomInLong);
                options.showZoomInMedium = !string.IsNullOrWhiteSpace(spec.zoomInMedium);
                options.showZoomInShort  = !string.IsNullOrWhiteSpace(spec.zoomInShort);

                options.showZoomOutLong   = !string.IsNullOrWhiteSpace(spec.zoomOutLong);
                options.showZoomOutMedium = !string.IsNullOrWhiteSpace(spec.zoomOutMedium);
                options.showZoomOutShort  = !string.IsNullOrWhiteSpace(spec.zoomOutShort);

                options.zoomShortDelay  = spec.ZoomRunTimeShortMs;
                options.zoomMediumDelay = spec.ZoomRunTimeMediumMs;
                options.zoomLongDelay   = spec.ZoomRunTimeLongMs;

                options.showPresets = spec.EnablePresets;
                int i = 0;
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_1);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_2);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_3);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_4);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_5);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_6);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_7);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_8);
                i = 0;
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_1);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_2);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_3);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_4);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_5);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_6);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_7);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_8);

                options.showZoomLevels = false;

                return(PTZHtml.GetHtml(camId, cam, options));
            }
            return("Unsupported PTZ Profile");
        }
Ejemplo n.º 2
0
        public string GetHtml(string camId, IPCameraBase cam)
        {
            HtmlOptions options = new HtmlOptions();

            options.showPtzArrows    = true;
            options.showPtzDiagonals = true;

            options.panDelay  = panDelay;
            options.tiltDelay = tiltDelay;

            options.showZoomButtons = true;

            options.showZoomInLong  = options.showZoomInMedium = options.showZoomInShort = true;
            options.showZoomOutLong = options.showZoomOutMedium = options.showZoomOutShort = true;

            options.zoomShortDelay  = zoomShortDelay;
            options.zoomMediumDelay = zoomMediumDelay;
            options.zoomLongDelay   = zoomLongDelay;

            options.showPresets = true;
            int i = 0;

            options.gettablePresets[i++] = true;
            options.gettablePresets[i++] = true;
            options.gettablePresets[i++] = true;
            options.gettablePresets[i++] = true;
            options.gettablePresets[i++] = true;
            options.gettablePresets[i++] = true;
            options.gettablePresets[i++] = true;
            options.gettablePresets[i++] = true;
            i = 0;
            options.settablePresets[i++] = true;
            options.settablePresets[i++] = true;
            options.settablePresets[i++] = true;
            options.settablePresets[i++] = true;
            options.settablePresets[i++] = true;
            options.settablePresets[i++] = true;
            options.settablePresets[i++] = true;
            options.settablePresets[i++] = true;

            options.showZoomLevels = false;

            return(PTZHtml.GetHtml(camId, cam, options));
        }
Ejemplo n.º 3
0
 public static string GetHtml(string camId, IPCameraBase cam)
 {
     if (cam.cameraSpec.ptzType == Configuration.PtzType.IPS_EYE01)
     {
         return(new IPS_EYE01.IPS_EYE01_PTZ(cam.cameraSpec).GetHtml(camId, cam));
     }
     else if (cam.cameraSpec.ptzType == Configuration.PtzType.TrendnetTVIP400)
     {
         return(new TrendNet.TV_IP400(cam.cameraSpec).GetHtml(camId, cam));
     }
     else if (cam.cameraSpec.ptzType == Configuration.PtzType.CustomPTZProfile)
     {
         return(new Custom.CustomPTZProfile(cam.cameraSpec, cam).GetHtml(camId, cam));
     }
     else if (cam.cameraSpec.ptzType == Configuration.PtzType.Huisun)
     {
         return(new HuisunBullet(cam.cameraSpec, cam).GetHtml(camId, cam));
     }
     return("");
 }
Ejemplo n.º 4
0
        public void GeneratePseudoPanorama(bool overlap, bool fullSizeImages = false)
        {
            IPCameraBase cam           = MJpegServer.cm.GetCamera(cs.id);
            bool         isFirstTime   = true;
            double       hfov          = cs.ptz_fov_horizontal == 0 ? 60 : cs.ptz_fov_horizontal;
            double       vfov          = cs.ptz_fov_vertical == 0 ? 34 : cs.ptz_fov_vertical;
            int          numImagesWide = overlap ? (int)Math.Round((360 / hfov) * 2) : 6;
            int          numImagesHigh = overlap ? (int)Math.Round(((cs.ptz_tiltlimit_low - cs.ptz_tiltlimit_high) / (vfov * 10)) * 2) : 3;

            for (int j = 0; j < numImagesHigh; j++)
            {
                for (int i = 0; i < numImagesWide; i++)
                {
                    FloatVector3 percentPos = new FloatVector3((float)i / (float)numImagesWide, (float)j / (float)numImagesHigh, 0);
                    PositionABS_PercentPosition(percentPos);
                    Thread.Sleep(isFirstTime ? 7000 : 4500);
                    isFirstTime = false;
                    try
                    {
                        byte[] input = cam.LastFrame;
                        if (input.Length > 0)
                        {
                            if (!fullSizeImages)
                            {
                                input = ImageConverter.ConvertImage(input, maxWidth: 240, maxHeight: 160);
                            }
                            FileInfo file = new FileInfo(CameraProxyGlobals.ThumbsDirectoryBase + cam.cameraSpec.id.ToLower() + (i + (j * numImagesWide)) + ".jpg");
                            Util.EnsureDirectoryExists(file.Directory.FullName);
                            File.WriteAllBytes(file.FullName, input);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Debug(ex);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public HuisunBullet(CameraSpec camSpec, IPCameraBase cam)
 {
     this.camSpec = camSpec;
     this.cam     = cam;
     url          = "http://" + camSpec.ptz_hostName + "/ipnc/";
 }
Ejemplo n.º 6
0
        internal static string GetHtml(string camId, IPCameraBase cam, HtmlOptions options)
        {
            int           arrowSize = 40;
            StringBuilder sb        = new StringBuilder();

            sb.Append("<td id=\"pthCell\" class=\"nounderline\"><div id=\"pthDiv\"><script type=\"text/javascript\">");
            sb.Append(Javascript.Longclick());
            sb.Append("</script>");
            sb.Append(@"<style type=""text/css"">
.presettbl
{
	border-collapse: collapse;
}
.presettbl td
{
	width: 66px;
	height: 50px;
	padding: 1px;
}
.presettbl img
{
	width: 64px;
	height: 48px;
	border: 1px Solid #666666;
	margin-bottom: -7px;
}
</style>
<script type=""text/javascript"">
$(function()
{
	for(var i = 1; i <= 8; i++)
	{
		$('#preset' + i).longAndShortClick(
		function(ele)
		{
			if(ele.getAttribute('settable') == '1')
			{
				var mynum = parseInt(ele.getAttribute('mynum'));
				if(confirm('Are you sure you want to assign preset ' + mynum + '?'))
					$.get('../control/PTZ?id="                     + camId + @"&cmd=ps' + mynum).done(function()
					{
						$('#preset' + mynum).attr('src', 'PTZPRESETIMG?id="                         + camId + @"&index=' + mynum + '&nocache=' + new Date().getTime());
					});
			}
			else
				alert('This preset is not settable.');
		},
		function(ele)
		{
			var mynum = parseInt(ele.getAttribute('mynum'));
			$.get('../control/PTZ?id="             + camId + @"&cmd=pl' + mynum);
		});
	}
});
</script>");

            sb.Append("<table style=\"width: 100%;\"><tbody><tr><td>");

            List <string> cells = new List <string>();

            if (options.showPtzArrows)
            {
                StringBuilder sbCell = new StringBuilder();
                sbCell.Append("<table id=\"pthTable\"><tbody><tr><td>");
                if (options.showPtzDiagonals)
                {
                    sbCell.Append(GetLinkToPTControl(camId, img("arrow-up-left.png", arrowSize, arrowSize, true), "ul"));
                }
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, img("arrow-up.png", arrowSize, arrowSize, true), "u", keyboardKey: 38, keyboardDelay: options.tiltDelay));
                sbCell.Append("</td><td>");
                if (options.showPtzDiagonals)
                {
                    sbCell.Append(GetLinkToPTControl(camId, img("arrow-up-right.png", arrowSize, arrowSize, true), "ur"));
                }
                sbCell.Append("</td></tr><tr><td>");
                sbCell.Append(GetLinkToPTControl(camId, img("arrow-left.png", arrowSize, arrowSize, true), "l", keyboardKey: 37, keyboardDelay: options.tiltDelay));
                sbCell.Append("</td><td>");
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, img("arrow-right.png", arrowSize, arrowSize, true), "r", keyboardKey: 39, keyboardDelay: options.panDelay));
                sbCell.Append("</td></tr><tr><td>");
                if (options.showPtzDiagonals)
                {
                    sbCell.Append(GetLinkToPTControl(camId, img("arrow-down-left.png", arrowSize, arrowSize, true), "dl"));
                }
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, img("arrow-down.png", arrowSize, arrowSize, true), "d", keyboardKey: 40, keyboardDelay: options.panDelay));
                sbCell.Append("</td><td>");
                if (options.showPtzDiagonals)
                {
                    sbCell.Append(GetLinkToPTControl(camId, img("arrow-down-right.png", arrowSize, arrowSize, true), "dr"));
                }
                sbCell.Append("</td></tr></tbody></table>");
                cells.Add(sbCell.ToString());
            }
            if (options.showZoomButtons)
            {
                StringBuilder sbCell = new StringBuilder();
                sbCell.Append("<table id=\"zTable\"><tbody>");
                if (options.showZoomInLong || options.showZoomOutLong)
                {
                    sbCell.Append("<tr><td>");
                    if (options.showZoomInLong)
                    {
                        sbCell.Append(GetLinkToPTControl(camId, img("plus.png", arrowSize, arrowSize, true), "i3", keyboardKey: 73, keyboardDelay: options.zoomLongDelay));
                    }
                    sbCell.Append("</td><td style=\"text-align: right;\">");
                    if (options.showZoomOutLong)
                    {
                        sbCell.Append(GetLinkToPTControl(camId, img("minus.png", arrowSize, arrowSize, true), "o3", keyboardKey: 79, keyboardDelay: options.zoomLongDelay));
                    }
                    sbCell.Append("</td></tr>");
                }
                if (options.showZoomInMedium || options.showZoomOutMedium)
                {
                    sbCell.Append("<tr><td>");
                    if (options.showZoomInMedium)
                    {
                        sbCell.Append(GetLinkToPTControl(camId, img("plus.png", (int)(arrowSize * 0.66), (int)(arrowSize * 0.66), true), "i2", keyboardDelay: options.zoomMediumDelay));
                    }
                    sbCell.Append("</td><td style=\"text-align: right;\">");
                    if (options.showZoomOutMedium)
                    {
                        sbCell.Append(GetLinkToPTControl(camId, img("minus.png", (int)(arrowSize * 0.66), (int)(arrowSize * 0.66), true), "o2", keyboardDelay: options.zoomMediumDelay));
                    }
                    sbCell.Append("</td></tr>");
                }
                if (options.showZoomInShort || options.showZoomOutShort)
                {
                    sbCell.Append("<tr><td>");
                    if (options.showZoomInShort)
                    {
                        sbCell.Append(GetLinkToPTControl(camId, img("plus.png", (int)(arrowSize * 0.5), (int)(arrowSize * 0.5), true), "i1", keyboardDelay: options.zoomShortDelay));
                    }
                    sbCell.Append("</td><td style=\"text-align: right;\">");
                    if (options.showZoomOutShort)
                    {
                        sbCell.Append(GetLinkToPTControl(camId, img("minus.png", (int)(arrowSize * 0.5), (int)(arrowSize * 0.5), true), "o1", keyboardDelay: options.zoomShortDelay));
                    }
                    sbCell.Append("</td></tr>");
                }
                sbCell.Append("</tbody></table>");
                cells.Add(sbCell.ToString());
            }
            if (options.showZoomLevels)
            {
                StringBuilder sbCell = new StringBuilder();
                sbCell.Append("<style type=\"text/css\">#zTable { font-size: 2em; } #zTable td { padding: 6px; }</style>");
                sbCell.Append("<table id=\"zTable\"><tbody><tr><td></td><td>");
                sbCell.Append(GetLinkToPTControl(camId, "0", "z0", keyboardKey: 49, keyboardDelay: 500));
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, "1", "z1", keyboardKey: 49, keyboardDelay: 500));
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, "2", "z2", keyboardKey: 50, keyboardDelay: 500));
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, "3", "z3", keyboardKey: 51, keyboardDelay: 500));
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, "4", "z4", keyboardKey: 52, keyboardDelay: 500));
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, "5", "z5", keyboardKey: 53, keyboardDelay: 500));
                sbCell.Append("</td><td>");
                sbCell.Append(GetLinkToPTControl(camId, "6", "z6", keyboardKey: 54, keyboardDelay: 500));
                sbCell.Append("</td><td></td></tr></tbody></table>");
                cells.Add(sbCell.ToString());
            }

            if (options.showPresets)
            {
                StringBuilder sbCell = new StringBuilder();
                sbCell.Append("<table class=\"presettbl\"><tbody><tr>");
                sbCell.Append("<td>").Append(GetPresetControl(camId, 1, options)).Append("</td>");                 // 49
                sbCell.Append("<td>").Append(GetPresetControl(camId, 2, options)).Append("</td>");
                sbCell.Append("<td>").Append(GetPresetControl(camId, 3, options)).Append("</td>");
                sbCell.Append("<td>").Append(GetPresetControl(camId, 4, options)).Append("</td>");
                sbCell.Append("</tr><tr>");
                sbCell.Append("<td>").Append(GetPresetControl(camId, 5, options)).Append("</td>");
                sbCell.Append("<td>").Append(GetPresetControl(camId, 6, options)).Append("</td>");
                sbCell.Append("<td>").Append(GetPresetControl(camId, 7, options)).Append("</td>");
                sbCell.Append("<td>").Append(GetPresetControl(camId, 8, options)).Append("</td>");
                sbCell.Append("</tr></tbody></table>");
                cells.Add(sbCell.ToString());
            }

            sb.Append(string.Join("</td><td>", cells));
            sb.Append("</td></tr></tbody></table>");

            sb.Append("</div></td></tr><tr>");
            return(sb.ToString());
        }
Ejemplo n.º 7
0
 public CustomPTZProfile(CameraSpec camSpec, IPCameraBase cam)
 {
     this.camSpec = camSpec;
     this.cam     = cam;
     urlBase      = "http://" + camSpec.ptz_hostName + "/";
 }
Ejemplo n.º 8
0
 public string GetHtml(string camId, IPCameraBase cam)
 {
     return(PTZHtml.GetHtml(camId, cam, new HtmlOptions()));
 }