Merge lp:~nico-inattendu/luciole/bug_excessive_cpu into lp:luciole/0.8
- bug_excessive_cpu
- Merge into 0.8
Proposed by
NicoInattendu
Status: | Merged |
---|---|
Approved by: | NicoInattendu |
Approved revision: | not available |
Merge reported by: | NicoInattendu |
Merged at revision: | not available |
Proposed branch: | lp:~nico-inattendu/luciole/bug_excessive_cpu |
Merge into: | lp:luciole/0.8 |
Diff against target: |
804 lines (+364/-74) 8 files modified
lucioLib/gui/dialog_project_properties.py (+166/-24) lucioLib/lcl_gst/lcl_gst_acq.py (+41/-11) lucioLib/lcl_gst/lcl_gst_base.py (+10/-6) lucioLib/lcl_gst/lcl_gst_play.py (+0/-1) lucioLib/lucioWebCamDetect/luciole_webcam_detection.py (+70/-16) lucioLib/luciole_controller.py (+11/-6) lucioLib/luciole_project.py (+64/-10) luciole.py (+2/-0) |
To merge this branch: | bzr merge lp:~nico-inattendu/luciole/bug_excessive_cpu |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
NicoInattendu | Approve | ||
Review via email: mp+18246@code.launchpad.net |
Commit message
Merge with corrections fo excessive CPU bug #500649
Description of the change
To post a comment you must log in.
Revision history for this message
NicoInattendu (nico-inattendu) wrote : | # |
Revision history for this message
NicoInattendu (nico-inattendu) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lucioLib/gui/dialog_project_properties.py' | |||
2 | --- lucioLib/gui/dialog_project_properties.py 2009-04-28 13:36:55 +0000 | |||
3 | +++ lucioLib/gui/dialog_project_properties.py 2010-01-29 07:10:30 +0000 | |||
4 | @@ -1,9 +1,9 @@ | |||
5 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
6 | 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
7 | 3 | # -*- Mode: Python -*- | 3 | # -*- Mode: Python -*- |
9 | 4 | # vi:si:ai:et:sw=4:sts=4:ts=4 | 4 | # vim:si:ai:et:sw=4:sts=4:ts=4 |
10 | 5 | # | 5 | # |
12 | 6 | # Copyright Nicolas Bertrand (nico@inattendu.org), 2009 | 6 | # Copyright Nicolas Bertrand (nico@inattendu.org), 2009, 2010 |
13 | 7 | # | 7 | # |
14 | 8 | # This file is part of Luciole. | 8 | # This file is part of Luciole. |
15 | 9 | # | 9 | # |
16 | @@ -22,16 +22,22 @@ | |||
17 | 22 | # | 22 | # |
18 | 23 | # | 23 | # |
19 | 24 | """ | 24 | """ |
21 | 25 | dialog_project_properties.py : Dialog who display the project properties | 25 | dialog_project_properties.py : Dialog who display the luciole project properties |
22 | 26 | """ | 26 | """ |
23 | 27 | #i18n | ||
24 | 27 | from gettext import gettext as _ | 28 | from gettext import gettext as _ |
25 | 29 | |||
26 | 28 | import gtk | 30 | import gtk |
27 | 29 | import pango | 31 | import pango |
28 | 30 | 32 | ||
29 | 31 | from .. import luciole_constants as LCONST | 33 | from .. import luciole_constants as LCONST |
30 | 32 | import webcam_detection_widget as LWDW | 34 | import webcam_detection_widget as LWDW |
31 | 33 | 35 | ||
33 | 34 | (LABEL,ENTRY)=range(2) | 36 | |
34 | 37 | #type of widgets for displaying webcam data | ||
35 | 38 | (LABEL,ENTRY,SCALE)=range(3) | ||
36 | 39 | |||
37 | 40 | |||
38 | 35 | 41 | ||
39 | 36 | class Project_properties(object): | 42 | class Project_properties(object): |
40 | 37 | 43 | ||
41 | @@ -83,14 +89,19 @@ | |||
42 | 83 | 'desc' : _('Video height :'), | 89 | 'desc' : _('Video height :'), |
43 | 84 | 'type' : LABEL | 90 | 'type' : LABEL |
44 | 85 | }, | 91 | }, |
45 | 92 | 'framerate_list': { | ||
46 | 93 | 'desc' : _('Webcam framerate \n (number of images per second)'), | ||
47 | 94 | 'type' : SCALE | ||
48 | 95 | }, | ||
49 | 96 | |||
50 | 97 | |||
51 | 86 | } | 98 | } |
52 | 87 | 99 | ||
53 | 88 | 100 | ||
54 | 89 | _title = _('Project properties') | 101 | _title = _('Project properties') |
55 | 90 | 102 | ||
56 | 91 | def __init__(self,main_window, project, cb_project_change) : | 103 | def __init__(self,main_window, project, cb_project_change) : |
59 | 92 | """ create a Dialog with project properties and disqpay it""" | 104 | """ create a Dialog with project properties and display it""" |
58 | 93 | |||
60 | 94 | self._dialog = gtk.Dialog ( _(self._title), | 105 | self._dialog = gtk.Dialog ( _(self._title), |
61 | 95 | main_window, | 106 | main_window, |
62 | 96 | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, | 107 | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, |
63 | @@ -101,6 +112,9 @@ | |||
64 | 101 | self._project = project | 112 | self._project = project |
65 | 102 | self._cb_project_change = cb_project_change | 113 | self._cb_project_change = cb_project_change |
66 | 103 | 114 | ||
67 | 115 | # keep framerate list and framerate selected those value can change | ||
68 | 116 | self._framerate_selected = self._project['webcam_data']['framerate_selected'] | ||
69 | 117 | self._framerate_list = self._project['webcam_data']['framerate_list'] | ||
70 | 104 | # connect destroy signal | 118 | # connect destroy signal |
71 | 105 | #self._dialog.connect("destroy", self._cb_on_exit) | 119 | #self._dialog.connect("destroy", self._cb_on_exit) |
72 | 106 | self._dialog.connect("delete-event", self._cb_on_exit) | 120 | self._dialog.connect("delete-event", self._cb_on_exit) |
73 | @@ -131,10 +145,19 @@ | |||
74 | 131 | # assumption only enry on webcam data | 145 | # assumption only enry on webcam data |
75 | 132 | webcam_dict = self._project['webcam_data'] | 146 | webcam_dict = self._project['webcam_data'] |
76 | 133 | for (key_entry, widget_entry) in self.webcam_widgets.iteritems() : | 147 | for (key_entry, widget_entry) in self.webcam_widgets.iteritems() : |
81 | 134 | if widget_entry.get_text() != webcam_dict[key_entry] : | 148 | # specific treatment when the wigdet is associated to framerate_list |
82 | 135 | # entry value changed | 149 | # store framerate_list and framerate_selected |
83 | 136 | # emit callback to inidcate project change | 150 | if key_entry == 'framerate_list' : |
84 | 137 | self._cb_project_change('webcam_data', key_entry, widget_entry.get_text()) | 151 | # callback for updated framerate |
85 | 152 | self._cb_project_change('webcam_data', 'framerate_selected',self._framerate_selected) | ||
86 | 153 | # check if framerate list has changed if yes callback for framerate list | ||
87 | 154 | if webcam_dict[key_entry] != self._framerate_list : | ||
88 | 155 | self._cb_project_change('webcam_data', 'framerate_list',self._framerate_list) | ||
89 | 156 | else : | ||
90 | 157 | if widget_entry.get_text() != webcam_dict[key_entry] : | ||
91 | 158 | # entry value changed | ||
92 | 159 | # emit callback to inidcate project change | ||
93 | 160 | self._cb_project_change('webcam_data', key_entry, widget_entry.get_text()) | ||
94 | 138 | 161 | ||
95 | 139 | def _cb_on_exit(self,widget,event) : | 162 | def _cb_on_exit(self,widget,event) : |
96 | 140 | self._dialog.destroy() | 163 | self._dialog.destroy() |
97 | @@ -196,15 +219,19 @@ | |||
98 | 196 | widget = None | 219 | widget = None |
99 | 197 | if self._WEBCAM_PREFS[key]['type'] == ENTRY : | 220 | if self._WEBCAM_PREFS[key]['type'] == ENTRY : |
100 | 198 | widget = gtk.Entry() | 221 | widget = gtk.Entry() |
103 | 199 | widget.set_alignment(xalign=0.0) # left justification of label | 222 | widget.set_alignment(xalign = 0.0) # left justification |
104 | 200 | else: | 223 | widget.set_text("%s"%self._project['webcam_data'][key]) |
105 | 224 | elif self._WEBCAM_PREFS[key]['type'] == LABEL : | ||
106 | 201 | widget = gtk.Label() | 225 | widget = gtk.Label() |
109 | 202 | widget.set_alignment(xalign=0.0,yalign=0.5) # left justification of label | 226 | widget.set_alignment(xalign = 0.0, yalign = 0.5) # left justification |
110 | 203 | 227 | widget.set_text("%s"%self._project['webcam_data'][key]) | |
111 | 228 | elif self._WEBCAM_PREFS[key]['type'] == SCALE : | ||
112 | 229 | widget = Framerate_scale(self._project['webcam_data'][key], | ||
113 | 230 | self._project['webcam_data']['framerate_selected'], | ||
114 | 231 | self._cb_framerate_selected) | ||
115 | 232 | |||
116 | 204 | self.webcam_widgets[key] = widget # save the widget | 233 | self.webcam_widgets[key] = widget # save the widget |
117 | 205 | 234 | ||
118 | 206 | widget.set_text("%s"%self._project['webcam_data'][key]) | ||
119 | 207 | |||
120 | 208 | widget.show() | 235 | widget.show() |
121 | 209 | table.attach(widget, 1, 2, row, row+1,xpadding = 10 ) | 236 | table.attach(widget, 1, 2, row, row+1,xpadding = 10 ) |
122 | 210 | 237 | ||
123 | @@ -235,7 +262,9 @@ | |||
124 | 235 | self.make_table_webcam_row(table,2,'height') | 262 | self.make_table_webcam_row(table,2,'height') |
125 | 236 | self.make_table_webcam_row(table,3,'source_input') | 263 | self.make_table_webcam_row(table,3,'source_input') |
126 | 237 | self.make_table_webcam_row(table,4,'device') | 264 | self.make_table_webcam_row(table,4,'device') |
128 | 238 | 265 | self.make_table_webcam_row(table,5,'framerate_list') | |
129 | 266 | # No lines for framerate_selected tag : handled framerate_list tag | ||
130 | 267 | |||
131 | 239 | Hbox.pack_start( child = table, | 268 | Hbox.pack_start( child = table, |
132 | 240 | expand = True, | 269 | expand = True, |
133 | 241 | fill = True, | 270 | fill = True, |
134 | @@ -294,15 +323,25 @@ | |||
135 | 294 | 323 | ||
136 | 295 | 324 | ||
137 | 296 | def _cb_webcam_detection(self,project_data) : | 325 | def _cb_webcam_detection(self,project_data) : |
139 | 297 | """ calback when webcam detection is done update webcam data """ | 326 | """ callback when webcam detection is done update webcam data """ |
140 | 298 | if project_data.has_key('webcam_data') and project_data['webcam_data'] != {} : | 327 | if project_data.has_key('webcam_data') and project_data['webcam_data'] != {} : |
141 | 299 | for (w_key, w_widget) in self.webcam_widgets.iteritems() : | 328 | for (w_key, w_widget) in self.webcam_widgets.iteritems() : |
145 | 300 | if project_data['webcam_data'].has_key(w_key) : | 329 | # Sepcific operation for framerate_list widget |
146 | 301 | w_text ="%s"%project_data['webcam_data'][w_key] | 330 | if w_key == 'framerate_list' : |
147 | 302 | w_widget.set_text(w_text) | 331 | w_widget.refresh(project_data['webcam_data']['framerate_list'], |
148 | 332 | project_data['webcam_data']['framerate_selected'] ) | ||
149 | 333 | self._framerate_list = project_data['webcam_data']['framerate_list'] | ||
150 | 334 | # for other webcam widgets : only text to update | ||
151 | 303 | else : | 335 | else : |
154 | 304 | w_widget.set_text('') | 336 | if project_data['webcam_data'].has_key(w_key) : |
155 | 305 | 337 | w_text ="%s"%project_data['webcam_data'][w_key] | |
156 | 338 | w_widget.set_text(w_text) | ||
157 | 339 | else : | ||
158 | 340 | w_widget.set_text('') | ||
159 | 341 | |||
160 | 342 | def _cb_framerate_selected(self,framerate) : | ||
161 | 343 | """ callback to update selected framerate used by Framerate_scale widget """ | ||
162 | 344 | self._framerate_selected = framerate | ||
163 | 306 | 345 | ||
164 | 307 | class Webcam_detection_dialog(gtk.MessageDialog) : | 346 | class Webcam_detection_dialog(gtk.MessageDialog) : |
165 | 308 | """ Opens Dialog for webcam Detection """ | 347 | """ Opens Dialog for webcam Detection """ |
166 | @@ -352,4 +391,107 @@ | |||
167 | 352 | return True | 391 | return True |
168 | 353 | 392 | ||
169 | 354 | 393 | ||
171 | 355 | 394 | class Framerate_scale(gtk.HScale) : | |
172 | 395 | """ | ||
173 | 396 | Widget use to display an horizontal scale : | ||
174 | 397 | represenation of webcam framerates in number of images per seconds | ||
175 | 398 | """ | ||
176 | 399 | |||
177 | 400 | def __init__(self,framerate_range,initial_range,cb_framerate_changed) : | ||
178 | 401 | """ | ||
179 | 402 | Constructor | ||
180 | 403 | params : | ||
181 | 404 | - framerate_range : The framerate range - a list of framerate tuple | ||
182 | 405 | - initial_range : The initial range to dipslay - a tuple | ||
183 | 406 | - cb_framerate_changed : the callback function to indicate framerate change | ||
184 | 407 | """ | ||
185 | 408 | |||
186 | 409 | # | ||
187 | 410 | # store params | ||
188 | 411 | # | ||
189 | 412 | self._framerate_range = framerate_range | ||
190 | 413 | self._initial_range = initial_range | ||
191 | 414 | self._cb_framerate_changed = cb_framerate_changed | ||
192 | 415 | |||
193 | 416 | |||
194 | 417 | # | ||
195 | 418 | # configure widget | ||
196 | 419 | # | ||
197 | 420 | |||
198 | 421 | # compute the initial position on Scale bar | ||
199 | 422 | initial_f_value = float(self._framerate_range.index(self._initial_range)) | ||
200 | 423 | |||
201 | 424 | # | ||
202 | 425 | # compute an adjustment in range [0 .. nb_framerate], icrement is 1 | ||
203 | 426 | # Use floats as ints actually | ||
204 | 427 | # Display framerates instead of float values | ||
205 | 428 | # | ||
206 | 429 | adj = gtk.Adjustment(value =initial_f_value, | ||
207 | 430 | lower = 0.0, | ||
208 | 431 | upper = float(len( self._framerate_range)), | ||
209 | 432 | step_incr = 1.0, | ||
210 | 433 | page_incr = 1.0) | ||
211 | 434 | |||
212 | 435 | |||
213 | 436 | super(Framerate_scale,self).__init__(adjustment = adj) | ||
214 | 437 | |||
215 | 438 | # configure signals | ||
216 | 439 | self.connect("format-value", self.on_format_value) | ||
217 | 440 | self.connect("value-changed", self.on_value_changed) | ||
218 | 441 | |||
219 | 442 | # configure widget display properties | ||
220 | 443 | self.set_update_policy(gtk.UPDATE_DISCONTINUOUS) | ||
221 | 444 | self.set_value_pos(gtk.POS_BOTTOM) | ||
222 | 445 | self.show_all() | ||
223 | 446 | |||
224 | 447 | def on_format_value(self,widget,value) : | ||
225 | 448 | """ | ||
226 | 449 | Signal 'format-value' : Used to display value in scale in image/seconds format. | ||
227 | 450 | Computed according the adjustment value, the intger round of value is the index | ||
228 | 451 | of framerate_range | ||
229 | 452 | """ | ||
230 | 453 | int_val = int(value) | ||
231 | 454 | if int_val >= len(self._framerate_range) : | ||
232 | 455 | int_val = len(self._framerate_range) -1 | ||
233 | 456 | val_to_display = self._framerate_range[int_val] | ||
234 | 457 | # compute and return the number of images per second | ||
235 | 458 | return int(val_to_display[0]/val_to_display[1]) | ||
236 | 459 | |||
237 | 460 | def on_value_changed(self,widget) : | ||
238 | 461 | """ | ||
239 | 462 | Emited when a value is changed and selected by user | ||
240 | 463 | the signal function get the float value, round it, | ||
241 | 464 | get the equivalent framerate. | ||
242 | 465 | """ | ||
243 | 466 | # TODO : how to update webcam date | ||
244 | 467 | |||
245 | 468 | # get rounded value | ||
246 | 469 | int_val = int(widget.get_value()) | ||
247 | 470 | if int_val >= len(self._framerate_range) : | ||
248 | 471 | int_val = len(self._framerate_range) -1 | ||
249 | 472 | # update project data : do callback call | ||
250 | 473 | self._cb_framerate_changed( self._framerate_range[int_val]) | ||
251 | 474 | |||
252 | 475 | |||
253 | 476 | def refresh(self, framerate_list, framerate_selected) : | ||
254 | 477 | """ | ||
255 | 478 | Update Scale bar and ajustment according new framerate range | ||
256 | 479 | """ | ||
257 | 480 | |||
258 | 481 | self._framerate_range = framerate_list | ||
259 | 482 | self._initial_range = framerate_selected | ||
260 | 483 | |||
261 | 484 | # | ||
262 | 485 | # recompute adjustment | ||
263 | 486 | # | ||
264 | 487 | initial_f_value = float(self._framerate_range.index(self._initial_range)) | ||
265 | 488 | |||
266 | 489 | adj = gtk.Adjustment(value =initial_f_value, | ||
267 | 490 | lower = 0.0, | ||
268 | 491 | upper = float(len( self._framerate_range)), | ||
269 | 492 | step_incr = 1.0, | ||
270 | 493 | page_incr = 1.0) | ||
271 | 494 | |||
272 | 495 | self.set_adjustment(adj) | ||
273 | 496 | |||
274 | 497 | |||
275 | 356 | 498 | ||
276 | === modified file 'lucioLib/lcl_gst/lcl_gst_acq.py' | |||
277 | --- lucioLib/lcl_gst/lcl_gst_acq.py 2009-12-14 06:15:44 +0000 | |||
278 | +++ lucioLib/lcl_gst/lcl_gst_acq.py 2010-01-29 07:10:30 +0000 | |||
279 | @@ -40,12 +40,28 @@ | |||
280 | 40 | 40 | ||
281 | 41 | class PhotoSaveBin(LG.Bin) : | 41 | class PhotoSaveBin(LG.Bin) : |
282 | 42 | """ Bin Pad to save in jpeg format image from stream. Stream alyays encoded but the result will be saved to file only when a capture is done """ | 42 | """ Bin Pad to save in jpeg format image from stream. Stream alyays encoded but the result will be saved to file only when a capture is done """ |
283 | 43 | |||
284 | 44 | # Do jpeg encoding with a framerate of 5 images per second used to reduce cpu | ||
285 | 45 | JPEG_CAPS_FILTER = " video/x-raw-yuv, framerate=5/1 " | ||
286 | 46 | |||
287 | 43 | def __init__(self) : | 47 | def __init__(self) : |
288 | 44 | """ Pilpeline desc : jpegenc + fakseink """ | 48 | """ Pilpeline desc : jpegenc + fakseink """ |
289 | 45 | 49 | ||
290 | 50 | super(PhotoSaveBin,self).__init__() | ||
291 | 46 | self.__gobject_init__() | 51 | self.__gobject_init__() |
292 | 47 | ImageBinElems=[] | 52 | ImageBinElems=[] |
293 | 48 | 53 | ||
294 | 54 | Myvideorate = LG.element_factory_make('videorate') # rate transformation | ||
295 | 55 | ImageBinElems.append(Myvideorate) | ||
296 | 56 | |||
297 | 57 | MyJpegFilter = LG.element_factory_make("capsfilter", "JpegFilter") | ||
298 | 58 | # create caps string according, width, height and framerate | ||
299 | 59 | caps = LG.Caps(self.JPEG_CAPS_FILTER) | ||
300 | 60 | |||
301 | 61 | self.logger.info(" Webcam cap : %s"%caps.to_string()) | ||
302 | 62 | MyJpegFilter.set_property("caps", caps) | ||
303 | 63 | ImageBinElems.append(MyJpegFilter) | ||
304 | 64 | |||
305 | 49 | MyJpegenc = LG.element_factory_make("jpegenc","MyJpegenc") # jpeg encoding | 65 | MyJpegenc = LG.element_factory_make("jpegenc","MyJpegenc") # jpeg encoding |
306 | 50 | ImageBinElems.append(MyJpegenc) | 66 | ImageBinElems.append(MyJpegenc) |
307 | 51 | 67 | ||
308 | @@ -54,9 +70,9 @@ | |||
309 | 54 | 70 | ||
310 | 55 | for elem in ImageBinElems : self.add(elem) | 71 | for elem in ImageBinElems : self.add(elem) |
311 | 56 | 72 | ||
313 | 57 | LG.element_link_many(MyJpegenc,photosink) | 73 | LG.element_link_many(Myvideorate,MyJpegFilter,MyJpegenc,photosink) |
314 | 58 | 74 | ||
316 | 59 | self.add_pad(LG.GhostPad('sink', MyJpegenc.get_pad('sink'))) | 75 | self.add_pad(LG.GhostPad('sink', Myvideorate.get_pad('sink'))) |
317 | 60 | 76 | ||
318 | 61 | 77 | ||
319 | 62 | class InputImageBin(LG.Bin): | 78 | class InputImageBin(LG.Bin): |
320 | @@ -79,7 +95,7 @@ | |||
321 | 79 | self.MyAlpha.set_property("alpha",self.__alphaValueImage) | 95 | self.MyAlpha.set_property("alpha",self.__alphaValueImage) |
322 | 80 | alphaValueImage = property(get_alphaValueImage, set_alphaValueImage, None, " Framerate for displaying input image ") | 96 | alphaValueImage = property(get_alphaValueImage, set_alphaValueImage, None, " Framerate for displaying input image ") |
323 | 81 | 97 | ||
325 | 82 | def __init__(self,image,alphaValue,framerate=25) : | 98 | def __init__(self,image,alphaValue,framerate=1) : |
326 | 83 | self.__gobject_init__() | 99 | self.__gobject_init__() |
327 | 84 | self.__image2Mix = image | 100 | self.__image2Mix = image |
328 | 85 | self.__framerate = framerate | 101 | self.__framerate = framerate |
329 | @@ -90,11 +106,12 @@ | |||
330 | 90 | self.InputImage= LG.element_factory_make('multifilesrc') | 106 | self.InputImage= LG.element_factory_make('multifilesrc') |
331 | 91 | self.InputImage.set_property('location',self.__image2Mix) | 107 | self.InputImage.set_property('location',self.__image2Mix) |
332 | 92 | ImageBinElems.append(self.InputImage) | 108 | ImageBinElems.append(self.InputImage) |
334 | 93 | 109 | ||
335 | 110 | |||
336 | 94 | # filter to set frame rate | 111 | # filter to set frame rate |
337 | 95 | self.ImageFilter = LG.element_factory_make("capsfilter") | 112 | self.ImageFilter = LG.element_factory_make("capsfilter") |
338 | 96 | self._filter_caps_string = "image/jpeg, framerate=(fraction)%s/1 ,width=%s,height=%s " | 113 | self._filter_caps_string = "image/jpeg, framerate=(fraction)%s/1 ,width=%s,height=%s " |
340 | 97 | 114 | ||
341 | 98 | caps_string = self._filter_caps_string%(self.__framerate,MCONST.VIDEO_PAL_RES[0],MCONST.VIDEO_PAL_RES[1]) | 115 | caps_string = self._filter_caps_string%(self.__framerate,MCONST.VIDEO_PAL_RES[0],MCONST.VIDEO_PAL_RES[1]) |
342 | 99 | caps = LG.Caps(caps_string) | 116 | caps = LG.Caps(caps_string) |
343 | 100 | self.ImageFilter.set_property("caps", caps) | 117 | self.ImageFilter.set_property("caps", caps) |
344 | @@ -282,16 +299,22 @@ | |||
345 | 282 | 299 | ||
346 | 283 | class WebcamInputBin(LG.Bin) : | 300 | class WebcamInputBin(LG.Bin) : |
347 | 284 | """ LG.Bin for Web cam input""" | 301 | """ LG.Bin for Web cam input""" |
350 | 285 | def __init__(self,width=640,height=480,source_input='v4l2src',device='/dev/video0') : | 302 | def __init__(self,width=640, height=480, framerate=(2,25), source_input='v4l2src', device='/dev/video0') : |
351 | 286 | """build Dv cam input bin | 303 | """build web cam input bin |
352 | 287 | Description of pipeline : | 304 | Description of pipeline : |
353 | 288 | __________________________________________________________ | 305 | __________________________________________________________ |
354 | 289 | | | | 306 | | | |
355 | 290 | -->-- | v4lsrc --> capsfilter --> ffmpegcolorspace --> ScaleBin | ghostPad -->-- | 307 | -->-- | v4lsrc --> capsfilter --> ffmpegcolorspace --> ScaleBin | ghostPad -->-- |
356 | 291 | |__________________________________________________________|_ | 308 | |__________________________________________________________|_ |
358 | 292 | 309 | params : | |
359 | 310 | width : The webcam width. Integer value | ||
360 | 311 | height : The webcam width. Integer value | ||
361 | 312 | framerate : The webcam framerate. A tuple for fraction representation (denom,num) | ||
362 | 313 | source_input : The type of driver input. A string | ||
363 | 314 | device : Path to webcam device. A string | ||
364 | 315 | |||
365 | 293 | """ | 316 | """ |
367 | 294 | 317 | super(WebcamInputBin,self).__init__() | |
368 | 295 | self.__gobject_init__() | 318 | self.__gobject_init__() |
369 | 296 | ImageBinElems=[] | 319 | ImageBinElems=[] |
370 | 297 | 320 | ||
371 | @@ -300,8 +323,9 @@ | |||
372 | 300 | ImageBinElems.append(MyVideoSrc) | 323 | ImageBinElems.append(MyVideoSrc) |
373 | 301 | 324 | ||
374 | 302 | MyVideoSrcFilter = LG.element_factory_make("capsfilter", "MyVideoSrc") | 325 | MyVideoSrcFilter = LG.element_factory_make("capsfilter", "MyVideoSrc") |
377 | 303 | 326 | # create caps string according, width, height and framerate | |
378 | 304 | caps = LG.Caps("video/x-raw-yuv, width=%s,height=%s"%(width,height) ) | 327 | caps = LG.Caps("video/x-raw-yuv, width=%s,height=%s , framerate=%s/%s "%(width,height,framerate[0],framerate[1]) ) |
379 | 328 | self.logger.info(" Webcam cap : %s"%caps.to_string()) | ||
380 | 305 | MyVideoSrcFilter.set_property("caps", caps) | 329 | MyVideoSrcFilter.set_property("caps", caps) |
381 | 306 | ImageBinElems.append(MyVideoSrcFilter) | 330 | ImageBinElems.append(MyVideoSrcFilter) |
382 | 307 | 331 | ||
383 | @@ -492,6 +516,8 @@ | |||
384 | 492 | self.__webcam_data['height'] = 480 | 516 | self.__webcam_data['height'] = 480 |
385 | 493 | self.__webcam_data['device'] = "/dev/video0" | 517 | self.__webcam_data['device'] = "/dev/video0" |
386 | 494 | self.__webcam_data['source_input'] = "v4l2src" | 518 | self.__webcam_data['source_input'] = "v4l2src" |
387 | 519 | self.__webcam_data['framerate_list'] = [ (25,2) ] | ||
388 | 520 | self.__webcam_data['framerate_selected'] = (25,2) | ||
389 | 495 | 521 | ||
390 | 496 | def reset_pipe(self): | 522 | def reset_pipe(self): |
391 | 497 | """ Gstreamer pipe configuration : | 523 | """ Gstreamer pipe configuration : |
392 | @@ -500,10 +526,14 @@ | |||
393 | 500 | """ | 526 | """ |
394 | 501 | ElementList = [] | 527 | ElementList = [] |
395 | 502 | self.pipe = LG.Pipeline(self.pipe_name) | 528 | self.pipe = LG.Pipeline(self.pipe_name) |
396 | 529 | print self.__webcam_data | ||
397 | 530 | print " type framerate list :" , type(self.__webcam_data['framerate_list']) | ||
398 | 531 | |||
399 | 503 | if (self.__inputType == MCONST.WEBCAM) : | 532 | if (self.__inputType == MCONST.WEBCAM) : |
400 | 504 | InputBin = WebcamInputBin( | 533 | InputBin = WebcamInputBin( |
401 | 505 | width = self.__webcam_data['width'], | 534 | width = self.__webcam_data['width'], |
402 | 506 | height = self.__webcam_data['height'], | 535 | height = self.__webcam_data['height'], |
403 | 536 | framerate = self.__webcam_data['framerate_selected'], | ||
404 | 507 | source_input = self.__webcam_data['source_input'], | 537 | source_input = self.__webcam_data['source_input'], |
405 | 508 | device = self.__webcam_data['device'] | 538 | device = self.__webcam_data['device'] |
406 | 509 | ) | 539 | ) |
407 | 510 | 540 | ||
408 | === modified file 'lucioLib/lcl_gst/lcl_gst_base.py' | |||
409 | --- lucioLib/lcl_gst/lcl_gst_base.py 2009-12-14 06:15:44 +0000 | |||
410 | +++ lucioLib/lcl_gst/lcl_gst_base.py 2010-01-29 07:10:30 +0000 | |||
411 | @@ -60,11 +60,19 @@ | |||
412 | 60 | # | 60 | # |
413 | 61 | 61 | ||
414 | 62 | class Pipeline(gst.Pipeline) : | 62 | class Pipeline(gst.Pipeline) : |
416 | 63 | """ Interaface class for pipeline """ | 63 | """ Interface class for gst pipeline """ |
417 | 64 | 64 | ||
418 | 65 | def __init__(self, *args,**kwargs) : | 65 | def __init__(self, *args,**kwargs) : |
419 | 66 | super(Pipeline, self).__init__(*args,**kwargs) | 66 | super(Pipeline, self).__init__(*args,**kwargs) |
420 | 67 | 67 | ||
421 | 68 | class Bin(gst.Bin) : | ||
422 | 69 | """ Interface class for gst Bin """ | ||
423 | 70 | |||
424 | 71 | def __init__(self, *args,**kwargs) : | ||
425 | 72 | super(Bin, self).__init__(*args,**kwargs) | ||
426 | 73 | self.logger = logging.getLogger('luciole') | ||
427 | 74 | |||
428 | 75 | |||
429 | 68 | class VideoWidget(object): | 76 | class VideoWidget(object): |
430 | 69 | """ class usage to be understood """ | 77 | """ class usage to be understood """ |
431 | 70 | def __init__(self,DrawingArea): | 78 | def __init__(self,DrawingArea): |
432 | @@ -91,11 +99,7 @@ | |||
433 | 91 | 99 | ||
434 | 92 | def __init__(self,video_widget = None, pipe_name=None, cb_on_error = None, cb_on_eos = None ): | 100 | def __init__(self,video_widget = None, pipe_name=None, cb_on_error = None, cb_on_eos = None ): |
435 | 93 | # init logger | 101 | # init logger |
436 | 94 | |||
437 | 95 | self.logger = logging.getLogger('luciole') | 102 | self.logger = logging.getLogger('luciole') |
438 | 96 | if self.logger.level == logging.DEBUG : | ||
439 | 97 | gst.debug_set_active(True) | ||
440 | 98 | gst.debug_set_default_threshold(gst.LEVEL_DEBUG) | ||
441 | 99 | 103 | ||
442 | 100 | # | 104 | # |
443 | 101 | # link display window widget with gstreamer | 105 | # link display window widget with gstreamer |
444 | @@ -109,7 +113,7 @@ | |||
445 | 109 | self._cb_on_eos = cb_on_eos | 113 | self._cb_on_eos = cb_on_eos |
446 | 110 | 114 | ||
447 | 111 | self.pipe = Pipeline(pipe_name) | 115 | self.pipe = Pipeline(pipe_name) |
449 | 112 | print self.pipe | 116 | self.logger.info(self.pipe) |
450 | 113 | 117 | ||
451 | 114 | def connect_bus(self) : | 118 | def connect_bus(self) : |
452 | 115 | """ Connect to bus """ | 119 | """ Connect to bus """ |
453 | 116 | 120 | ||
454 | === modified file 'lucioLib/lcl_gst/lcl_gst_play.py' | |||
455 | --- lucioLib/lcl_gst/lcl_gst_play.py 2009-12-14 06:15:44 +0000 | |||
456 | +++ lucioLib/lcl_gst/lcl_gst_play.py 2010-01-29 07:10:30 +0000 | |||
457 | @@ -83,7 +83,6 @@ | |||
458 | 83 | # filter | 83 | # filter |
459 | 84 | self.ImageFilter = LG.element_factory_make("capsfilter") | 84 | self.ImageFilter = LG.element_factory_make("capsfilter") |
460 | 85 | caps_string = self._filter_caps_string % self._framerate | 85 | caps_string = self._filter_caps_string % self._framerate |
461 | 86 | print caps_string | ||
462 | 87 | caps = LG.gst.Caps(caps_string) | 86 | caps = LG.gst.Caps(caps_string) |
463 | 88 | self.ImageFilter.set_property("caps", caps) | 87 | self.ImageFilter.set_property("caps", caps) |
464 | 89 | ElementList.append(self.ImageFilter) | 88 | ElementList.append(self.ImageFilter) |
465 | 90 | 89 | ||
466 | === modified file 'lucioLib/lucioWebCamDetect/luciole_webcam_detection.py' | |||
467 | --- lucioLib/lucioWebCamDetect/luciole_webcam_detection.py 2009-05-09 16:11:31 +0000 | |||
468 | +++ lucioLib/lucioWebCamDetect/luciole_webcam_detection.py 2010-01-29 07:10:30 +0000 | |||
469 | @@ -35,6 +35,12 @@ | |||
470 | 35 | 35 | ||
471 | 36 | import gobject | 36 | import gobject |
472 | 37 | 37 | ||
473 | 38 | import logging | ||
474 | 39 | module_logger = logging.getLogger('luciole') | ||
475 | 40 | |||
476 | 41 | |||
477 | 42 | from .. import luciole_exceptions as LEXCEP | ||
478 | 43 | |||
479 | 38 | 44 | ||
480 | 39 | # Availables video sources for gstreamer | 45 | # Availables video sources for gstreamer |
481 | 40 | GSTREAMER_VIDEO_SOURCES = [ | 46 | GSTREAMER_VIDEO_SOURCES = [ |
482 | @@ -51,6 +57,9 @@ | |||
483 | 51 | 57 | ||
484 | 52 | def __init__(self) : | 58 | def __init__(self) : |
485 | 53 | """ class init""" | 59 | """ class init""" |
486 | 60 | # init logger | ||
487 | 61 | self.logger = logging.getLogger('luciole') | ||
488 | 62 | |||
489 | 54 | self._webcam_devices = list() | 63 | self._webcam_devices = list() |
490 | 55 | 64 | ||
491 | 56 | ############################################################ | 65 | ############################################################ |
492 | @@ -86,13 +95,15 @@ | |||
493 | 86 | video_formats = self._webcam_devices[webcam_device_index]['webcam_data']['video_formats'] | 95 | video_formats = self._webcam_devices[webcam_device_index]['webcam_data']['video_formats'] |
494 | 87 | mimetypes = ('video/x-raw-yuv','video/x-raw-rgb','image/jpeg') | 96 | mimetypes = ('video/x-raw-yuv','video/x-raw-rgb','image/jpeg') |
495 | 88 | (width,height)=(None,None) | 97 | (width,height)=(None,None) |
496 | 89 | |||
497 | 90 | for mimetype in mimetypes : | 98 | for mimetype in mimetypes : |
498 | 99 | |||
499 | 91 | if video_formats.has_key(mimetype) : | 100 | if video_formats.has_key(mimetype) : |
500 | 92 | # the resolution format are sorted by resolution | 101 | # the resolution format are sorted by resolution |
501 | 93 | # the higher resolution is first in list | 102 | # the higher resolution is first in list |
502 | 94 | width = video_formats[mimetype][0]['width'] | 103 | width = video_formats[mimetype][0]['width'] |
503 | 95 | height = video_formats[mimetype][0]['height'] | 104 | height = video_formats[mimetype][0]['height'] |
504 | 105 | framerate = video_formats[mimetype][0]['framerate'] | ||
505 | 106 | |||
506 | 96 | 107 | ||
507 | 97 | # leave loop when mimetype is found | 108 | # leave loop when mimetype is found |
508 | 98 | break | 109 | break |
509 | @@ -101,9 +112,11 @@ | |||
510 | 101 | # a format was detected : prepare pipeline info | 112 | # a format was detected : prepare pipeline info |
511 | 102 | webcam_bin_data['width'] = width | 113 | webcam_bin_data['width'] = width |
512 | 103 | webcam_bin_data['height'] = height | 114 | webcam_bin_data['height'] = height |
513 | 115 | webcam_bin_data['framerate_list'] = framerate | ||
514 | 116 | webcam_bin_data['framerate_selected'] = framerate[len(framerate)/2] | ||
515 | 104 | webcam_bin_data['source_input'] = self._webcam_devices[webcam_device_index]['v4l_driver'] | 117 | webcam_bin_data['source_input'] = self._webcam_devices[webcam_device_index]['v4l_driver'] |
516 | 105 | webcam_bin_data['device'] = self._webcam_devices[webcam_device_index]['device'] | 118 | webcam_bin_data['device'] = self._webcam_devices[webcam_device_index]['device'] |
518 | 106 | webcam_bin_data['name'] = self._webcam_devices[webcam_device_index]['name'] | 119 | webcam_bin_data['name'] = self._webcam_devices[webcam_device_index]['name'] |
519 | 107 | 120 | ||
520 | 108 | return webcam_bin_data | 121 | return webcam_bin_data |
521 | 109 | 122 | ||
522 | @@ -262,7 +275,6 @@ | |||
523 | 262 | for i in range(num_structures) : | 275 | for i in range(num_structures) : |
524 | 263 | # loop on each strutcures | 276 | # loop on each strutcures |
525 | 264 | structure = caps[i] | 277 | structure = caps[i] |
526 | 265 | |||
527 | 266 | if ( structure.has_name("video/x-raw-yuv") | 278 | if ( structure.has_name("video/x-raw-yuv") |
528 | 267 | or structure.has_name("video/x-raw-rgb") | 279 | or structure.has_name("video/x-raw-rgb") |
529 | 268 | or structure.has_name("image/jpeg") | 280 | or structure.has_name("image/jpeg") |
530 | @@ -271,12 +283,12 @@ | |||
531 | 271 | if not webcam_device["video_formats"].has_key(structure.get_name()): | 283 | if not webcam_device["video_formats"].has_key(structure.get_name()): |
532 | 272 | webcam_device["video_formats"][structure.get_name()] = list() | 284 | webcam_device["video_formats"][structure.get_name()] = list() |
533 | 273 | resolution_list = webcam_device["video_formats"][structure.get_name()] | 285 | resolution_list = webcam_device["video_formats"][structure.get_name()] |
535 | 274 | #print " resolution_list at the begin : %s"%webcam_device["video_formats"] | 286 | #print " resolution_list at the begin : \n %s"%webcam_device["video_formats"] |
536 | 275 | 287 | ||
537 | 276 | # take in acount only structure wih fields width and height | 288 | # take in acount only structure wih fields width and height |
538 | 277 | if (structure.has_field("width") and structure.has_field("height")) : | 289 | if (structure.has_field("width") and structure.has_field("height")) : |
539 | 278 | #print " %s : %s x %s"%(structure.get_name(),structure["width"],structure["height"] ) | 290 | #print " %s : %s x %s"%(structure.get_name(),structure["width"],structure["height"] ) |
541 | 279 | 291 | resolution=dict() | |
542 | 280 | # check if result is in GST_TYPE_INT_RANGE format | 292 | # check if result is in GST_TYPE_INT_RANGE format |
543 | 281 | if (isinstance(structure["width"], gst.IntRange)): | 293 | if (isinstance(structure["width"], gst.IntRange)): |
544 | 282 | # when type is range --> some resolution points are created in the range | 294 | # when type is range --> some resolution points are created in the range |
545 | @@ -286,21 +298,31 @@ | |||
546 | 286 | while ( ( width_cur <= structure["width"].high ) and | 298 | while ( ( width_cur <= structure["width"].high ) and |
547 | 287 | ( height_cur <= structure["height"].high ) | 299 | ( height_cur <= structure["height"].high ) |
548 | 288 | ): | 300 | ): |
550 | 289 | resolution=dict() | 301 | |
551 | 290 | ( resolution["width"] , resolution["height"] ) = (width_cur,height_cur) | 302 | ( resolution["width"] , resolution["height"] ) = (width_cur,height_cur) |
552 | 303 | #store framerate | ||
553 | 304 | resolution["framerate"] = None | ||
554 | 305 | if structure.has_field("framerate") : | ||
555 | 306 | resolution["framerate"] = structure["framerate"] | ||
556 | 307 | # Append resolution dict to list | ||
557 | 291 | if not resolution in resolution_list : | 308 | if not resolution in resolution_list : |
558 | 292 | resolution_list.append(resolution) | 309 | resolution_list.append(resolution) |
559 | 293 | (width_cur,height_cur) = (width_cur*2,height_cur*2) | 310 | (width_cur,height_cur) = (width_cur*2,height_cur*2) |
560 | 294 | 311 | ||
561 | 295 | # check if result is in G_TYPE_INT format | 312 | # check if result is in G_TYPE_INT format |
562 | 296 | elif structure.has_field_typed("width",gobject.TYPE_INT) : | 313 | elif structure.has_field_typed("width",gobject.TYPE_INT) : |
563 | 297 | resolution=dict() | ||
564 | 298 | (resolution["width"] , resolution["height"] ) = (structure["width"],structure["height"]) | 314 | (resolution["width"] , resolution["height"] ) = (structure["width"],structure["height"]) |
565 | 315 | resolution["framerate"] = None | ||
566 | 316 | if structure.has_field("framerate") : | ||
567 | 317 | resolution["framerate"] = luciole_webcam_detection.gst_get_framerate(structure["framerate"]) | ||
568 | 299 | if not resolution in resolution_list : | 318 | if not resolution in resolution_list : |
569 | 300 | resolution_list.append(resolution) | 319 | resolution_list.append(resolution) |
570 | 301 | 320 | ||
571 | 302 | else : | 321 | else : |
573 | 303 | print " type %s"% structure.get_field_type("width") | 322 | # raise error |
574 | 323 | excep_message = "unkown video type %s"% structure.get_field_type("width") | ||
575 | 324 | raise LEXCEP.LucioException,excep_message | ||
576 | 325 | |||
577 | 304 | for mimetype,res_list in webcam_device["video_formats"].iteritems(): | 326 | for mimetype,res_list in webcam_device["video_formats"].iteritems(): |
578 | 305 | # loop on video on formats to stort it | 327 | # loop on video on formats to stort it |
579 | 306 | # data are sorted by width , in reverse order; i.e max res is the first in the list | 328 | # data are sorted by width , in reverse order; i.e max res is the first in the list |
580 | @@ -314,7 +336,36 @@ | |||
581 | 314 | # print "----- %s : %s"%(mimetype,res_list) | 336 | # print "----- %s : %s"%(mimetype,res_list) |
582 | 315 | gst_get_supported_video_formats = staticmethod(__gst_get_supported_video_formats) | 337 | gst_get_supported_video_formats = staticmethod(__gst_get_supported_video_formats) |
583 | 316 | 338 | ||
585 | 317 | 339 | def __gst_get_framerate(framerate_obj): | |
586 | 340 | """ create a list of gst.Fraction framerates """ | ||
587 | 341 | framerate = list() | ||
588 | 342 | if type(framerate_obj) == list : | ||
589 | 343 | framerate = framerate_obj | ||
590 | 344 | elif isinstance(framerate_obj, gst.FractionRange) : | ||
591 | 345 | # convert also to list of framerate | ||
592 | 346 | NB_FRAMERATE = 4 | ||
593 | 347 | MAX_FRAMERATE = gst.Fraction(25,1) | ||
594 | 348 | |||
595 | 349 | # limit max framerate | ||
596 | 350 | if framerate_obj.high < MAX_FRAMERATE : | ||
597 | 351 | framerate_obj.high = MAX_FRAMERATE | ||
598 | 352 | |||
599 | 353 | new_framerate = framerate_obj.high | ||
600 | 354 | for i in range(NB_FRAMERATE) : | ||
601 | 355 | framerate.append(new_framerate) | ||
602 | 356 | new_framerate = new_framerate/2 | ||
603 | 357 | # at end of loop append the lowest framerate if not 0 | ||
604 | 358 | if framerate_obj.low != gst.Fraction(0,1) : | ||
605 | 359 | framerate.append(framerate_obj.low) | ||
606 | 360 | else : | ||
607 | 361 | # raise error | ||
608 | 362 | excep_message = " unable to detect framerate : unknown type : %s for "%(type(framerate_obj),framerate_obj) | ||
609 | 363 | raise LEXCEP.LucioException,excep_message | ||
610 | 364 | # transform framerate in not gst format | ||
611 | 365 | if framerate != None : | ||
612 | 366 | framerate_trans = [ (fraction.num,fraction.denom) for fraction in framerate] | ||
613 | 367 | return framerate_trans | ||
614 | 368 | gst_get_framerate = staticmethod(__gst_get_framerate) | ||
615 | 318 | 369 | ||
616 | 319 | if __name__ == '__main__' : | 370 | if __name__ == '__main__' : |
617 | 320 | # TEST PURPOSE : for webcam detection | 371 | # TEST PURPOSE : for webcam detection |
618 | @@ -322,11 +373,14 @@ | |||
619 | 322 | val = CamObj.detect_webcam() | 373 | val = CamObj.detect_webcam() |
620 | 323 | print " found %s webCam device "%val | 374 | print " found %s webCam device "%val |
621 | 324 | 375 | ||
629 | 325 | if val >0 : | 376 | #if val >0 : |
630 | 326 | for device in CamObj.webcam_devices : | 377 | # for device in CamObj.webcam_devices : |
631 | 327 | for k,j in device.iteritems() : print "%s : %s"%(k,j) | 378 | # for k,j in device.iteritems() : print "%s : %s"%(k,j) |
632 | 328 | print "----------------------------------------------------------------" | 379 | # print "----------------------------------------------------------------" |
633 | 329 | 380 | for i in range(val) : | |
634 | 330 | 381 | #for enumerate(index,device) in CamObj.webcam_devices : | |
635 | 331 | 382 | best = CamObj.get_gst_best_input(i) | |
636 | 383 | print "Best webcam resolution found " | ||
637 | 384 | print best | ||
638 | 385 | print "\n \n" | ||
639 | 332 | 386 | ||
640 | 333 | 387 | ||
641 | === modified file 'lucioLib/luciole_controller.py' | |||
642 | --- lucioLib/luciole_controller.py 2009-12-14 06:15:44 +0000 | |||
643 | +++ lucioLib/luciole_controller.py 2010-01-29 07:10:30 +0000 | |||
644 | @@ -123,10 +123,6 @@ | |||
645 | 123 | project_dico_data = LP.project_dico() | 123 | project_dico_data = LP.project_dico() |
646 | 124 | for k,v in project_data.iteritems() : | 124 | for k,v in project_data.iteritems() : |
647 | 125 | project_dico_data[k] = project_data[k] | 125 | project_dico_data[k] = project_data[k] |
648 | 126 | #convert webcam_data as str values to be coherent with load of webcam data from a file | ||
649 | 127 | if k == 'webcam_data' : | ||
650 | 128 | for w_k in project_dico_data[k].keys() : | ||
651 | 129 | project_dico_data[k][w_k] = "%s"%project_dico_data[k][w_k] | ||
652 | 130 | self.project = project_dico_data | 126 | self.project = project_dico_data |
653 | 131 | 127 | ||
654 | 132 | # 2. create project ( folder structure ,etc ...) | 128 | # 2. create project ( folder structure ,etc ...) |
655 | @@ -146,8 +142,17 @@ | |||
656 | 146 | # if a project is loaded close it | 142 | # if a project is loaded close it |
657 | 147 | print """ DEBUG : Close project Before """ | 143 | print """ DEBUG : Close project Before """ |
658 | 148 | self.close() | 144 | self.close() |
661 | 149 | 145 | try : | |
662 | 150 | self.project = self.project_ctrller.open(project_path) | 146 | (is_valid,self.project) = self.project_ctrller.open(project_path) |
663 | 147 | except L_EXCEP.LucioException,err : | ||
664 | 148 | print err | ||
665 | 149 | |||
666 | 150 | # webcam data are not valid | ||
667 | 151 | if is_valid == False : | ||
668 | 152 | msg = _(" Webcam data not valid in project. Please restart webcam detection") | ||
669 | 153 | LTK.Dialog.ErrorMessage(self.gui.window, msg) | ||
670 | 154 | |||
671 | 155 | |||
672 | 151 | 156 | ||
673 | 152 | # 3. load project in application | 157 | # 3. load project in application |
674 | 153 | self.__load_project_in_app() | 158 | self.__load_project_in_app() |
675 | 154 | 159 | ||
676 | === modified file 'lucioLib/luciole_project.py' | |||
677 | --- lucioLib/luciole_project.py 2009-04-24 13:42:04 +0000 | |||
678 | +++ lucioLib/luciole_project.py 2010-01-29 07:10:30 +0000 | |||
679 | @@ -4,7 +4,7 @@ | |||
680 | 4 | # vi:si:ai:et:sw=4:sts=4:ts=4 | 4 | # vi:si:ai:et:sw=4:sts=4:ts=4 |
681 | 5 | # | 5 | # |
682 | 6 | # | 6 | # |
684 | 7 | # Copyright Nicolas Bertrand (nico@inattendu.org), 2009 | 7 | # Copyright Nicolas Bertrand (nico@inattendu.org), 2009,2010 |
685 | 8 | # | 8 | # |
686 | 9 | # This file is part of Luciole. | 9 | # This file is part of Luciole. |
687 | 10 | # | 10 | # |
688 | @@ -30,18 +30,49 @@ | |||
689 | 30 | import xml.etree.ElementTree as ET #python 2.5 | 30 | import xml.etree.ElementTree as ET #python 2.5 |
690 | 31 | from xml.parsers.expat import ParserCreate, ExpatError | 31 | from xml.parsers.expat import ParserCreate, ExpatError |
691 | 32 | 32 | ||
692 | 33 | |||
693 | 33 | import luciole_constants as LCONST | 34 | import luciole_constants as LCONST |
694 | 34 | import luciole_tools as LT | 35 | import luciole_tools as LT |
695 | 35 | import luciole_exceptions as L_EXCEP | 36 | import luciole_exceptions as L_EXCEP |
696 | 36 | 37 | ||
697 | 37 | class project_dico(dict): | 38 | class project_dico(dict): |
698 | 39 | """ | ||
699 | 40 | Luciole project dicitionary : contains all porject data as dictionary | ||
700 | 41 | """ | ||
701 | 42 | |||
702 | 43 | # | ||
703 | 44 | # CONSTANTS | ||
704 | 45 | # | ||
705 | 46 | |||
706 | 47 | # mandatory tags for webcam description | ||
707 | 48 | WEBCAM_DATA_TAGS = [ 'name', | ||
708 | 49 | 'device', | ||
709 | 50 | 'source_input', | ||
710 | 51 | 'height', | ||
711 | 52 | 'width', | ||
712 | 53 | 'framerate_list', | ||
713 | 54 | 'framerate_selected', | ||
714 | 55 | ] | ||
715 | 56 | |||
716 | 57 | # default values for webcam | ||
717 | 58 | WEBCAM_TAGS_DEFAULT_VALUES = { | ||
718 | 59 | 'framerate_list' : [(5,1) ], | ||
719 | 60 | 'framerate_selected' : (5,1) , | ||
720 | 61 | } | ||
721 | 62 | |||
722 | 63 | |||
723 | 38 | def __init__(self): | 64 | def __init__(self): |
724 | 65 | """ constructor : init a dict """ | ||
725 | 39 | super(project_dico,self).__init__() | 66 | super(project_dico,self).__init__() |
726 | 40 | 67 | ||
727 | 41 | class project_controller(object) : | 68 | class project_controller(object) : |
728 | 69 | """ | ||
729 | 70 | Class for handling luciole projects : creation, open, save | ||
730 | 71 | """ | ||
731 | 72 | |||
732 | 42 | 73 | ||
733 | 43 | def __init__(self): | 74 | def __init__(self): |
735 | 44 | pass | 75 | """ Constructor""" |
736 | 45 | # by default no project loaded | 76 | # by default no project loaded |
737 | 46 | self.__project_loaded = False | 77 | self.__project_loaded = False |
738 | 47 | 78 | ||
739 | @@ -170,21 +201,44 @@ | |||
740 | 170 | # loop on webcam data and save on data dictionary | 201 | # loop on webcam data and save on data dictionary |
741 | 171 | webcam_data={} | 202 | webcam_data={} |
742 | 172 | for my_item in et_webcam_data.getchildren() : | 203 | for my_item in et_webcam_data.getchildren() : |
746 | 173 | webcam_data[my_item.tag] = my_item.attrib.get("key") | 204 | # for framerate_selected and framerate_list tage : evaluate to convert in tuple and list |
747 | 174 | # create acquisition object | 205 | # for others keep it as str |
748 | 175 | p_project['webcam_data'] =webcam_data | 206 | if my_item.tag == 'framerate_selected' or my_item.tag == 'framerate_list' : |
749 | 207 | webcam_data[my_item.tag] = eval(my_item.attrib.get("key")) | ||
750 | 208 | else : | ||
751 | 209 | webcam_data[my_item.tag] = my_item.attrib.get("key") | ||
752 | 210 | |||
753 | 211 | # check webcam data validity | ||
754 | 212 | is_valid = True | ||
755 | 213 | missing_tags = [] | ||
756 | 214 | for data in p_project.WEBCAM_DATA_TAGS : | ||
757 | 215 | if not webcam_data.has_key(data) : | ||
758 | 216 | is_valid = False | ||
759 | 217 | missing_tags.append(data) | ||
760 | 218 | |||
761 | 219 | if is_valid == False : | ||
762 | 220 | # not a valid project | ||
763 | 221 | for missing_tag in missing_tags : | ||
764 | 222 | if p_project.WEBCAM_TAGS_DEFAULT_VALUES.has_key(missing_tag) : | ||
765 | 223 | webcam_data[missing_tag] = p_project.WEBCAM_TAGS_DEFAULT_VALUES[missing_tag] | ||
766 | 224 | print missing_tag | ||
767 | 225 | else : | ||
768 | 226 | err = 'Invalid Project webcam data , tag %s is missing '%missing_tag | ||
769 | 227 | raise L_EXCEP.LucioException, err | ||
770 | 228 | |||
771 | 229 | p_project['webcam_data'] = webcam_data | ||
772 | 176 | else : | 230 | else : |
777 | 177 | # nbd@grape : raise Error | 231 | # raise Error |
778 | 178 | print " Invalide webcam data found " | 232 | err = "Invalid webcam data found " |
779 | 179 | return None | 233 | raise L_EXCEP.LucioException, err |
780 | 180 | 234 | ||
781 | 181 | p_project['rush_images'] = self.__scanImages("rushData") | 235 | p_project['rush_images'] = self.__scanImages("rushData") |
782 | 182 | p_project['capture_images'] = self.__scanImages("captureData") | 236 | p_project['capture_images'] = self.__scanImages("captureData") |
783 | 183 | p_project['chrono_images'] = self.__scanImages("chronoData") | 237 | p_project['chrono_images'] = self.__scanImages("chronoData") |
784 | 184 | 238 | ||
785 | 185 | p_project = self.__check_rush_images(p_project) | 239 | p_project = self.__check_rush_images(p_project) |
786 | 186 | 240 | ||
788 | 187 | return p_project | 241 | return (is_valid,p_project) |
789 | 188 | 242 | ||
790 | 189 | 243 | ||
791 | 190 | def __scanImages(self,p_type) : | 244 | def __scanImages(self,p_type) : |
792 | 191 | 245 | ||
793 | === modified file 'luciole.py' | |||
794 | --- luciole.py 2009-12-10 05:12:06 +0000 | |||
795 | +++ luciole.py 2010-01-29 07:10:30 +0000 | |||
796 | @@ -47,6 +47,8 @@ | |||
797 | 47 | logger = logging.getLogger("luciole") | 47 | logger = logging.getLogger("luciole") |
798 | 48 | if is_verbose == True : | 48 | if is_verbose == True : |
799 | 49 | logger.setLevel(logging.DEBUG) | 49 | logger.setLevel(logging.DEBUG) |
800 | 50 | else : | ||
801 | 51 | logger.setLevel(logging.INFO) | ||
802 | 50 | 52 | ||
803 | 51 | # create console handler with a higher log level | 53 | # create console handler with a higher log level |
804 | 52 | ch = logging.StreamHandler() | 54 | ch = logging.StreamHandler() |
Merge with 0.8
Translation update needed after