<!--
! This program is to generate preset for the Papywizard
! program. This program can be used for commercial and/or
! non-commercial use for free.
!
! Author: Jones Henry Subbiah (C) 2010.
!
! Disclaimer: The user assumes the responsibility of any
! any demage using the preset. The author is not responsible
! for anything.
!
! The name of the preset will be
! TL_35<crop factor>_<focal length>_<# of points>_<fps>_<# of shots>.
!
! History of changes:
! ====================
! 0.1 Initial public version
!
-->
<html>
<head>
<title>Papywizard Time Lapse (Bezier Curve) Preset Generator</title>
<script language="Javascript">
var FOV_IN_SECS = 7;
var DEBUG = false;
var pval = '';
var crop_factor = '';
var focal_length = 0;
var fps = 30;
/*
* This function appends the message to the text box.
*/
function write ( message )
{
pval += message + "\n";
}
/*
* This function appends debug messages to the text box.
*/
function debug ( message )
{
if ( DEBUG )
write ( message );
}
/*
* Find the factorial value of a given number.
*/
function factorial(num)
{
var ctr = 0;
var result = 1;
if ( num != 0 )
for ( ctr = 1; ctr <= num; ctr++ )
result *= ctr;
return ( result );
}
/*
* Define a Point objecct
*/
function Point()
{
var x = 0.0;
var y = 0.0;
this.getYaw = function() { return x; }
this.setYaw = function(yaw) { x = yaw; }
this.getPitch = function() { return y; }
this.setPitch = function(pitch) { y = pitch; }
this.print = function() { debug ( "x: " + round24 ( x ) + ", y: " + round24 ( y ) ); }
}
/*
* Calculate the output points.
* Returns an array of Point objects.
*/
function bcurve ( points, steps )
{
var npoints = points.length;
var inc = 0.0;
var x = 0.0;
var y = 0.0;
var poly = 0.0;
var outpoints = new Array();
debug ( "bcurve - npoints: " + npoints );
debug ( "bcurve - steps: " + steps );
for ( var ctr2 = 0; ctr2 < steps; ctr2++ )
{
inc = 1.0 * ctr2 / steps;
x = 0.0;
y = 0.0;
for ( var ctr = 0; ctr < npoints; ctr++ )
{
poly = bpoly ( npoints - 1, ctr, inc );
x += poly * points [ ctr ].getYaw();
y += poly * points [ ctr ].getPitch();
}
p = new Point();
p.setYaw ( x );
p.setPitch ( y );
outpoints.push ( p );
}
debug ( "bcurve - outpoints.length: " + outpoints.length );
return ( outpoints );
}
/*
* Calculate the Bezier coefficient.
*/
function bcoeff ( order, pos )
{
return factorial ( order ) / ( factorial ( pos ) * factorial ( order - pos ) );
}
/*
* Calculate the Bezier polynomials.
*/
function bpoly ( order, pos, inc )
{
return bcoeff ( order, pos ) * Math.pow ( inc, pos ) * Math.pow ( ( 1.0 - inc ), ( order - pos ) );
}
/*
* Finds a minimal number of steps needed for the given lens.
* It assumes the FOV of the lens should be scanned in 7 seconds
* for a smooth movement.
*/
function findsteps ( points )
{
debug ( "findsteps - points.length: " + points.length );
var steps = 0;
var lst = new Array();
focal_length = parseFloat ( document.main.fl.value );
var sfa = ( document.main.sf.options[document.main.sf.selectedIndex].value ).split ( ',' );
crop_factor = Number ( sfa[0] );
var source_frame_width = Number ( sfa[1] );
var source_frame_height = Number ( sfa[2] );
var thfov = calculate_fov ( source_frame_width, focal_length );
var tvfov = calculate_fov ( source_frame_height, focal_length );
debug ( "findsteps - focal_length: " + focal_length );
debug ( "findsteps - crop_factor: " + crop_factor );
debug ( "findsteps - source_frame_width: " + source_frame_width );
debug ( "findsteps - source_frame_height: " + source_frame_height );
debug ( "findsteps - thfov: " + thfov );
debug ( "findsteps - tvfov: " + tvfov );
var fov = Math.min ( thfov, tvfov );
fps = parseInt ( document.main.ofps.options[document.main.ofps.selectedIndex].value );
var fov_per_step = fov / ( FOV_IN_SECS * fps );
debug ( "findsteps - fov: " + fov );
debug ( "findsteps - fps: " + fps );
debug ( "findsteps - fov_per_step: " + fov_per_step );
while ( 1 )
{
steps += 30;
lst = bcurve ( points, steps );
debug ( "findsteps - lst.length: " + lst.length );
debug ( "findsteps - steps: " + steps
+ ", lst[1].yaw: " + lst[1].getYaw() + ", lst[0].yaw: " + lst[0].getYaw()
+ ", diff: " + Math.abs ( lst[1].getYaw() - lst[0].getYaw() ) );
if ( Math.abs ( lst[1].getYaw() - lst[0].getYaw() ) < fov_per_step )
{
break;
}
}
debug ( "findsteps - steps: " + steps );
return ( steps );
}
/*
* This function calculates the angular field of view.
*/
function calculate_fov ( frame_length, focal_length )
{
return ( 2 * Math.atan ( frame_length / ( 2 * focal_length ) ) * 180 / Math.PI );
}
/*
* This function validates the input.
* Input validation is done only for text box fields.
*/
function validate_input()
{
if ( isNaN ( parseInt ( document.main.np.value ) ) )
{
alert ( "Enter a valid value for number of shots" );
document.main.np.select();
document.main.np.focus();
return false;
}
return true;
}
/*
* This function rounds a number to a four decimal precision.
* The trick to is to add 0.00005 to the number and truncate at the first
* decimal position.
*/
function round24 ( number )
{
nnum = number + 0.00005;
nums = nnum.toString();
numa = nums.split('.');
return ( numa[0] + '.' + numa[1].substring(0,4) );
}
/*
* Reads the input from the text fields.
*/
function read_point ( pname )
{
debug ( "read_point - pname: " + pname );
var yaw = document.getElementsByName(pname + "x")[0].value;
debug ( "read_point - yaw: " + yaw );
var pitch = document.getElementsByName(pname + "y")[0].value;
debug ( "read_point - pitch: " + pitch );
if ( yaw != '' && pitch != '' )
{
p = new Point();
p.setYaw ( yaw );
p.setPitch ( pitch );
return ( p );
}
return ( null );
}
/*
* This function is the main function that creates the full preset XML.
*/
function do_tl()
{
pval = '';
var pts = new Array();
for ( ctr = 0; ctr < 6; ctr++ )
{
p = read_point ( "p" + ( ctr + 1 ) );
if ( p != null )
{
pts.push ( p );
}
}
if ( pts.length < 2 )
{
alert ( "Plese enter the yaw, pitch values for at least two control points" );
return;
}
var steps = findsteps ( pts );
debug ( "steps: " + steps );
bpts = bcurve ( pts, steps );
for ( ctr = 0; ctr < bpts.length; ctr++ )
{
bpts[ctr].print();
}
write ( '<?xml version="1.0" encoding="utf-8"?>\n' );
write ( '<papywizard>\n' );
write ( ' <preset name="TL_35' + ( crop_factor * 10 ) + '_' + focal_length + '_' + pts.length + 'points_' + fps + 'fps_' + steps + 'shots">' );
write ( ' <tooltip>' );
write ( ' This time lapse preset is generated for the following ' + pts.length + ' control points.' );
for ( var ctr = 0; ctr < pts.length; ctr++ )
{
write ( ' Point' + ( ctr + 1 ) + '(' + pts[ctr].getYaw() + ',' + pts[ctr].getPitch() + ')' );
}
write ( ' ' + steps + ' shots will be taken using this preset' );
write ( ' </tooltip>' );
write ( ' <shoot>' );
for ( ctr = 0; ctr < bpts.length; ctr++ )
{
write ( ' <pict yaw="' + round24 ( bpts[ctr].getYaw() ) + '" pitch="' + round24 ( bpts[ctr].getPitch() ) + '"/>' );
}
write ( ' </shoot>' );
write ( ' </preset>\n' );
write ( '</papywizard>' );
document.main.preset.value = pval;
}
</script>
</head>
<body onload="document.main.preset.value = '';" bgcolor="#cccccc">
<form name="main">
<table border="0" cellspacing="2" cellpadding="2" width="700">
<tr>
<td>Crop Factor</td>
<td>
<select name="sf" style="width:100px">
<option value="1.0,36.0,24.0">35mm(1.0 Crop)</option>
<option value="1.3,27.7,18.5">35mm(1.3 Crop)</option>
<option value="1.5,24.0,16.0">35mm(1.5 Crop)</option>
<option value="1.6,22.5,15.0" selected>35mm(1.6 Crop)</option>
<option value="1.7,21.2,14.1">35mm(1.7 Crop)</option>
<option value="1.8,20.0,13.3">35mm(1.8 Crop)</option>
<option value="2.0,18.0,12.0">35mm(2.0 Crop)</option>
</select>
</td>
<td>Focal Length</td>
<td>
<input type="text" name="fl" style="width:100px" value="150">
</td>
<td>Output FPS</td>
<td>
<select name="ofps" style="width:100px">
<option value="24">24 fps</option>
<option value="25">25 fps</option>
<option value="30" selected>30 fps</option>
<option value="50">50 fps</option>
<option value="60">60 fps</option>
</select>
</td>
</tr>
<tr>
<td>
P1(yaw)
<input type="text" name="p1x" value="" style="width:60px">
</td>
<td>
P1(pitch)
<input type="text" name="p1y" value="" style="width:60px">
</td>
<td>
P2(yaw)
<input type="text" name="p2x" value="" style="width:60px">
</td>
<td>
P2(pitch)
<input type="text" name="p2y" value="" style="width:60px">
</td>
<td>
P3(yaw)
<input type="text" name="p3x" value="" style="width:60px">
</td>
<td>
P3(pitch)
<input type="text" name="p3y" value="" style="width:60px">
</td>
</tr>
<tr>
<td>
P4(yaw)
<input type="text" name="p4x" value="" style="width:60px">
</td>
<td>
P4(pitch)
<input type="text" name="p4y" value="" style="width:60px">
</td>
<td>
P5(yaw)
<input type="text" name="p5x" value="" style="width:60px">
</td>
<td>
P5(pitch)
<input type="text" name="p5y" value="" style="width:60px">
</td>
<td>
P6(yaw)
<input type="text" name="p6x" value="" style="width:60px">
</td>
<td>
P6(pitch)
<input type="text" name="p6y" value="" style="width:60px">
</td>
</tr>
<tr>
<td>Preset</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>
<input type="button" value="Generate" style="width:100px" onClick="do_tl();">
</td>
</tr>
<tr>
<td colspan="6">
<textarea name="preset" rows="18" cols="95"></textarea>
</td>
</tr>
</table>
</form>
</body>
</html>
claudevh wrote:I have a small problem on line 57, character 35
function factorial(num)
{
var ctr = 0;
var result = 1;
if ( num != 0 )
for ( ctr = 1; ctr <= num; ctr++ )
result *= ctr;
return ( result );
}
<!--
! This program is to generate preset for the Papywizard
! program. This program can be used for commercial and/or
! non-commercial use for free.
!
! Author: Jones Henry Subbiah (C) 2010.
!
! Disclaimer: The user assumes the responsibility of any
! any demage using the preset. The author is not responsible
! for anything.
!
! The name of the preset will be
! TL_35<crop factor>_<focal length>_<# of points>_<fps>_<# of shots>.
!
! History of changes:
! ====================
! 0.1 Initial public version
!
-->
<html>
<head>
<title>Papywizard 6 point Time Lapse (Bezier Curve) Preset Generator</title>
<script language="Javascript">
var FOV_IN_SECS = 7;
var DEBUG = false;
var pval = '';
var crop_factor = '';
var focal_length = 0;
var fps = 30;
/*
* This function appends the message to the text box.
*/
function write ( message )
{
pval += message + "\n";
}
/*
* This function appends debug messages to the text box.
*/
function debug ( message )
{
if ( DEBUG )
write ( message );
}
/*
* Find the factorial value of a given number.
*/
function factorial(num)
{
var ctr = 0;
var result = 1;
if ( num != 0 )
for ( ctr = 1; ctr <= num; ctr++ )
result *= ctr;
return ( result );
}
/*
* Define a Point objecct
*/
function Point()
{
var x = 0.0;
var y = 0.0;
this.getYaw = function() { return x; }
this.setYaw = function(yaw) { x = yaw; }
this.getPitch = function() { return y; }
this.setPitch = function(pitch) { y = pitch; }
this.print = function() { debug ( "x: " + round24 ( x ) + ", y: " + round24 ( y ) ); }
}
/*
* Calculate the output points.
* Returns an array of Point objects.
*/
function bcurve ( points, steps )
{
var npoints = points.length;
var inc = 0.0;
var x = 0.0;
var y = 0.0;
var poly = 0.0;
var outpoints = new Array();
debug ( "bcurve - npoints: " + npoints );
debug ( "bcurve - steps: " + steps );
for ( var ctr2 = 0; ctr2 < steps; ctr2++ )
{
inc = 1.0 * ctr2 / steps;
x = 0.0;
y = 0.0;
for ( var ctr = 0; ctr < npoints; ctr++ )
{
poly = bpoly ( npoints - 1, ctr, inc );
x += poly * points [ ctr ].getYaw();
y += poly * points [ ctr ].getPitch();
}
p = new Point();
p.setYaw ( x );
p.setPitch ( y );
outpoints.push ( p );
}
debug ( "bcurve - outpoints.length: " + outpoints.length );
return ( outpoints );
}
/*
* Calculate the Bezier coefficient.
*/
function bcoeff ( order, pos )
{
return factorial ( order ) / ( factorial ( pos ) * factorial ( order - pos ) );
}
/*
* Calculate the Bezier polynomials.
*/
function bpoly ( order, pos, inc )
{
return bcoeff ( order, pos ) * Math.pow ( inc, pos ) * Math.pow ( ( 1.0 - inc ), ( order - pos ) );
}
/*
* Finds a minimal number of steps needed for the given lens.
* It assumes the FOV of the lens should be scanned in 7 seconds
* for a smooth movement.
*/
function findsteps ( points )
{
debug ( "findsteps - points.length: " + points.length );
var steps = 0;
var lst = new Array();
focal_length = parseFloat ( document.main.fl.value );
var sfa = ( document.main.sf.options[document.main.sf.selectedIndex].value ).split ( ',' );
crop_factor = Number ( sfa[0] );
var source_frame_width = Number ( sfa[1] );
var source_frame_height = Number ( sfa[2] );
var thfov = calculate_fov ( source_frame_width, focal_length );
var tvfov = calculate_fov ( source_frame_height, focal_length );
debug ( "findsteps - focal_length: " + focal_length );
debug ( "findsteps - crop_factor: " + crop_factor );
debug ( "findsteps - source_frame_width: " + source_frame_width );
debug ( "findsteps - source_frame_height: " + source_frame_height );
debug ( "findsteps - thfov: " + thfov );
debug ( "findsteps - tvfov: " + tvfov );
var fov = Math.min ( thfov, tvfov );
fps = parseInt ( document.main.ofps.options[document.main.ofps.selectedIndex].value );
var fov_per_step = fov / ( FOV_IN_SECS * fps );
debug ( "findsteps - fov: " + fov );
debug ( "findsteps - fps: " + fps );
debug ( "findsteps - fov_per_step: " + fov_per_step );
while ( 1 )
{
steps += 30;
lst = bcurve ( points, steps );
debug ( "findsteps - lst.length: " + lst.length );
debug ( "findsteps - steps: " + steps
+ ", lst[1].yaw: " + lst[1].getYaw() + ", lst[0].yaw: " + lst[0].getYaw()
+ ", diff: " + Math.abs ( lst[1].getYaw() - lst[0].getYaw() ) );
if ( Math.abs ( lst[1].getYaw() - lst[0].getYaw() ) < fov_per_step )
{
break;
}
}
debug ( "findsteps - steps: " + steps );
return ( steps );
}
/*
* This function calculates the angular field of view.
*/
function calculate_fov ( frame_length, focal_length )
{
return ( 2 * Math.atan ( frame_length / ( 2 * focal_length ) ) * 180 / Math.PI );
}
/*
* This function validates the input.
* Input validation is done only for text box fields.
*/
function validate_input()
{
if ( isNaN ( parseInt ( document.main.np.value ) ) )
{
alert ( "Enter a valid value for number of shots" );
document.main.np.select();
document.main.np.focus();
return false;
}
return true;
}
/*
* This function rounds a number to a four decimal precision.
* The trick to is to add 0.00005 to the number and truncate at the first
* decimal position.
*/
function round24 ( number )
{
nnum = number + 0.00005;
nums = nnum.toString();
numa = nums.split('.');
return ( numa[0] + '.' + numa[1].substring(0,4) );
}
/*
* Reads the input from the text fields.
*/
function read_point ( pname )
{
debug ( "read_point - pname: " + pname );
var yaw = document.getElementsByName(pname + "x")[0].value;
debug ( "read_point - yaw: " + yaw );
var pitch = document.getElementsByName(pname + "y")[0].value;
debug ( "read_point - pitch: " + pitch );
if ( yaw != '' && pitch != '' )
{
p = new Point();
y.setYaw ( yaw );
p.setPitch ( pitch );
return ( p );
}
return ( null );
}
/*
* This function is the main function that creates the full preset XML.
*/
function do_tl()
{
pval = '';
var pts = new Array();
for ( ctr = 0; ctr < 6; ctr++ )
{
p = read_point ( "p" + ( ctr + 1 ) );
if ( p != null )
{
pts.push ( p );
}
}
if ( pts.length < 2 )
{
alert ( "Plese enter the yaw, pitch values for at least two control points" );
return;
}
var steps = findsteps ( pts );
debug ( "steps: " + steps );
bpts = bcurve ( pts, steps );
for ( ctr = 0; ctr < bpts.length; ctr++ )
{
bpts[ctr].print();
}
write ( '<?xml version="1.0" encoding="utf-8"?>\n' );
write ( '<papywizard>\n' );
write ( ' <preset name="TL_35' + ( crop_factor * 10 ) + '_' + focal_length + '_' + pts.length + 'points_' + fps + 'fps_' + steps + 'shots">' );
write ( ' <tooltip>' );
write ( ' This time lapse preset is generated for the following ' + pts.length + ' control points.' );
for ( var ctr = 0; ctr < pts.length; ctr++ )
{
write ( ' Point' + ( ctr + 1 ) + '(' + pts[ctr].getYaw() + ',' + pts[ctr].getPitch() + ')' );
}
write ( ' ' + steps + ' shots will be taken using this preset' );
write ( ' </tooltip>' );
write ( ' <shoot>' );
for ( ctr = 0; ctr < bpts.length; ctr++ )
{
write ( ' <pict yaw="' + round24 ( bpts[ctr].getYaw() ) + '" pitch="' + round24 ( bpts[ctr].getPitch() ) + '"/>' );
}
write ( ' </shoot>' );
write ( ' </preset>\n' );
write ( '</papywizard>' );
document.main.preset.value = pval;
}
</script>
</head>
<body onload="document.main.preset.value = '';" bgcolor="#cccccc">
<form name="main">
<table border="0" cellspacing="2" cellpadding="2" width="700">
<tr>
<td>Crop Factor</td>
<td>
<select name="sf" style="width:100px">
<option value="1.0,36.0,24.0">35mm(1.0 Crop)</option>
<option value="1.3,27.7,18.5">35mm(1.3 Crop)</option>
<option value="1.5,24.0,16.0">35mm(1.5 Crop)</option>
<option value="1.6,22.5,15.0" selected>35mm(1.6 Crop)</option>
<option value="1.7,21.2,14.1">35mm(1.7 Crop)</option>
<option value="1.8,20.0,13.3">35mm(1.8 Crop)</option>
<option value="2.0,18.0,12.0">35mm(2.0 Crop)</option>
</select>
</td>
<td>Focal Length</td>
<td>
<input type="text" name="fl" style="width:100px" value="150">
</td>
<td>Output FPS</td>
<td>
<select name="ofps" style="width:100px">
<option value="24">24 fps</option>
<option value="25">25 fps</option>
<option value="30" selected>30 fps</option>
<option value="50">50 fps</option>
<option value="60">60 fps</option>
<option value="120">120 fps</option>
</select>
</td>
</tr>
<tr>
<td>
Y1(yaw)
<input type="text" name="y1x" value="" style="width:60px">
</td>
<td>
P1(pitch)
<input type="text" name="p1y" value="" style="width:60px">
</td>
<td>
Y2(yaw)
<input type="text" name="y2x" value="" style="width:60px">
</td>
<td>
P2(pitch)
<input type="text" name="p2y" value="" style="width:60px">
</td>
<td>
Y3(yaw)
<input type="text" name="y3x" value="" style="width:60px">
</td>
<td>
P3(pitch)
<input type="text" name="p3y" value="" style="width:60px">
</td>
</tr>
<tr>
<td>
Y4(yaw)
<input type="text" name="y4x" value="" style="width:60px">
</td>
<td>
P4(pitch)
<input type="text" name="p4y" value="" style="width:60px">
</td>
<td>
Y5(yaw)
<input type="text" name="yp5x" value="" style="width:60px">
</td>
<td>
P5(pitch)
<input type="text" name="p5y" value="" style="width:60px">
</td>
<td>
Y6(yaw)
<input type="text" name="y6x" value="" style="width:60px">
</td>
<td>
P6(pitch)
<input type="text" name="p6y" value="" style="width:60px">
</td>
</tr>
<tr>
<td>Preset</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>
<input type="button" value="Generate" style="width:100px" onClick="do_tl();">
</td>
</tr>
<tr>
<td colspan="6">
<textarea name="preset" rows="18" cols="95"></textarea>
</td>
</tr>
</table>
</form>
</body>
</html>
sjhenry wrote:1. What is it?
This html/javascript program creates a PW preset to do a time lapse using Bezier Curve.
<pict yaw="0.0000" pitch="0.0000"/>
<pict yaw="0.0074" pitch="0.4469"/>
<pict yaw="0.0295" pitch="0.8985"/>
<pict yaw="0.0662" pitch="1.3547"/>
<pict yaw="0.1173" pitch="1.8153"/>
...
<pict yaw="0.0000" pitch="0.0000"/>
<pict yaw="0.0000" pitch="0.4469"/>
<pict yaw="0.0000" pitch="0.8985"/>
<pict yaw="0.0000" pitch="1.3547"/>
<pict yaw="0.0000" pitch="1.8153"/>
...
<pict yaw="0.0000" pitch="30.0000"/>
mjaszo wrote:Hi sjhenry! Thanks for a cool script! I've tried it and wors perfectly. What I though it would do though - that the path would include given points. If I want to show say 3 points Y,P / 0,0 / 90,45 / 180, 0 I have to use 0,0 / 90,90 / 180,0. Otherwise my path goes through 0,0 / 90,22.5/ 180,0. Would that be difficult to change? Makes more sens to be able to have chosen views in the timelapse. Could you add the duration of timelapse option? Say I know it should be 10sec=250frames. Then I just write position of my points and 250. Thanks again for sharing your work with us!
Mateusz Malinowski wrote:sjhenry wrote:1. What is it?
This html/javascript program creates a PW preset to do a time lapse using Bezier Curve.
Hi
Preset Generator doesn't work fine witch all settings.
Example
crop 1.6
focal lenght 550
fps 25
Point1(0,0)
Point2(0,30)
Point3(90,90)
Point4(180,30)
Point5(0,0)
On the start is
- Code: Select all
<pict yaw="0.0000" pitch="0.0000"/>
<pict yaw="0.0074" pitch="0.4469"/>
<pict yaw="0.0295" pitch="0.8985"/>
<pict yaw="0.0662" pitch="1.3547"/>
<pict yaw="0.1173" pitch="1.8153"/>
...
should be something like
- Code: Select all
<pict yaw="0.0000" pitch="0.0000"/>
<pict yaw="0.0000" pitch="0.4469"/>
<pict yaw="0.0000" pitch="0.8985"/>
<pict yaw="0.0000" pitch="1.3547"/>
<pict yaw="0.0000" pitch="1.8153"/>
...
<pict yaw="0.0000" pitch="30.0000"/>
and then increasing the value of yaw. Similarly, at the end.
Point3(90,90) - pitch is max 48.xxxx, not 90 as I declare.
Users browsing this forum: No registered users and 0 guests