[Papywizard] Time Lapse (Bezier Curve) Preset Generator  

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

[Papywizard] Time Lapse (Bezier Curve) Preset Generator

by sjhenry » Sat Apr 10, 2010 6:42 am

1. What is it?
This html/javascript program creates a PW preset to do a time lapse using Bezier Curve.

2. How to install?
a) Open notepad or any text editor
b) Copy the following code (remove the "Code:" part)
c) Paste that in the text editor
d) Save it with a name (like pw_tl_bc_preset.html)
e) Double click on the name. It will be opened in the default browser.

3. What is the system requirement?
A modern browser - latest version of any browser. I wrote it in html/javascript combination so that it works in most of the browsers. The javascript needs to be enabled on the browser.

4. What are the fields on the screen?
a) "Crop Factor" - the 35mm camera crop factor for your camera.
b) "Focal Length" - focal length of the lens used.
c) "Output FPS" - output frames per second.
d) "P1(yaw)" - the yaw value of the first Bezier control point.
e) "P1(pitch)" - the pitch value of the first Bezier control point.
Rest of the fields are for the control points 2 through 6.
NOTE: Use the Papywizard to find the yaw, pitch positions of each control points.

5) Where is it?
Here you go.

Code: Select all
<!--
 ! 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>

Jones

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 6:44 am

6) Where is the screen shot?
Here you go again.



no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 6:47 am

7) How do I use it?

a) First find a good scene for a time lapse. For example,



no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 6:48 am

7.b) find the control points.

For example, point 1 is here. Note down the yaw, pitch position from Papywizard main window.


Last edited by sjhenry on Sat Apr 10, 2010 6:49 am, edited 1 time in total.

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 6:50 am

Point 2 is here. Note down the yaw, pitch position from Papywizard main window.



no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 6:51 am

Point 3 is here. Note down the yaw, pitch position from Papywizard main window.



no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 6:51 am

Point 4 is here. Note down the yaw, pitch position from Papywizard main window.



no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 6:56 am

Now enter all the 4 control points in the preset window and generate the preset.

8) Setting up constant time:
====================
The total time between two shots are

"Stabilization Delay" + "Time Value" + time taken to move the head

Once you setup these times correctly, you will get a constant time between the shots.

If the time lapse video is shaky, use the DeShaker plugin http://www.sundancemediagroup.com/articles/deshaker_guide.htm for VirtualDub.

The example video before shake removal is at http://www.vimeo.com/10767739. The video after the shake removal is at http://www.vimeo.com/10767843

Jones

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 7:03 am

One more thing I forgot to mention is that the Bezier curve becomes a straight line when used with only two control points. It gives the flexibility of any orientation for the line. The code does not have any limitation on inputting the control points more than six. I have designed the screen to have only 6 control points for now. If it is not enough input points, it can be increased later.

Jones
Last edited by sjhenry on Sat Apr 10, 2010 7:04 am, edited 1 time in total.

User avatar
claudevh
Member
 
Posts: 1341
Joined: Sun Nov 25, 2007 11:12 pm
Location: Mont-Saint-André (Belgium)

by claudevh » Sat Apr 10, 2010 7:59 am

Hello Jones,

I have a small problem on line 57, character 35 : :/
for ( ctr = 1; ctr <= num; ctr++ )
---------------------^

Non valid character ...

Could-you have a look ?
Last edited by claudevh on Sat Apr 10, 2010 8:00 am, edited 1 time in total.
:cool: Claude :cool:
Merlin + Papywizard on Windows 7 & Nokia 770 § N810 & Acer (Netbook) + PanoramaApp Androïd + Deltawave PapyMerlin BT + Autopano
Spherical Pano (180 x 360) with Canon 40D + Canon EF-S 10-22mm f/3.5-4.5 Zoom & Pôle Pano with Canon 5D MK2 and shaved Tokina 10-17 3.5-4.5 AF DX Fisheye
Gigapixel photography with Nikon D200 + Sigma 70-200 F 2.8 EX DG APO HSM

User avatar
Paul
Member
 
Posts: 778
Joined: Sat Aug 30, 2008 4:46 pm
Location: Bonn, Germany

by Paul » Sat Apr 10, 2010 8:19 am

claudevh wrote:I have a small problem on line 57, character 35

I can run it unchanged with Firefox, saved with Notepad++

Code: Select all
     function factorial(num)
      {
          var ctr = 0;
          var result = 1;
          if ( num != 0 )
              for ( ctr = 1; ctr <= num; ctr++ )
                  result *= ctr;
          return ( result );
      }
