source: trunk/examples/video/piv/piv.tcl @ 2023

Last change on this file since 2023 was 2023, checked in by dkearney, 14 years ago

updates for video widgets
two new video dials
video chooser widget for selecting movies
video preview widget is a no frills movie player.
updated c code to more correctly report the last frame of the movie.
new video speed widget which allows for fractional values between 0x and 1.0x
updated piv/pve example application
fixed "release" function in tcl bindings for RpVideo?

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#!/bin/sh
2#\
3exec wish "$0" $*
4# ----------------------------------------------------------------------
5# wish executes everything from here on...
6
7package require RapptureGUI
8package require BLT
9package require Img
10
11
12option add *font -*-helvetica-medium-r-normal-*-12-*
13option add *background #d9d9d9
14option add *Tooltip.background white
15option add *BugReport*banner*foreground white
16option add *BugReport*banner*background #a9a9a9
17option add *BugReport*banner*highlightBackground #a9a9a9
18option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-18-*
19option add *upload*Label*font -*-helvetica-medium-r-normal-*-12-*
20option add *download*Label*font -*-helvetica-medium-r-normal-*-12-*
21
22switch $tcl_platform(platform) {
23    unix - windows {
24        event add <<PopupMenu>> <ButtonPress-3>
25    }
26    macintosh {
27        event add <<PopupMenu>> <Control-ButtonPress-1>
28    }
29}
30
31# install some Rappture support stuff...
32Rappture::bugreport::install
33Rappture::filexfer::init
34Rappture::grab::init
35
36
37wm title . "particle velocity estimate"
38wm withdraw .
39set width 960
40set height 625
41
42set installdir [file dirname [ \
43                Rappture::utils::expandPath [ \
44                file normalize [info script]]]]
45
46
47
48# ------------------------------------------------------------------
49# Main Window
50# ------------------------------------------------------------------
51
52# create a notebook to hold the different pages
53
54set nb [Rappture::Notebook .nb]
55pack .nb -expand yes -fill both
56
57# ------------------------------------------------------------------
58# About Page
59# ------------------------------------------------------------------
60
61set f [$nb insert end about]
62
63
64
65# html intro page
66
67set intro [frame $f.intro]
68
69Rappture::Scroller $intro.scroller -xscrollmode auto -yscrollmode auto
70pack $intro.scroller -expand yes -fill both
71
72Rappture::HTMLviewer $intro.scroller.html
73$intro.scroller contents $intro.scroller.html
74
75set fid [open "intro.html" r]
76set html [read $fid]
77close $fid
78$intro.scroller.html load $html
79
80
81# verticle divider
82set div [frame $f.div -width 1 -background black]
83
84
85set previewVar ""
86
87# movie chooser
88
89set chooser [frame $f.chooser_f]
90
91set fid [open [file join $installdir images step1.png] r]
92fconfigure $fid -translation binary -encoding binary
93set data [read $fid]
94close $fid
95set imh [image create photo]
96$imh put $data
97label $chooser.step1 -image $imh
98
99set 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
103pack $chooser.step1 -side top -anchor w -pady 8
104pack $vc -side bottom -anchor center
105
106
107
108# movie previewer
109
110set preview [frame $f.preview_f]
111
112set fid [open [file join $installdir images step2.png] r]
113fconfigure $fid -translation binary -encoding binary
114set data [read $fid]
115close $fid
116set imh [image create photo]
117$imh put $data
118label $preview.step2 -image $imh
119
120set vp [Rappture::VideoPreview $preview.preview -variable ::previewVar]
121
122pack $preview.step2 -side top -anchor w -pady 8
123pack $vp -side bottom -anchor center
124
125
126
127# analyze button gets us to the analyze page
128
129set analyze [frame $f.analyze_f]
130
131set fid [open [file join $installdir images step3.png] r]
132fconfigure $fid -translation binary -encoding binary
133set data [read $fid]
134close $fid
135set imh [image create photo]
136$imh put $data
137label $analyze.step3 -image $imh
138
139button $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    }
148pack $analyze.step3 -side left -anchor w
149pack $analyze.go -anchor center
150
151
152set reqwidth [expr round($width/2.0)]
153blt::table $f \
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
159
160blt::table configure $f c0 -resize none
161blt::table configure $f c1 -resize none
162blt::table configure $f c2 -resize none
163# blt::table configure $f r0 -pady 1
164
165# ------------------------------------------------------------------
166# VIDEO PAGE
167# ------------------------------------------------------------------
168
169set f [$nb insert end video]
170set vs [Rappture::VideoScreen $f.viewer -fileopen {$nb current about}]
171pack $vs -expand yes -fill both
172
173
174# ------------------------------------------------------------------
175# SHOW WINDOW
176# ------------------------------------------------------------------
177
178
179$nb current about
180wm geometry . ${width}x${height}
181wm deiconify .
182
183#update idletasks
184#image delete $imh
Note: See TracBrowser for help on using the repository browser.