Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1543 - in trunk: Engine/Display SwigInterface UserInterface


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1543 - in trunk: Engine/Display SwigInterface UserInterface
  • Date: Tue, 24 Jul 2007 08:50:40 -0600 (MDT)

Author: abe
Date: Tue Jul 24 08:50:40 2007
New Revision: 1543

Modified:
   trunk/Engine/Display/FileDisplay.cc
   trunk/Engine/Display/FileDisplay.h
   trunk/SwigInterface/manta.i
   trunk/UserInterface/CameraPathAutomator.cc
   trunk/UserInterface/CameraPathAutomator.h
Log:

Modified camera path utility to work with a swig/python ui. UI allows
creating camera paths for benchmarks and movies. Image sequences may
be rendered from camera paths and automatically resampled to renderer
performance. Benchmarks may be plotted inside manta via matplotlib.


M    SwigInterface/manta.i
M    UserInterface/CameraPathAutomator.cc
M    UserInterface/CameraPathAutomator.h
M    Engine/Display/FileDisplay.cc
M    Engine/Display/FileDisplay.h


Modified: trunk/Engine/Display/FileDisplay.cc
==============================================================================
--- trunk/Engine/Display/FileDisplay.cc (original)
+++ trunk/Engine/Display/FileDisplay.cc Tue Jul 24 08:50:40 2007
@@ -60,7 +60,9 @@
   file_number( 0 ),
   skip_frames( 0 ),
   prefix( "manta_frame" ),
-  type_extension( "png" )
+  type_extension( "png" ),
+  init_time( Time::currentSeconds() ),
+  use_timestamp( true )  
 {
 
   
/////////////////////////////////////////////////////////////////////////////
@@ -101,14 +103,15 @@
   }
 }
 
-FileDisplay::FileDisplay(const string &prefix_, const string &type_, int 
offset_, int skip_, bool fps_ ) :
+FileDisplay::FileDisplay(const string &prefix_, const string &type_, int 
offset_, int skip_, bool use_timestamp_, bool fps_ ) :
   display_fps( fps_ ),
   current_frame( 0 ),
   file_number( offset_ ),
   skip_frames( skip_ ),
   prefix( prefix_ ),
