File tree 3 files changed +39
-1
lines changed
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change
1
+ #capture image on webcam with OpenCV
2
+ import Image ;
3
+ import cv ;
4
+ import subprocess
5
+ import ImageStat
6
+ import time
7
+
8
+ capture = cv .CreateCameraCapture (0 )
9
+ cv .SetCaptureProperty (capture ,cv .CV_CAP_PROP_FRAME_WIDTH , 128 )
10
+ cv .SetCaptureProperty (capture ,cv .CV_CAP_PROP_FRAME_HEIGHT , 128 );
11
+
12
+ if not capture :
13
+ print "Error"
14
+ sys .exit (1 )
15
+ while 1 :
16
+ frame = cv .QueryFrame (capture )
17
+ cv .SaveImage ("./cam.bmp" ,frame )
18
+ image = Image .open ("./cam.bmp" ).convert ('L' )
19
+ stats = ImageStat .Stat (image )
20
+ stats = stats .mean [0 ]
21
+
22
+ brightval = hex (int ((255 - (stats * 1.5 ))))
23
+ currentval = subprocess .Popen ("setpci -s 00:02.0 F4.B" ,shell = True ,stdout = subprocess .PIPE ).stdout .read ()
24
+ if abs (int (brightval ,16 ) - int (currentval ,16 )) > 30 :
25
+ print int (brightval ,16 )
26
+ command = "setpci -s 00:02.0 F4.B=" + str (brightval )
27
+ subprocess .Popen (command ,shell = True )
28
+ else :
29
+ time .sleep (5 )
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ def parseLyrics(data):
67
67
run = False
68
68
inp = str (raw_input ("\b Save lyrics(y/n)?" ))
69
69
if inp == 'y' or inp == 'Y' :
70
- inp += a2 [len ('Title: ' ):len (a2 )]+ ".lyric' "
70
+ inp += a2 [len ('Title: ' )+ 1 :len (a2 )]+ ".lyric"
71
71
try :
72
72
file_w = open (inp ,'a' )
73
73
file_w .write (op + '\n ' + lyric )
Original file line number Diff line number Diff line change
1
+ import dbus
2
+ bus = dbus .SessionBus ()
3
+
4
+ proxy = bus .get_object ('org.gnome.SettingsDaemon' ,
5
+ '/org/gnome/SettingsDaemon/Power' )
6
+
7
+ iface = dbus .Interface (proxy ,dbus_interface = 'org.gnome.SettingsDaemon.Power.Screen' )
8
+
9
+ iface .SetPercentage (30 )
You can’t perform that action at this time.
0 commit comments