ffmpeg : avi to image sequence

April 17th, 2008

convert 10 frames, starting at 45 seconds, no sound, 3-digit padding

  1. ffmpeg -i movie.avi -ss 45 -vframes 10 -an -f image2 %3d.png

arduino node for yg

March 27th, 2008
  1. </p>
  2. //arduino.h
  3.  
  4. #ifndef _arduino_h_
  5. #define _arduino_h_
  6.  
  7. #include "ygNode.h"
  8. #include
  9.  
  10. class arduino : public ygNode
  11. {
  12. public:
  13. arduino(const char* name,bool master=true);
  14. ~arduino ();
  15. virtual void reset(void);
  16. virtual void message(const ygMessage&);
  17. virtual void app(void);
  18. void openPort (void);
  19. private:
  20. int fd;  // file descriptor;
  21. FILE *file;ygString device;
  22. bool changed;
  23. protected:
  24. pthread_rwlock_t m_lock;
  25. void lock();
  26. void unlock();
  27. };
  28.  
  29. #endif
  30.  
  31. // arduino.cxx
  32.  
  33. #include "arduino.h"
  34. #include
  35. #include
  36. #include
  37. #include
  38. #include
  39. #include
  40. #include
  41. #include
  42. #include
  43.  
  44. using namespace std;
  45.  
  46. extern "C" ygNode* construct_arduino(const char* name,bool master) { return new arduino(name,master); }
  47.  
  48. arduino::arduino(const char* name,bool master) : ygNode(name,master)
  49. {
  50. setClassName("arduino");
  51. fd = 0;
  52.  
  53. pthread_rwlock_init(&m_lock,NULL);
  54.  
  55. }
  56.  
  57. arduino::~arduino ()
  58. {
  59. fclose(file);
  60. close (fd);
  61. pthread_rwlock_destroy(&m_lock);
  62. }
  63.  
  64. void arduino::reset(void)
  65. {
  66. ygNode::reset();
  67. }
  68.  
  69. void arduino::lock()
  70. {
  71. pthread_rwlock_wrlock(&m_lock);
  72. }
  73.  
  74. void arduino::unlock()
  75. {
  76. pthread_rwlock_unlock(&m_lock);
  77. }
  78.  
  79. void arduino::message(const ygMessage& msg)
  80. {
  81. if (msg == "port")
  82. {
  83. /* mymessage(msg.floatArg(0)); */
  84.  
  85. device = msg.args[0];
  86. openPort ();
  87. }
  88. else
  89. ygNode::message(msg);
  90. }
  91.  
  92. void arduino::openPort ()
  93. {
  94. termios oldtio, tio;
  95.  
  96. fd = ::open(device.c_str(),O_RDWR | O_NOCTTY);
  97.  
  98. if (fd<0)
  99. {
  100. printf ("serial open: error = %d\n",errno);
  101. printf ("serial open: error = %s\n",strerror(errno));
  102. }
  103. else
  104. {
  105. file = fdopen(fd,"rw");
  106. tcgetattr(fd, &oldtio);
  107.  
  108. tio.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
  109. tio.c_iflag = IGNPAR;
  110. tio.c_oflag = 0;
  111. tio.c_lflag = 0;
  112.  
  113. tio.c_cc[VMIN]=1;
  114. tio.c_cc[VTIME] = 1;
  115.  
  116. tcflush (fd,TCIFLUSH);
  117. tcsetattr(fd,TCSANOW,&tio);
  118. }
  119. }
  120.  
  121. void arduino::app(void)
  122. {
  123. ygString args;
  124. char buffer[256];
  125. char cvalue[32];
  126. int count;
  127. int v1=0,v2=0,v3=0;
  128. int i;
  129. if (fd>0)
  130. {    lock();
  131. //count = fd.getline(buffer,256);
  132. fscanf(file,"%d,%d,%d",&v1,&v2,&v3);
  133. unlock();
  134. //printf ("%d %d %d\n",v1,v2,v3);
  135. sprintf (cvalue,"value1=%d ",v1);
  136. args += cvalue;
  137. sprintf (cvalue,"value2=%d ",v2);
  138. args += cvalue;
  139. sprintf (cvalue,"value3=%d ",v3);
  140. args += cvalue;
  141. eventOccurred ("data",args);
  142. }
  143.  
  144. ygNode::app();
  145. }

QIII sound in ubuntu

March 16th, 2008

if errors about DMA / unable to map /dev/dsp:

edit this file:

/proc/asound/card0/pcm0p

add lines for programs that should be allowed to have DMA:

quake3 0 0 direct