Last edited by Paul on Sat Apr 10, 2010 8:19 am, edited 1 time in total.
Paul

close, but no cigar ... ... ...

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Sat Apr 10, 2010 4:52 pm

Claude,

I tested the script with IE and Firefox. It works fine. What browser are you using and the version? The "<=" is the javascript language element for the less than or equal. If the browser's javascript implementation is not correct, then it may error out.

The other problem could be that when copying, if one of the ";" is omitted, then it can error out.

Jones

User avatar
claudevh
Member
 
Posts: 1341
Joined: Sun Nov 25, 2007 11:12 pm
Location: Mont-Saint-André (Belgium)

by claudevh » Sat Apr 10, 2010 10:44 pm

Thank-you Jones, its fine now I have used Notepad ++ in place of Bonfire studio and it work fine now! :)
Thanks also to Paul for the idea of Notepad++ ;)
:cool: Claude :cool:
Merlin + Papywizard on Windows 7 & Nokia 770 § N810 & Acer (Netbook) + PanoramaApp Androïd + Deltawave PapyMerlin BT + Autopano
Spherical Pano (180 x 360) with Canon 40D + Canon EF-S 10-22mm f/3.5-4.5 Zoom & Pôle Pano with Canon 5D MK2 and shaved Tokina 10-17 3.5-4.5 AF DX Fisheye
Gigapixel photography with Nikon D200 + Sigma 70-200 F 2.8 EX DG APO HSM

no avatar
skyml
Member
 
Posts: 30
Joined: Wed Aug 18, 2010 2:41 pm
Location: Santa Ana, CA

by skyml » Thu Sep 30, 2010 6:30 am

Jones,

first off let me thank you for your hard work on your time lapse preset for Papywizard. Time Lapse is the primary reason why I built my rig and am hoping more people get involved in writing something to help us non-programers out here.

Here is a link to a short video I made using the Skywatcher (Merlin/Orion) for timelapse: http://www.youtube.com/watch?v=nenmhAEjFHs

I would love more control on the duration and number of shots as well as the number of key points or control points along both axis. The ability to speed up or slow down the number of frames between key points is of real interest and the ablity to run memorized key points at a faster speed without firing the shutter of even more interest (for overlaying time lapse and real time video - first pick the path and then shoot the time lapse then repeat the path in faster speed in video mode for the Canon 7D or a video camera then overlay both in an editor for cool effect).

The only confusing point I had with your layout was the lables for Yaw and Pitch as both begin with "P." I am not a programer at all but I dove in and played around with your preset looking to see what I could and of coursre the whole thing crashed.

Here is my botched effort :P:

Code: Select all
<!--
 ! 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>

Offline
Last edited by skyml on Thu Sep 30, 2010 6:35 am, edited 1 time in total.
Mike Lanfor
Celestron Skywatcher Panohead (firmeware version=010981), Papywizard, Nokia 800 (OS2008), Win 7 64 on Sony VIAO, Canon 7D, 40D, 30D with Canon 70-200mm F2.8L IS, 24-135mm F3.5 IS, Sigma 15mm F2.8, Vivitar 7mm f3.5 Fisheye for Canon (manual lens), Sigma 135-500mm f3.5/5.6.
Focus Time Lapse and Spherical Pano's/pano tours (Autopano gig and Tour). Dynamic Perception Dolly with MX2.

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Tue Oct 26, 2010 3:20 am

I like the time lapse video you have here. It is very good.

Regarding the label, I named then same due to representing the same point and one is for yaw and another one is for pitch. You will see this within the ( and ). For example, the P2 has two points with label P2(yaw) and P2(pitch).

It is easy to add the number of shots to Bezier curve time lapse at any given position. But speeding up and slowing done can not be done using the preset. In order to do that, I think the speed of the head needs to be changed.

One other way to do is to skip intermediate points so that it looks like speeding up or slowing down. I am not sure whether it will work or not.

Jones
Last edited by sjhenry on Tue Oct 26, 2010 3:26 am, edited 1 time in total.

no avatar
skyml
Member
 
Posts: 30
Joined: Wed Aug 18, 2010 2:41 pm
Location: Santa Ana, CA

by skyml » Tue Oct 26, 2010 3:34 am

Jones,

thanks for your reply. You mention it is easy to change the number of shots at any given position but I am clueless on how to do that. Would love to tell it to take (for example) 300 shots between point 1 and 2 and then 150 shots between 2 and 3. How would I do that? I believe doing so would give it the effect of slow between point one and two and then faster between point two and three.

