Open monitors from montage view
-
- Posts: 74
- Joined: Wed Feb 25, 2004 5:06 pm
Open monitors from montage view
I've made a quick patch to zm_html_view_montagefeed.php to enable a user to open up the full camera watch window by clicking on one of the montage images.
I have my montage set to 1/2 regular image size so when something happens that looks interesting in the montage view I can click on the image and have the full view pop up as if I'd launched it from the console.
NB: This only works in browsers that use the native jpeg streaming method, such as Firefox.
Diff -> http://www.hunter13.com/zm_montagefeed.diff.txt
Complete file -> http://www.hunter13.com/zm_html_view_mo ... ed.php.txt
I have my montage set to 1/2 regular image size so when something happens that looks interesting in the montage view I can click on the image and have the full view pop up as if I'd launched it from the console.
NB: This only works in browsers that use the native jpeg streaming method, such as Firefox.
Diff -> http://www.hunter13.com/zm_montagefeed.diff.txt
Complete file -> http://www.hunter13.com/zm_html_view_mo ... ed.php.txt
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
I tried this great contribution from unclerichy and found that when I put the php file into my Ubuntu 7.10 package install of 1.22, it messed up my montage scaling from the options panel (basically, my montage views no longer scaled properly; even though the image sizes on screen were the correct dimensions, the images themselves weren't scaled). Assuming this was because the montage scaling system may have changed since this patch was written in 2005, I modified it a bit and it seems to work for me now.
I left unclerichy's javascript:newWindow function alone at the top, and just added a little "echo" statement in the lower part that creates the link. This is a bit of a hack job (it doesn't even properly close the "<a>" tag), but so far it's working for me.
Allows clicking the montage image for a detail view of the monitor. You have to close your own windows; it's not smart enough to re-use the same pop-up window if you click another montage image.
If I haven't provided proper credit or if I've done something (other than poor coding) incorrectly, please let me know and give me a chance to correct it. I have never made a code contribution to anything before and I wanted to give something back (besides $) to the ZM community.
My edits to the stock 1.22 file - zm_html_view_montagefeed.php - below are surrounded by "//Haus Quick Edit" and "//Haus END Quick Edit"; the rest of the file is unchanged.
I left unclerichy's javascript:newWindow function alone at the top, and just added a little "echo" statement in the lower part that creates the link. This is a bit of a hack job (it doesn't even properly close the "<a>" tag), but so far it's working for me.
Allows clicking the montage image for a detail view of the monitor. You have to close your own windows; it's not smart enough to re-use the same pop-up window if you click another montage image.
If I haven't provided proper credit or if I've done something (other than poor coding) incorrectly, please let me know and give me a chance to correct it. I have never made a code contribution to anything before and I wanted to give something back (besides $) to the ZM community.
My edits to the stock 1.22 file - zm_html_view_montagefeed.php - below are surrounded by "//Haus Quick Edit" and "//Haus END Quick Edit"; the rest of the file is unchanged.
Code: Select all
<?php
//
// ZoneMinder web montage feed view file, $Date: 2006/03/27 22:01:33 $, $Revision: 1.40 $
// Copyright (C) 2003, 2004, 2005, 2006 Philip Coombes
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if ( !canView( 'Stream' ) )
{
$view = "error";
return;
}
if ( empty($mode) )
{
if ( ZM_WEB_USE_STREAMS && canStream() )
$mode = "stream";
else
$mode = "still";
}
if ( ZM_OPT_CONTROL )
{
$sql = "select M.*,C.CanMoveMap,C.CanMoveRel from Monitors as M left join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'";
}
else
{
$sql = "select * from Monitors where Id = '$mid'";
}
$result = mysql_query( $sql );
if ( !$result )
die( mysql_error() );
$monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$montage_width = ZM_WEB_MONTAGE_WIDTH?ZM_WEB_MONTAGE_WIDTH:reScale( $monitor['Width'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$montage_height = ZM_WEB_MONTAGE_HEIGHT?ZM_WEB_MONTAGE_HEIGHT:reScale( $monitor['Height'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$width_scale = ($montage_width*SCALE_BASE)/$monitor['Width'];
$height_scale = ($montage_height*SCALE_BASE)/$monitor['Height'];
$scale = (int)(($width_scale<$height_scale)?$width_scale:$height_scale);
if ( $mode != "stream" )
{
// Prompt an image to be generated
if ( ZM_WEB_REFRESH_METHOD == "http" )
header("Refresh: ".ZM_WEB_REFRESH_IMAGE."; URL=$PHP_SELF?view=montagefeed&mid=$mid&mode=still&scale=$scale" );
}
noCacheHeaders();
$image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) );
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $monitor['Name'] ?> - <?= $zmSlangFeed ?></title>
<link rel="stylesheet" href="zm_html_styles.css" type="text/css">
<script type="text/javascript">
//Haus Quick Edit: This was contributed by unclerichy of the Zoneminder Forums
function newWindow(Url,Name,Width,Height)
{
var Name = window.open(Url,Name,"resizable,width="+Width+",height="+Height);
}
//Haus END Quick Edit: The above was contributed by unclerichy of the Zoneminder Forums
<?php
if ( $mode != "stream" && ZM_WEB_REFRESH_METHOD == "javascript" )
{
if ( ZM_WEB_DOUBLE_BUFFER )
{
?>
function fetchImage()
{
var now = new Date();
var zm_image = new Image();
zm_image.src = '<?= $image_src ?>'+'&'+now.getTime();
document['zmImage'].src = zm_image.src;
}
window.setInterval( "fetchImage()", <?= ZM_WEB_REFRESH_IMAGE*1000 ?> );
<?php
}
else
{
?>
window.setTimeout( "window.location.reload(true)", <?= ZM_WEB_REFRESH_IMAGE*1000 ?> );
<?php
}
}
?>
</script>
</head>
<body>
<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
<tr><td align="center">
<?php
if ( $mode == "stream" )
{
//Haus Quick Edit
echo('<a href="javascript:newWindow(\''.$PHP_SELF.'?view=watch&mid='.$monitor['Id'].'\',\'\')">');
//Haus End Quick Edit
if ( ZM_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT )
{
$stream_src = getStreamSrc( array( "mode=mpeg", "monitor=".$monitor['Id'], "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
outputVideoStream( $stream_src, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'], ZM_MPEG_LIVE_FORMAT );
}
else
{
$stream_src = getStreamSrc( array( "mode=jpeg", "monitor=".$mid, "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) );
if ( canStreamNative() )
{
if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel'] || $monitor['CanMoveCon']) )
{
outputControlStream( $stream_src, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor, $scale, "MontageSink".$mid );
}
else
{
outputImageStream( $stream_src, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
}
}
else
{
outputHelperStream( $stream_src, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ) );
}
}
}
else
{
if ( $control && ($monitor['CanMoveMap'] || $monitor['CanMoveRel'] || $monitor['CanMoveCon']) )
{
outputControlStill( $image_src, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor, $scale, "MontageSink".$mid );
}
else
{
outputImageStill( $image_src, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
}
}
?>
</td></tr>
</table>
</body>
</html>
Lee, I'm using 1.22.3-8.deb or 1.22.3-9.deb (Peter Howard's fine work) on Ubuntu 7.04 server; I'm not sure which, though I'm pretty sure there's no change in the montage view between those two releases as I don't recall anything in the changelogs about it.
Cordel, I have "jpeg" selected under Options -> Images -> ZM_STREAM_METHOD. But until I edited the file above, I wasn't able to click the montage images. Am I missing a setting? If so, I feel sort of silly for changing the php file if the functionality is already there, but I'm not seeing it.
Cordel, I have "jpeg" selected under Options -> Images -> ZM_STREAM_METHOD. But until I edited the file above, I wasn't able to click the montage images. Am I missing a setting? If so, I feel sort of silly for changing the php file if the functionality is already there, but I'm not seeing it.
I've never used 1.23, so I can't say what might be different in the zm_html_view_montagefeed.php file. If I upgrade to 1.23 I'll re-work the patch, but with a functioning 1.22 system I'm not sure there's enough new stuff in 1.23 to make me go through all the hassle of install/setup again...(sorry) - I'm a "don't mess with success" kind of guy.
If someone wants to run a diff between my zm_html_view_montagefeed.php file (as posted above) and that of a stock 1.23, it should become clear if there are massive changes between the two versions that would indicate how hard it would be to make this work under 1.23.
If someone wants to run a diff between my zm_html_view_montagefeed.php file (as posted above) and that of a stock 1.23, it should become clear if there are massive changes between the two versions that would indicate how hard it would be to make this work under 1.23.
I had released a mod for montage view to view monitors by clicking on the image. It can be found here: http://www.zoneminder.com/forums/viewto ... highlight=
It doesn't have any scaling issues that I'm aware of.
It doesn't have any scaling issues that I'm aware of.
Ammaross,
Sorry - didn't mean to steal focus or not give credit to your earlier solution - I didn't know about your post/contribution. When I did a forum search, I only came up with unclerichy's thread, or I saw it and pounced on it without spending enough time reviewing all the info.
Nonetheless, echoing Lee's earlier comment, it would be great to see some of this stuff baked into ZM, rather than requiring patches. This has got to be one of the more useful changes for anyone who doesn't do full-size montage views.
Sorry - didn't mean to steal focus or not give credit to your earlier solution - I didn't know about your post/contribution. When I did a forum search, I only came up with unclerichy's thread, or I saw it and pounced on it without spending enough time reviewing all the info.
Nonetheless, echoing Lee's earlier comment, it would be great to see some of this stuff baked into ZM, rather than requiring patches. This has got to be one of the more useful changes for anyone who doesn't do full-size montage views.