[vtkusers] Need help with vtkVideoSource

leonid tazin at iec.co.il
Tue Aug 5 06:05:38 EDT 2003


  Hi  All
Does anybody know , how to connect mpeg video with vtkVideoSource in next tcl sample

package require vtk

vtkImageReader2 mpeg
mpeg SetFileName random.mpg
mpeg Update

vtkVideoSource grabber
grabber SetInput [mpeg GetOutput] ;# not existing  method  !!!
grabber SetOutputFormatToRGB  
grabber SetFrameSize 320 240 1
grabber SetOutputWholeExtent 0 159 0 119 0 0
grabber SetFrameBufferSize 26
grabber SetNumberOfOutputFrames 26
grabber Grab  
[grabber GetOutput] UpdateInformation  

vtkImageViewer viewer  
viewer SetInput [grabber GetOutput]   
#[viewer GetImageWindow] DoubleBufferOn  
viewer SetColorWindow 255 
viewer SetColorLevel 127.5 
viewer SetZSlice 0 

viewer Render  

proc animate {} {
    if { [grabber GetPlaying] == 1 } {viewer Render; after 1 animate}
} 

proc Play {} {if { [grabber GetPlaying] != 1 } {grabber Play; animate}}  

proc Stop {} {grabber Stop}  

proc Grab {} {grabber Grab; viewer Render}  

proc SetFrameRate { r } {grabber SetFrameRate $r}  

proc SetFrame { f } {viewer SetZSlice $f ; viewer Render}

wm withdraw .
toplevel .t
frame .t.controls 
button .t.controls.grab -text "Grab" -command Grab 
pack .t.controls.grab -side left 
button .t.controls.stop -text "Stop" -command Stop 
pack .t.controls.stop -side left 
button .t.controls.play -text "Play" -command Play 
pack .t.controls.play -side left 
pack .t.controls -side top  

frame .t.rate 
label .t.rate.label -text "Frames/s" 
scale .t.rate.scale -from 0.0 -to 60.0 -orient horizontal -command SetFrameRate
.t.rate.scale set [grabber GetFrameRate]   

pack .t.rate.label -side left 
pack .t.rate.scale -side left 
pack .t.rate -side top 

frame .t.viewframe
label .t.viewframe.label -text "Frame #" 
scale .t.viewframe.scale -from 0 -to 25 -orient horizontal -command SetFrame

pack .t.viewframe.label -side left 
pack .t.viewframe.scale -side left 
pack .t.viewframe -side top 

frame .t.ex  
button .t.ex.button -text "Exit" -command ::vtk::cb_exit
pack .t.ex.button -side left 
pack .t.ex -side top 

Thanks a lot. Leonid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030805/b98954c1/attachment.htm>


More information about the vtkusers mailing list