-  type_extension( type_ )
-  
+  type_extension( type_ ),
+  init_time( Time::currentSeconds() ),
+  use_timestamp( use_timestamp_ )
 {
 
   // Determine which writer to use.
@@ -138,6 +141,18 @@
   // Check to see if we should skip the frame.
   if (!skip_frames || ((current_frame % skip_frames) == 0)) {
 
+    // Record the timestamp of this file.
+    unsigned number;
+    unsigned width = 10;
+    if (use_timestamp) {
+      const float delta_time = (Time::currentSeconds() - init_time);
+      number = (unsigned)(delta_time*1000.0f);
+    }
+    else {
+      number = file_number;
+    }
+    
+    // Record time to output file.
     double start_time;
     if (display_fps) {
       start_time = Time::currentSeconds();
@@ -154,8 +169,8 @@
       stringstream lss, rss;
       
       // Output left and right images.
-      lss << prefix << "_left_" << setfill( '0' ) << setw( 5 ) << 
file_number << "." << type_extension;
-      rss << prefix << "_right_" << setfill( '0' ) << setw( 5 ) << 
file_number << "." << type_extension;
+      lss << prefix << "_left_" << setfill( '0' ) << setw( width ) << number 
<< "." << type_extension;
+      rss << prefix << "_right_" << setfill( '0' ) << setw( width ) << 
number << "." << type_extension;
       
       // Send the image to the appropriate writer.
       if (writer == TGA_WRITER) {
@@ -170,7 +185,11 @@
       
       // Otherwise output a single image.
       stringstream ss;
-      ss << prefix << "_" << setfill( '0' ) << setw( 5 ) << file_number << 
"." << type_extension;
+      ss << prefix << "_"
+         << setfill( '0' )
+         << setw( width )
+         << number
+         << "." << type_extension;
       
       if (writer == TGA_WRITER) {
         writeTGA( image, ss.str(), 0 );

Modified: trunk/Engine/Display/FileDisplay.h
==============================================================================
--- trunk/Engine/Display/FileDisplay.h  (original)
+++ trunk/Engine/Display/FileDisplay.h  Tue Jul 24 08:50:40 2007
@@ -45,7 +45,7 @@
     enum { TGA_WRITER, NRRD_WRITER };
     
     FileDisplay(const vector<string>& args);
-    FileDisplay(const string &prefix, const string &type, int offset = 0, 
int skip = 0, bool fps = false );
+    FileDisplay(const string &prefix, const string &type, int offset = 0, 
int skip = 0, bool use_timestamp_ = true, bool fps = false );
     
     virtual ~FileDisplay();
     virtual void setupDisplayChannel(SetupContext&);
@@ -61,6 +61,8 @@
     int    skip_frames;
     string prefix;
     string type_extension;
+    float  init_time;
+    bool   use_timestamp; // Use either timestamp of file number counter.
     
   private:
     FileDisplay(const FileDisplay&);

Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Tue Jul 24 08:50:40 2007
@@ -67,6 +67,8 @@
 #include <Engine/Display/OpenGLDisplay.h>
 #include <Engine/Display/PureOpenGLDisplay.h>
 #include <Engine/Display/NullDisplay.h>
+#include <Engine/Display/FileDisplay.h>
+#include <Engine/Display/MultiDisplay.h>
 
 #include <Engine/ImageTraversers/NullImageTraverser.h>
 #include <Engine/ImageTraversers/DeadlineImageTraverser.h>
@@ -90,6 +92,8 @@
 %include <Engine/Display/OpenGLDisplay.h>
 %include <Engine/Display/PureOpenGLDisplay.h>
 %include <Engine/Display/NullDisplay.h>
+%include <Engine/Display/FileDisplay.h>
+%include <Engine/Display/MultiDisplay.h>
 
 %include <Engine/ImageTraversers/NullImageTraverser.h>
 %include <Engine/ImageTraversers/DeadlineImageTraverser.h>
@@ -109,11 +113,12 @@
 %{
 #include <UserInterface/AutomatorUI.h>
 #include <UserInterface/SyncFrameAutomator.h>
+#include <UserInterface/CameraPathAutomator.h>
 %}
 
 %include <UserInterface/AutomatorUI.h>
 %include <UserInterface/SyncFrameAutomator.h>
-
+%include <UserInterface/CameraPathAutomator.h>
 
 ////////////////////////////////////////////////////////
 // Lights and backgrounds

Modified: trunk/UserInterface/CameraPathAutomator.cc
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.cc  (original)
+++ trunk/UserInterface/CameraPathAutomator.cc  Tue Jul 24 08:50:40 2007
@@ -64,6 +64,7 @@
   last_sync_frame( 0 ),
   last_sync_seconds( 0 ),
   average_fps( 0 ),
+
   delta_t( delta_t_ ),
   delta_time( delta_time_ ),
   total_points( total_points_ ),
@@ -83,6 +84,40 @@
   }
 }
 
+CameraPathAutomator::CameraPathAutomator( MantaInterface *manta_interface_, 
int channel_,
+                                          int warmup_, CameraPathDataVector 
&camera_data,
+                                          Real delta_t_, Real delta_time_ )
+  :
+  AutomatorUI( manta_interface_, warmup_ ),
+  synchronize_barrier( "sync barrier" ),
+  channel( channel_ ),
+  last_sync_frame( 0 ),
+  last_sync_seconds( 0 ),
+  average_fps( 0 ),
+  delta_t( delta_t_ ),
+  delta_time( delta_time_ ),
+  total_points( camera_data.size() ),
+  sync_frames( 0 ),
+  loop_behavior( PATH_STOP ),
+  interval_start( 1 ),
+  interval_last ( camera_data.size()-2 )
+
+{
+  eye    = new Vector[total_points];
+  lookat = new Vector[total_points];
+  up     = new Vector[total_points];
+
+  for(int i = 0; i < total_points; ++i) {
+    eye[i]    = camera_data[i].eye;
+    lookat[i] = camera_data[i].lookat;
+    up[i]     = camera_data[i].up;
+  }
+
+  // Reserve storage for the performance statistics results.
+  performance.reserve( 1024 );
+}
+
+
 
 
 CameraPathAutomator::CameraPathAutomator( MantaInterface *manta_interface_, 
int channel_, 
@@ -347,6 +382,9 @@
   std::cerr << "Beginning camera path " << total_points 
             << " control points. Using interval " << first_point << ":" << 
last_point << std::endl;
 
+  // Clear performance statistics.
+  performance.clear();
+  
   int transaction_number = 0;
   
   do {
@@ -432,6 +470,8 @@
   getMantaInterface()->getCamera( channel )->reset( eye_, up_, lookat_ );
 }
 
+
+
 void CameraPathAutomator::mantaSynchronize( int issue_transaction ) {
 
   // Wait for either the renderer thread or the camera path thread.
@@ -448,7 +488,12 @@
   last_sync_seconds = current_sync_seconds;
   last_sync_frame   = current_sync_frame;
 
-  if (!sync_quiet) {
+  if (sync_quiet) { 
+
+    // Store the statistics.
+    performance.push_back( elapse_frame/elapse_seconds );
+  }
+  else {
     // Output performance since last sync.
     std::cout << current_sync_frame << " "
               << issue_transaction << " "
@@ -459,6 +504,7 @@
               << std::endl;
     // stdout flush is necessary so that output occurs before program 
terminates.
   }
+  
 }
 
 
///////////////////////////////////////////////////////////////////////////////

Modified: trunk/UserInterface/CameraPathAutomator.h
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.h   (original)
+++ trunk/UserInterface/CameraPathAutomator.h   Tue Jul 24 08:50:40 2007
@@ -29,6 +29,7 @@
 #ifndef __CAMERAPATHAUTOMATOR_H__
 #define __CAMERAPATHAUTOMATOR_H__
 
+#include <Interface/Camera.h>
 #include <UserInterface/AutomatorUI.h>
 
 #include <MantaTypes.h>
@@ -39,15 +40,45 @@
 #include <string>
 #include <vector>
 
+#ifdef SWIG
+%template (vector_float) std::vector<float>;
+%template (vector_BasicCameraData) std::vector<Manta::BasicCameraData>;
+#endif
+
 namespace Manta {
 
   using std::string;
   using std::vector;
+#ifndef SWIG
   using SCIRun::Barrier;
+#endif
+
+  // std::vector wrapper class for swig.
+  class CameraPathDataVector : public std::vector<BasicCameraData> {
+    typedef std::vector<BasicCameraData> Parent;
+  public:    
+    CameraPathDataVector( ) { }
+    CameraPathDataVector( unsigned size_ ) : Parent( size_ ) { };
+
+    void PushBack( BasicCameraData data ) { push_back( data ); }
+    void Clear() { clear(); }
+  };
+
 
+
+  class CameraPathPerformanceVector : public std::vector<float> {
+    typedef std::vector<float> Parent;
+  public:    
+    CameraPathPerformanceVector( ) { }
+    CameraPathPerformanceVector( unsigned size_ ) : Parent( size_ ) { };
+
+    int __len__ () {
+      return size();
+    }
+  };
+  
   class CameraPathAutomator : public AutomatorUI {
   private:
-
     
///////////////////////////////////////////////////////////////////////////
     // Control points.
     Vector *eye;
@@ -55,6 +86,8 @@
     Vector *up;
     int total_points;
 
+    CameraPathPerformanceVector performance;
+    
     
///////////////////////////////////////////////////////////////////////////
     // Parameter t interval between control points.
     Real delta_t;
@@ -93,6 +126,7 @@
   public:
     // Loop Behaviors
     enum { PATH_STOP, PATH_EXIT, PATH_LOOP, PATH_ABORT };
+    
 
     CameraPathAutomator( MantaInterface *manta_interface_, int channel_,
                          int warmup_, const string &file_name,
@@ -102,6 +136,10 @@
                          int warmup_, Vector *eye_, Vector *lookat_,
                          Vector *up_, int total_points_,
                          Real delta_t_ = 0.2, Real delta_time_ = 0.2 );
+    CameraPathAutomator( MantaInterface *manta_interface_, int channel_,
+                         int warmup_, CameraPathDataVector &camera_data,
+                         Real delta_t_, Real delta_time_ );
+    
     ~CameraPathAutomator();
 
     // Create method called by RTRT_register.
@@ -143,6 +181,8 @@
     
     // Get the fps for the last complete run.
     inline Real get_average_fps() { return average_fps; };
+
+    inline CameraPathPerformanceVector get_performance() { return 
performance; }
 
   };
 };




  • [MANTA] r1543 - in trunk: Engine/Display SwigInterface UserInterface, abe, 07/24/2007

Archive powered by MHonArc 2.6.16.

Top of page