pdm 0 0 direct

handy encoding examples

March 15th, 2008

http://www-i6.informatik.rwth-aachen.de/~dreuw/videotools.html

JPEG to AVI: mencoder -ovc lavc -mf fps=25:type=jpg ‘mf://*.jpg’ -vf harddup -ofps 25 -noskip -o outputfile.avi

xorg.conf with Xinerama for cavelibs

March 15th, 2008

this configuration works by defining each head on the card as its own device.  the ServerLayout is where they get combined.  The Virtual option in the Display subsection gives us a bigger desktop which we need to cut off the OpenGL Performer logo.

Section “ServerLayout”
Identifier     “Default Layout”
Screen      0  “Screen0″
Screen      1  “Screen1″ RightOf “Screen0″
InputDevice    “Generic Keyboard”
InputDevice    “Configured Mouse”
InputDevice    “stylus” “SendCoreEvents”
InputDevice    “cursor” “SendCoreEvents”
InputDevice    “eraser” “SendCoreEvents”
EndSection

Section “ServerFlags”
Option         “Xinerama” “1″
EndSection

Section “Monitor”
Identifier     “Monitor1″
VendorName     “Unknown”
ModelName      “WDE LCM-19v7″
HorizSync       30.0 - 82.0
VertRefresh     56.0 - 76.0
EndSection

Section “Monitor”
Identifier     “Monitor0″
VendorName     “Unknown”
ModelName      “HSD HW191A”
HorizSync       30.0 - 80.0
VertRefresh     49.0 - 75.0
EndSection

Section “Device”
Identifier     “Videocard0″
Driver         “nvidia”
VendorName     “NVIDIA Corporation”
BoardName      “Quadro FX 1400″
BusID       “PCI:1:0:0″
Screen       0
EndSection

Section “Device”
Identifier     “Videocard1″
Driver         “nvidia”
VendorName     “NVIDIA Corporation”
BoardName      “Quadro FX 1400″
BusID          “PCI:1:0:0″
Screen         1
EndSection

Section “Screen”
Identifier     “Screen0″
Device         “Videocard0″
Monitor        “Monitor0″
DefaultDepth    24
SubSection    “Display”
Depth        24
Modes        “1280×1024″ “1024×768″
Virtual        1280 1280
EndSubSection
EndSection

Section “Screen”
Identifier     “Screen1″
Device         “Videocard1″
Monitor        “Monitor1″
DefaultDepth    24
SubSection    “Display”
Depth        24
Modes        “1280×1024″ “1024×768″
Virtual        1280 1280
EndSubSection
EndSection

Section “Extensions”
Option         “Composite” “0″
EndSection

Compiling OpenCV

February 28th, 2008

a couple of patches needed.

using ffmpeg from svn

in  cvcap_ffmpeg.cpp


#define INT64_C
#define __STDC_CONSTANT_MACROS
#include 

#include “_highgui.h”

extern “C” {
#include

#include

#ifndef WIN32
#include 
#endif
}

//#define INT64_C (long long)

February 20th, 2008

April 23rd, 2007

??

syndication test

February 5th, 2007

syndication test post

Using Macro Functions in Ygdrasil

July 23rd, 2006

One of Ygdrasil’s major shortcomings has always been that you cannot encapsulate code using something like functions, classes, instances, VRML’s PROTO nodes, or other kinds of abstractions. A common Yg construction might involve an object node, a sound node, and a trigger node. like this:

wandTrigger trigger1 (when(start,sound1.play,object1.size(1.5)),when(stop,object1.size(1)))
{
sound sound1(file(glass.aiff))
object object1 (file(glass.pfb),position(0 5 3))
}

if you have, say, 20 or 30 objects that you want to create like this, that means 20 wandTriggers, 20 objects, 20 sound files, all with the appropriate routing between them. makes the scene file a little cluttered. what we’d like to do is make a function, or template, or prototype for this combination of nodes and the way they behave, so we could say things like :

soundObject (1,glass,0,5,3)

which would give it a number, the name for the .pfb and the .aiff to use, and position.

one way to do this would of course be to write a quick little perl or python script to generate the text, and then paste it into your scene or use a #include. or, you can use the magic of the C Preprocessor to define Macro Functions right in the scene file.

#define makething(N,NAME,X,Y) 
pointAtTrigger(when(button1,anim_##N.start(1))) 
{
mayaAnimation anim_##N (file(NAME##_1.anim))
{
object object_##N (file(NAME.pfb),position(X Y 0))
}
}

makething(1,alve_bureau,-15,10)
makething(2,alve_cornerstation,-10,10)
etc.