Thanks!

Mike
Mike Lanfor
Celestron Skywatcher Panohead (firmeware version=010981), Papywizard, Nokia 800 (OS2008), Win 7 64 on Sony VIAO, Canon 7D, 40D, 30D with Canon 70-200mm F2.8L IS, 24-135mm F3.5 IS, Sigma 15mm F2.8, Vivitar 7mm f3.5 Fisheye for Canon (manual lens), Sigma 135-500mm f3.5/5.6.
Focus Time Lapse and Spherical Pano's/pano tours (Autopano gig and Tour). Dynamic Perception Dolly with MX2.

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Mon Nov 01, 2010 12:15 am

Mike,

I misunderstood what you said about the multiple shots. . I thought that you were mentioning about multiple shots at a given position - for example to do a HDR with multiple exposures.

I can still think of a way to have different speed between these control points. Open the GUI to enter 5 more text fileds to enter the number of shots between point1 and point2, point2 and point3 etc. Then find the largest number of shots needed between any two points. This maximum number will be correct between those two points. For a slower speed, the some of the shots will be skipped. This needs some change to the code.

Jones

User avatar
bruper
Member
 
Posts: 31
Joined: Mon Feb 15, 2010 12:01 pm
Location: Portugal

by bruper » Mon Feb 21, 2011 1:46 am

I copied/paste the above script on textedit and save it with the title bezier_preset.xml but I get almost the same error as Claude (error line 57 column 34) with PW 2.1.20. I use Mac and I believe there is no Notepad++ for it. Any ideas please?
Bruno
_____
Merlin mount, Sony EX3 with Adaptimax and some Nikon lenses, Canon 60D with some Canon & Tokina lenses, etc. PapyWizard on MBP 17" 2.93 GHz, OS 10.6.6

User avatar
bruper
Member
 
Posts: 31
Joined: Mon Feb 15, 2010 12:01 pm
Location: Portugal

by bruper » Mon Feb 21, 2011 2:09 am

I would like to use it for a stop-animation project where the movement would be controlled step by step, the all movement would be designed on the set as if it was a computerized motion control with bezier speed and moves... would be great!!
Bruno
_____
Merlin mount, Sony EX3 with Adaptimax and some Nikon lenses, Canon 60D with some Canon & Tokina lenses, etc. PapyWizard on MBP 17" 2.93 GHz, OS 10.6.6

User avatar
mjaszo
Member
 
Posts: 39
Joined: Mon Jul 18, 2011 1:17 pm
Location: Biala Podlaska / Warsaw

by mjaszo » Mon Jul 18, 2011 2:04 pm

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!
Canon 5D II / 24-105mm 4 L / 50mm 1.4 II / Tokina 10-17mm FE / Panogear / PanoMaxx / APG / PTP / CS5 / blue BIC pen etc.

no avatar
Mateusz Malinowski
Member
 
Posts: 85
Joined: Tue Apr 19, 2011 7:46 pm
Location: Polska

by Mateusz Malinowski » Tue Jul 24, 2012 4:39 pm

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.
Last edited by Mateusz Malinowski on Thu Jul 26, 2012 10:11 am, edited 1 time in total.

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Thu Aug 09, 2012 3:21 am

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!

Hi mjaszo,

The Bezier curve timelapse preset will not go through the points you input. The input points are called control points to control how the curve is defined. If you need to have that points in your preset, then you have to use the other timelapse preset.

Jones

no avatar
sjhenry
Member
 
Posts: 146
Joined: Tue Mar 10, 2009 1:43 am
Location: Colorado, USA

by sjhenry » Thu Aug 09, 2012 3:33 am

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.

Hi,

I think that there is a misunderstanding on this Bezier curve preset generator. The input points are called control points to control how the Bezier curve is defined. It will not go through the points unless you have only defined two points and that will be a straight line. If you need to go through all point, please try the http://www.kolor.com/forum/t6748-papywizard-timelapse-preset-generator preset generator.

In your example, you have to generate 4 different preset using two points at a time and combine it manually.

fps 25
Point1(0,0)
Point2(0,30)
Point3(90,90)
Point4(180,30)
Point5(0,0)

First preset for P1(0,0) and P2(0,30)
Second preset for P1(0,30) to P2(90,90)
Third preset for P1(90,90) to P2(180,30)
Fourth preset for P1(180,30) to P2(0,0)

Then combine the xmls generated manually to have one valid xml.

Jones


Return to Timelapse and related applications

Who is online

Users browsing this forum: No registered users and 1 guest