Changeset 2023
- Timestamp:
- Jan 9, 2011, 9:30:53 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 18 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/video/dial/dialdemo.tcl
r1979 r2023 45 45 after 200 { 46 46 update idletasks 47 .f.d3 mark add loopstart 548 .f.d3 mark add loopend 1047 # .f.d3 mark add loopstart 5 48 # .f.d3 mark add loopend 10 49 49 .f.d3 mark add particle0 17 50 50 .f.d3 mark add particle1 10 -
trunk/examples/video/piv/intro.html
r1928 r2023 1 1 <html> 2 2 <body> 3 <h1>PIV tool</h1> 4 <p>add info about how piv tool works</p> 3 <center> 4 <h1>ParticleVE</h1> 5 <h2>a particle tracking velocimetry tool</h2> 6 </center> 7 <p> 8 Track particles in videos to calculate an estimate of 9 their velocity. 10 </p> 11 12 <h3>What is Particle Velocity Estimation</h3> 13 <p> 14 <!-- text from wikipedia --> 15 Particle tracking velocimetry (PTV) is a velocimetry method, i.e a technique to measure velocity of particles. The name suggests that the particles are tracked, and not only recorded as an image as it is suggested in another form, particle image velocimetry. There are two very different experimental methods: 16 17 * the two dimensional (2D) modification of Particle Image Velocimetry (PIV), in which the flow field is measured in the two-dimensional slice of the flow, illuminated by a laser sheet (a thin plane) and low density of seeded particles allow for the tracking each of them individually for several frames. 18 * the Three-Dimensional Particle tracking velocimetry (3D-PTV) is a distinctive experimental technique, based on multiple camera-system, three-dimensional volume illumination and tracking of flow tracers (i.e. particles) in three-dimensional space by using photogrammetric principles. 19 </p> 20 <h3>Get Started:</h3> 21 <ol> 22 <li>Choose a video to track particles in.</li> 23 <li>Preview the video, searching for interesting frames.</li> 24 <li>Mark particle locations and analyze the frames.</li> 25 </ol> 26 <center> 27 <img src="images/pve_demo_small.png"/> 28 </center> 29 30 <h3>Practical Applications:</h3> 31 <p></p> 32 33 <h3>Learn More:</h3> 34 <ol> 35 <li><a href="http://wikipedia.org/wiki/Particle_tracking_velocimetry">Particle Tracking Velocimetry (PTV)</a></li> 36 <li><a href="http://wikipedia.org/wiki/Particle_image_velocimetry">Particle Image Velocimetry (PIV)</a></li> 37 </ol> 5 38 </body> 6 39 </html> -
trunk/examples/video/piv/piv.tcl
r1979 r2023 7 7 package require RapptureGUI 8 8 package require BLT 9 package require Img 9 10 10 11 … … 36 37 wm title . "particle velocity estimate" 37 38 wm withdraw . 39 set width 960 40 set height 625 41 42 set installdir [file dirname [ \ 43 Rappture::utils::expandPath [ \ 44 file normalize [info script]]]] 45 38 46 39 47 … … 53 61 set f [$nb insert end about] 54 62 55 # loader for videos56 63 57 set loader [frame $f.loader]58 64 59 label $loader.icon -image [Rappture::icon folder] 60 pack $loader.icon -side left 61 label $loader.name -borderwidth 1 -relief solid -background white -anchor w 62 pack $loader.name -side left -expand yes -fill x -padx 2 63 button $loader.go -text "Upload..." 64 pack $loader.go -side right 65 # html intro page 65 66 66 # create an html intro page 67 68 set intro [frame $f.intro -borderwidth 1 -width 300 -height 300] 67 set intro [frame $f.intro] 69 68 70 69 Rappture::Scroller $intro.scroller -xscrollmode auto -yscrollmode auto … … 79 78 $intro.scroller.html load $html 80 79 81 set demo [frame $f.demo]82 80 81 # verticle divider 82 set div [frame $f.div -width 1 -background black] 83 84 85 set previewVar "" 86 87 # movie chooser 88 89 set chooser [frame $f.chooser_f] 90 91 set fid [open [file join $installdir images step1.png] r] 92 fconfigure $fid -translation binary -encoding binary 93 set data [read $fid] 94 close $fid 95 set imh [image create photo] 96 $imh put $data 97 label $chooser.step1 -image $imh 98 99 set vc [Rappture::VideoChooser $chooser.vc -variable ::previewVar] 100 $vc load [glob "/home/derrick/projects/piv/video/*.mp4"] 101 # $vc load [glob "/apps/piv/video/*.mp4"] 102 103 pack $chooser.step1 -side top -anchor w -pady 8 104 pack $vc -side bottom -anchor center 105 106 107 108 # movie previewer 109 110 set preview [frame $f.preview_f] 111 112 set fid [open [file join $installdir images step2.png] r] 113 fconfigure $fid -translation binary -encoding binary 114 set data [read $fid] 115 close $fid 116 set imh [image create photo] 117 $imh put $data 118 label $preview.step2 -image $imh 119 120 set vp [Rappture::VideoPreview $preview.preview -variable ::previewVar] 121 122 pack $preview.step2 -side top -anchor w -pady 8 123 pack $vp -side bottom -anchor center 124 125 126 127 # analyze button gets us to the analyze page 128 129 set analyze [frame $f.analyze_f] 130 131 set fid [open [file join $installdir images step3.png] r] 132 fconfigure $fid -translation binary -encoding binary 133 set data [read $fid] 134 close $fid 135 set imh [image create photo] 136 $imh put $data 137 label $analyze.step3 -image $imh 138 139 button $analyze.go \ 140 -text "Analyze" \ 141 -command { 142 $vp video stop 143 $vs load file $previewVar 144 $vs video seek [$vp query framenum] 145 $nb current next> 146 # FIXME: video loaded into memory twice 147 } 148 pack $analyze.step3 -side left -anchor w 149 pack $analyze.go -anchor center 150 151 152 set reqwidth [expr round($width/2.0)] 83 153 blt::table $f \ 84 0,0 $intro -rowspan 3 -fill both \ 85 0,1 $demo -fill x \ 86 1,1 $loader -fill x 154 0,0 $intro -rowspan 3 -fill both -reqwidth $reqwidth\ 155 0,1 $div -rowspan 3 -fill y -pady 8 -padx 8\ 156 0,2 $chooser -fill x -padx {0 8}\ 157 1,2 $preview -fill x \ 158 2,2 $analyze -fill x 87 159 88 blt::table configure $f c* -resize both 160 blt::table configure $f c0 -resize none 161 blt::table configure $f c1 -resize none 162 blt::table configure $f c2 -resize none 89 163 # blt::table configure $f r0 -pady 1 90 164 … … 94 168 95 169 set f [$nb insert end video] 96 set movieViewer [Rappture::VideoScreen $f.viewer]97 $loader.go configure -command {$nb current next>; $movieViewer loadcb} 170 set vs [Rappture::VideoScreen $f.viewer -fileopen {$nb current about}] 171 pack $vs -expand yes -fill both 98 172 99 pack $movieViewer -expand yes -fill both100 173 101 174 # ------------------------------------------------------------------ … … 103 176 # ------------------------------------------------------------------ 104 177 178 105 179 $nb current about 106 wm geometry . 900x600180 wm geometry . ${width}x${height} 107 181 wm deiconify . 108 update idletasks109 182 110 # for testing we automatically load a video 111 array set videoFiles [list \ 112 1 "/home/derrick/projects/piv/video/TOPHAT_06-03-10_16-05-55.mp4" \ 113 2 "/home/derrick/projects/piv/video/TOPHAT_06-03-10_16-09-56.mp4" \ 114 3 "/home/derrick/projects/piv/video/TOPHAT_06-03-10_16-13-56.mp4" \ 115 4 "/home/derrick/junk/coa360download56Kbps240x160.mpg" \ 116 ] 117 $nb current video 118 update idletasks 119 $movieViewer load file $videoFiles(1) 183 #update idletasks 184 #image delete $imh -
trunk/gui/scripts/Makefile.in
r1979 r2023 114 114 $(srcdir)/utils.tcl \ 115 115 $(srcdir)/valueresult.tcl \ 116 $(srcdir)/videochooser.tcl \ 117 $(srcdir)/videochooserinfo.tcl \ 116 118 $(srcdir)/videodial.tcl \ 119 $(srcdir)/videodial1.tcl \ 120 $(srcdir)/videodial2.tcl \ 117 121 $(srcdir)/videodistance.tcl \ 118 122 $(srcdir)/videoscreen.tcl \ 123 $(srcdir)/videospeed.tcl \ 119 124 $(srcdir)/videoparticle.tcl \ 125 $(srcdir)/videopreview.tcl \ 120 126 $(srcdir)/visviewer.tcl \ 121 127 $(srcdir)/vtkviewer.tcl \ -
trunk/gui/scripts/videodial.tcl
r1979 r2023 682 682 foreach {x0 y0 x1 y1} [$c bbox $item] break 683 683 if {! [info exists y1]} continue 684 684 puts stderr "$item : [expr $y1-$y0]: $y0 $y1" 685 685 lappend q $y0 $y1 686 686 } -
trunk/gui/scripts/videoscreen.tcl
r1979 r2023 17 17 18 18 option add *Video.width 300 widgetDefault 19 option add *Video*cursor crosshair widgetDefault20 19 option add *Video.height 300 widgetDefault 21 20 option add *Video.foreground black widgetDefault 22 21 option add *Video.controlBackground gray widgetDefault 23 option add *Video.controlDarkBackground #999999 widgetDefault24 option add *Video.plotBackground black widgetDefault25 option add *Video.plotForeground white widgetDefault26 option add *Video.plotOutline gray widgetDefault27 22 option add *Video.font \ 28 23 -*-helvetica-medium-r-normal-*-12-* widgetDefault … … 31 26 inherit itk::Widget 32 27 33 itk_option define -plotforeground plotForeground Foreground ""34 itk_option define -plotbackground plotBackground Background ""35 itk_option define -plotoutline plotOutline PlotOutline ""36 28 itk_option define -width width Width -1 37 29 itk_option define -height height Height -1 30 itk_option define -fileopen fileopen Fileopen "" 38 31 39 32 constructor { args } { … … 109 102 110 103 array set _settings [subst { 111 $this-currenttime 0112 104 $this-framenum 0 113 105 $this-loop 0 … … 122 114 123 115 124 125 116 # Create flow controls... 126 117 … … 132 123 rename -background -controlbackground controlBackground Background 133 124 } 134 135 # pack $itk_component(main) -side top -expand yes -fill both136 125 bind $itk_component(main) <Configure> [itcl::code $this fixSize] 126 127 # hold the video frames in an image on the canvas 128 set _imh [image create photo] 129 $itk_component(main) create image 0 0 -anchor nw -image $_imh 137 130 138 131 # setup movie controls … … 154 147 set imagesDir [file join $RapptureGUI::library scripts images] 155 148 149 # ==== fileopen ==== 150 itk_component add fileopen { 151 button $itk_component(moviecontrols).fileopen \ 152 -borderwidth 1 -padx 1 -pady 1 \ 153 -image [Rappture::icon upload] \ 154 -command [itcl::code $this loadcb] 155 #-command [Rappture::filexfer::upload {piv tool} {id label desc} [itcl::code $this Upload]] 156 #-command [itcl::code $this video seek 0] 157 } { 158 usual 159 ignore -borderwidth 160 rename -highlightbackground -controlbackground controlBackground \ 161 Background 162 } 163 Rappture::Tooltip::for $itk_component(fileopen) \ 164 "Open file" 156 165 157 166 # ==== measuring tool ==== … … 254 263 "Play continuously between marked sections" 255 264 256 # Video Dial257 265 itk_component add dial { 258 Rappture::Videodial $itk_component(moviecontrols).dial \ 266 frame $itk_interior.dial 267 } { 268 usual 269 rename -background -controlbackground controlBackground Background 270 } 271 272 # Video Dial Major 273 itk_component add dialmajor { 274 Rappture::Videodial1 $itk_component(dial).dialmajor \ 259 275 -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \ 260 276 -linecolor "" -activelinecolor "" \ 261 277 -min 0 -max 1 \ 262 -minortick 1 -majortick 5 \ 263 -variable [itcl::scope _settings($this-currenttime)] \ 278 -variable [itcl::scope _settings($this-framenum)] \ 264 279 -dialoutlinecolor black \ 265 280 -knobimage [Rappture::icon knob2] -knobposition center@middle … … 269 284 rename -background -controlbackground controlBackground Background 270 285 } 271 $itk_component(dial) current 0 272 bind $itk_component(dial) <<Value>> [itcl::code $this video update] 286 $itk_component(dialmajor) current 0 287 bind $itk_component(dialmajor) <<Value>> [itcl::code $this video update] 288 289 # Video Dial Minor 290 itk_component add dialminor { 291 Rappture::Videodial2 $itk_component(dial).dialminor \ 292 -padding 0 \ 293 -min 0 -max 1 \ 294 -minortick 1 -majortick 5 \ 295 -variable [itcl::scope _settings($this-framenum)] \ 296 -dialoutlinecolor black 297 } { 298 usual 299 rename -background -controlbackground controlBackground Background 300 } 301 $itk_component(dialminor) current 0 302 bind $itk_component(dialminor) <<Value>> [itcl::code $this video update] 273 303 274 304 itk_component add framenumlabel { … … 282 312 283 313 # Current Frame Number 284 #set ffont "arial 9"285 #set fwidth [calcLabelWidth $ffont]286 314 itk_component add framenum { 287 315 label $itk_component(frnumfr).framenum \ … … 293 321 rename -background -controlbackground controlBackground Background 294 322 } 295 #$itk_component(framenum) value 1296 #bind $itk_component(framenum) <<Value>> \297 # [itcl::code $this video seek -framenum]298 323 Rappture::Tooltip::for $itk_component(framenum) \ 299 324 "Current frame number" … … 315 340 # Speed 316 341 itk_component add speed { 317 Rappture:: Flowspeed $itk_component(moviecontrols).speed \318 -min 1 -max 10 -width 3 -font "arial 9"342 Rappture::Videospeed $itk_component(moviecontrols).speed \ 343 -min 0 -max 1 -width 4 -font "arial 9" -factor 2 319 344 } { 320 345 usual … … 325 350 "Change speed of movie" 326 351 327 $itk_component(speed) value 1352 $itk_component(speed) value 0.25 328 353 bind $itk_component(speed) <<Value>> [itcl::code $this video speed] 329 354 330 355 356 blt::table $itk_component(dial) \ 357 0,0 $itk_component(dialmajor) -fill x \ 358 1,0 $itk_component(dialminor) -fill x 359 360 331 361 blt::table $itk_component(moviecontrols) \ 332 0,0 $itk_component(measure) -padx {2 0} \ 333 0,1 $itk_component(particle) -padx {4 0} \ 362 0,0 $itk_component(fileopen) -padx {2 0} \ 363 0,1 $itk_component(measure) -padx {4 0} \ 364 0,2 $itk_component(particle) -padx {4 0} \ 334 365 0,5 $itk_component(dial) -fill x -padx {2 4} -rowspan 3 \ 335 366 1,0 $itk_component(rewind) -padx {2 0} \ … … 361 392 itcl::body Rappture::VideoScreen::destructor {} { 362 393 array unset _settings $this-* 394 if {[info exists _imh]} { 395 image delete $_imh 396 } 363 397 } 364 398 … … 394 428 } 395 429 430 if {([info exists _movie]) && ("" != ${_movie})} { 431 ${_movie} release 432 } 433 396 434 set _movie [Rappture::Video $type $data] 397 435 file delete $fname 398 436 set _framerate [${_movie} get framerate] 399 set _mspf [expr round(((1.0/${_framerate})*1000)/pow(2,$_settings($this-speed)-1))] 400 set _delay [expr {${_mspf} - ${_ofrd}}] 401 puts stderr "framerate = ${_framerate}" 402 puts stderr "mspf = ${_mspf}" 403 puts stderr "ofrd = ${_ofrd}" 404 puts stderr "delay = ${_delay}" 405 406 ${_movie} seek 0 437 video speed 438 439 video seek 0 440 441 # update the dial and framenum widgets 442 set _settings($this-framenum) 0 443 407 444 408 445 # setup the image display 409 446 410 set _imh [image create photo]411 447 foreach {w h} [query dimensions] break 412 448 if {${_width} == -1} { … … 416 452 set _height $h 417 453 } 418 $itk_component(main) create image 0 0 -anchor nw -image $_imh419 454 420 455 set _lastFrame [$_movie get position end] 421 456 422 457 # update the dial with video information 423 $itk_component(dial) configure -min 0 -max ${_lastFrame} 458 $itk_component(dialmajor) configure -min 0 -max ${_lastFrame} 459 $itk_component(dialminor) configure -min 0 -max ${_lastFrame} 424 460 425 461 fixSize … … 466 502 } 467 503 468 set _width [winfo width $itk_component(main)] 469 set _height [winfo height $itk_component(main)] 504 # set _width [winfo width $itk_component(main)] 505 # set _height [winfo height $itk_component(main)] 506 # 507 # # get an image with the new size 508 # ${_imh} put [${_movie} get image ${_width} ${_height}] 509 # 510 # # fix the dimesions of the canvas 511 # #$itk_component(main) configure -width ${_width} -height ${_height} 512 # 513 # $itk_component(main) configure -scrollregion [$itk_component(main) bbox all] 514 515 ###################### 470 516 471 517 # get an image with the new size 472 518 ${_imh} put [${_movie} get image ${_width} ${_height}] 473 474 # fix the dimesions of the canvas 475 #$itk_component(main) configure -width ${_width} -height ${_height} 476 477 $itk_component(main) configure -scrollregion [$itk_component(main) bbox all] 519 puts stderr "${_width} ${_height}" 520 521 # fix the dimesions of the video canvas 522 $itk_component(main) configure -width ${_width} -height ${_height} 478 523 } 479 524 … … 486 531 "play" { 487 532 if {$_settings($this-play) == 1} { 488 # disable seek while playing489 # bind $itk_component(dial) <<Value>> ""490 533 eventually play 491 534 } else { … … 494 537 set _pendings(play) 0 495 538 set _settings($this-play) 0 496 # enable seek while paused497 # bind $itk_component(dial) <<Value>> [itcl::code $this updateFrame]498 539 } 499 540 } … … 507 548 "speed" { 508 549 set speed [$itk_component(speed) value] 509 set _mspf [expr round(((1.0/${_framerate})*1000)/ pow(2,$speed-1))]550 set _mspf [expr round(((1.0/${_framerate})*1000)/$speed)] 510 551 set _delay [expr {${_mspf} - ${_ofrd}}] 511 552 puts stderr "_mspf = ${_mspf} | $speed | ${_ofrd} | ${_delay}" 512 553 } 513 554 "update" { 514 #video stop 515 # eventually seek [expr round($_settings($this-currenttime))] 516 Seek [expr round($_settings($this-currenttime))] 517 # Seek $_settings($this-framenum) 518 #after idle [itcl::code $this video play] 555 # eventually seek [expr round($_settings($this-framenum))] 556 Seek [expr round($_settings($this-framenum))] 519 557 } 520 558 default { … … 555 593 itcl::body Rappture::VideoScreen::Play {} { 556 594 595 set cur ${_nextframe} 596 557 597 # time how long it takes to retrieve the next frame 558 598 set _ofrd [time { 559 $_movie seek $_nextframe 599 # use seek instead of next fxn incase the ${_nextframe} is 600 # not the current frame+1. this happens when we skip frames 601 # because the underlying c lib is too slow at reading. 602 $_movie seek $cur 560 603 $_imh put [$_movie get image ${_width} ${_height}] 561 604 } 1] … … 574 617 575 618 # update the dial and framenum widgets 576 set _settings($this-currenttime) $cur577 619 set _settings($this-framenum) $cur 578 620 579 if {[expr $cur%100] == 0} {580 # puts stderr "ofrd = ${_ofrd}"581 # puts stderr "delay = ${_delay}"582 # puts stderr "after: [after info]"583 # puts stderr "id = ${_id}"584 }585 621 586 622 # no play cmds pending … … 590 626 # then loop back to loopstart when cur hits loopend 591 627 if {$_settings($this-loop)} { 592 if {$cur == [$itk_component(dial ) mark position loopend]} {593 Seek [$itk_component(dial ) mark position loopstart]628 if {$cur == [$itk_component(dialminor) mark position loopend]} { 629 Seek [$itk_component(dialminor) mark position loopstart] 594 630 } 595 631 } … … 598 634 if {$cur < ${_lastFrame}} { 599 635 set _id [after ${_delay} [itcl::code $this eventually play]] 600 } 601 602 # event generate $itk_component(hull) <<Frame>> 636 } else { 637 video stop 638 } 639 640 event generate $itk_component(hull) <<Frame>> 603 641 } 604 642 … … 624 662 625 663 # update the dial and framenum widgets 664 set _settings($this-framenum) [$_movie get position cur] 626 665 event generate $itk_component(main) <<Frame>> 627 set cur [$_movie get position cur]628 set _settings($this-currenttime) $cur629 set _settings($this-framenum) $cur630 666 631 667 } … … 836 872 ${_obj} Coords $x $y $x $y 837 873 ${_obj} Show object 838 $itk_component(dial ) mark add arrow current874 $itk_component(dialminor) mark add arrow current 839 875 } 840 876 "drag" { … … 898 934 ${_obj} Coords $x $y 899 935 ${_obj} Show object 900 $itk_component(dial ) mark add $name current936 $itk_component(dialminor) mark add $name current 901 937 # bind $itk_component(hull) <<Frame>> [itcl::code $itk_component(main).$name UpdateFrame] 902 938 … … 993 1029 # ---------------------------------------------------------------------- 994 1030 itcl::body Rappture::VideoScreen::writeText {x y text color tags width} { 995 # write text up-left 996 $itk_component(main) create text [expr $x-1] [expr $y-1] \ 1031 $itk_component(main) create text [expr $x-1] [expr $y] \ 997 1032 -tags $tags \ 998 1033 -justify center \ … … 1001 1036 -width $width 1002 1037 1003 # write text down-right 1004 $itk_component(main) create text [expr $x+1] [expr $y+1] \ 1038 $itk_component(main) create text [expr $x+1] [expr $y] \ 1005 1039 -tags $tags \ 1006 1040 -justify center \ … … 1008 1042 -fill black \ 1009 1043 -width $width 1044 1045 $itk_component(main) create text [expr $x] [expr $y-1] \ 1046 -tags $tags \ 1047 -justify center \ 1048 -text $text \ 1049 -fill black \ 1050 -width $width 1051 1052 $itk_component(main) create text [expr $x] [expr $y+1] \ 1053 -tags $tags \ 1054 -justify center \ 1055 -text $text \ 1056 -fill black \ 1057 -width $width 1058 1059 # # write text up-left 1060 # $itk_component(main) create text [expr $x-1] [expr $y-1] \ 1061 # -tags $tags \ 1062 # -justify center \ 1063 # -text $text \ 1064 # -fill black \ 1065 # -width $width 1066 # 1067 # # write text down-right 1068 # $itk_component(main) create text [expr $x+1] [expr $y+1] \ 1069 # -tags $tags \ 1070 # -justify center \ 1071 # -text $text \ 1072 # -fill black \ 1073 # -width $width 1010 1074 1011 1075 # write text at x,y … … 1031 1095 1032 1096 if {($frames != 0) && (${_px2dist} != 0)} { 1033 set t [expr 1.0*$px/$frames /${_px2dist}*${_framerate}]1097 set t [expr 1.0*$px/$frames*${_px2dist}*${_framerate}] 1034 1098 } else { 1035 1099 set t 0.0 … … 1044 1108 itcl::body Rappture::VideoScreen::toggleloop {} { 1045 1109 if {$_settings($this-loop) == 0} { 1046 $itk_component(dial ) mark remove loopstart1047 $itk_component(dial ) mark remove loopend1110 $itk_component(dialminor) mark remove loopstart 1111 $itk_component(dialminor) mark remove loopend 1048 1112 } else { 1049 1113 set cur [$_movie get position cur] … … 1060 1124 } 1061 1125 1062 $itk_component(dial ) mark add loopstart $startframe1063 $itk_component(dial ) mark add loopend $endframe1126 $itk_component(dialminor) mark add loopstart $startframe 1127 $itk_component(dialminor) mark add loopend $endframe 1064 1128 } 1065 1129 … … 1074 1138 error "bad value: \"$itk_option(-width)\": width should be an integer" 1075 1139 } 1076 set ${_width}$itk_option(-width)1140 set _width $itk_option(-width) 1077 1141 after idle [itcl::code $this fixSize] 1078 1142 } … … 1086 1150 error "bad value: \"$itk_option(-height)\": height should be an integer" 1087 1151 } 1088 set ${_height}$itk_option(-height)1152 set _height $itk_option(-height) 1089 1153 after idle [itcl::code $this fixSize] 1090 1154 } 1155 1156 # ---------------------------------------------------------------------- 1157 # OPTION: -fileopen 1158 # ---------------------------------------------------------------------- 1159 itcl::configbody Rappture::VideoScreen::fileopen { 1160 $itk_component(fileopen) configure -command $itk_option(-fileopen) 1161 } -
trunk/lang/tcl/src/RpVideoTclInterface.cc
r1925 r2023 30 30 31 31 static Rp_OpSpec rpVideoOps[] = { 32 {"get", 1, (void *)GetOp, 3, 5, "[image ?width height?]|[position cur|end]|[framerate]",},32 {"get", 1, (void *)GetOp, 3, 5, "[image ?width height?]|[position cur|end]|[framerate]",}, 33 33 {"next", 1, (void *)NextOp, 2, 2, "",}, 34 {"release", 1, (void *)ReleaseOp, 2, 2, "",}, 34 35 {"seek", 1, (void *)SeekOp, 3, 3, "+n|-n|n",}, 35 36 {"size", 1, (void *)SizeOp, 2, 2, "",}, 36 {"release", 1, (void *)ReleaseOp, 2, 2, "",},37 37 }; 38 38 … … 243 243 Tcl_Obj *const *objv) 244 244 { 245 246 // void *img = NULL;247 // int width = 960;248 // int height = 540;249 // int bufSize = 0;250 251 245 int pos = 0; 252 246 VideoGoNext((VideoObj *)clientData); 253 247 VideoGetPositionCur((VideoObj *)clientData,&pos); 254 248 Tcl_SetObjResult(interp, Tcl_NewIntObj(pos)); 255 // VideoGetImage((VideoObj *)clientData, width, height, &img, &bufSize);256 257 // Tcl_SetByteArrayObj(Tcl_GetObjResult(interp),258 // (const unsigned char*)img, bufSize);259 249 260 250 return TCL_OK; … … 277 267 Tcl_Obj *const *objv) 278 268 { 279 280 // void *img = NULL;281 // int width = 960;282 // int height = 540;283 // int bufSize = 0;284 269 const char *val_s = NULL; 285 270 int val = 0; … … 311 296 int c = 0; 312 297 c = VideoGoToN((VideoObj *)clientData, val); 313 // printf("c = %d\tval = %d\n",c,val); 314 } 315 316 // VideoGetImage((VideoObj *)clientData, width, height, &img, &bufSize); 317 318 // if (img == NULL) { 319 // printf("img is null\n"); 320 // } 321 322 // Tcl_SetByteArrayObj(Tcl_GetObjResult(interp), 323 // (const unsigned char*)img, bufSize); 298 } 324 299 325 300 VideoGetPositionCur((VideoObj *)clientData,&pos); -
trunk/src/objects/RpVideo.c
r1983 r2023 83 83 char mode[64]; 84 84 char fmt[64]; 85 int lastframe; 85 86 86 87 /* tmp buffer to give images back to user */ … … 154 155 *vid->mode = '\0'; 155 156 *vid->fmt = '\0'; 157 vid->lastframe = 0; 156 158 157 159 vid->img = NULL; … … 171 173 int fnlen = 0; 172 174 int err = 0; 175 int lastframe = 0; 173 176 174 177 if (fileName == NULL) { … … 206 209 return err; 207 210 } 211 212 VideoFindLastFrame(vidPtr,&lastframe); 213 vidPtr->lastframe = lastframe; 208 214 } else if (*mode == 'w') { 209 215 /* we're now in "input" mode */ … … 216 222 return 0; 217 223 } 224 225 /* 226 * ------------------------------------------------------------------------ 227 * VideoFindLastFrame() 228 * 229 * Find the last readable frame. 230 * ------------------------------------------------------------------------ 231 */ 232 int 233 VideoFindLastFrame(vidPtr,lastframe) 234 VideoObj *vidPtr; 235 int *lastframe; 236 { 237 int f = 0; 238 int nframe = 0; 239 int cur = 0; 240 AVStream *vstreamPtr; 241 242 if (vidPtr == NULL) { 243 return -1; 244 } 245 246 if (lastframe == NULL) { 247 return -1; 248 } 249 250 if (VideoModeRead(vidPtr) != 0) { 251 return -1; 252 } 253 254 // calculate an estimate of the last frame 255 vstreamPtr = vidPtr->pFormatCtx->streams[vidPtr->videoStream]; 256 nframe = VideoTime2Frame(vstreamPtr, 257 vstreamPtr->start_time + vstreamPtr->duration); 258 259 // get the real last readable frame 260 // is 50 frames far enough to go back 261 // to be outside of the last key frame? 262 f = vidPtr->frameNumber; 263 cur = VideoGoToN(vidPtr,nframe-50); 264 while (cur != nframe) { 265 cur = nframe; 266 nframe = VideoGoNext(vidPtr); 267 } 268 *lastframe = nframe; 269 VideoGoToN(vidPtr,f); 270 271 return 0; 272 } 273 218 274 219 275 /* … … 822 878 VideoObj *vidPtr; 823 879 { 824 return VideoGoPlusMinusN(vidPtr,1); 880 int nabs; 881 882 if (vidPtr == NULL) { 883 return -1; 884 } 885 886 nabs = vidPtr->frameNumber + 1; 887 return VideoGoToN(vidPtr, nabs); 825 888 } 826 889 … … 910 973 /* get at least one frame, unless we're done or at the beginning*/ 911 974 if (!gotframe && !vidPtr->atEnd) { 912 VideoNextFrame(vidPtr); 975 if (vidPtr->frameNumber > nabs) { 976 // we are probably at a key frame, just past 977 // the requested frame and need to seek backwards. 978 VideoGoToN(vidPtr,n); 979 } else { 980 VideoNextFrame(vidPtr); 981 } 913 982 } 914 983 } … … 1040 1109 free(vidPtr->img); 1041 1110 VideoAllocImgBuffer(vidPtr,iw,ih); 1042 } else {1043 // image buffer is the correct size1044 // do nothing1045 1111 } 1046 1112 } … … 1155 1221 int *pos; 1156 1222 { 1157 int nframe = -1;1158 1223 AVStream *vstreamPtr; 1159 1224 … … 1170 1235 } 1171 1236 1172 if (vidPtr->pFormatCtx) { 1173 vstreamPtr = vidPtr->pFormatCtx->streams[vidPtr->videoStream]; 1174 nframe = VideoTime2Frame(vstreamPtr, 1175 vstreamPtr->start_time + vstreamPtr->duration); 1176 } 1177 1178 *pos = nframe; 1237 *pos = vidPtr->lastframe; 1179 1238 return 0; 1180 1239 }
Note: See TracChangeset
for help on using the changeset viewer.