Exemplo n.º 1
0
def sleep():
    global voiceState
    if voiceState=="WAKEUP":
        voiceState="SLEEP"
        MMC.setBrightness(0)
    else:
        voiceState="WAKEUP" #退出设置
    print(voiceState)
Exemplo n.º 2
0
import PC as P
import MMC as MarkovCls
import SMM as SupportMarkov
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# create a cohort
cohort = MarkovCls.Cohort(id=0, therapy=P.Therapies.ANTICOAGULATION)

# simulate the cohort
simOutputs = cohort.simulate()

# graph survival curve
PathCls.graph_sample_path(sample_path=simOutputs.get_survival_curve(),
                          title='Survival curve, Anticoagulation',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

# create a cohort
cohort2 = MarkovCls.Cohort(id=0, therapy=P.Therapies.NO_DRUG)

# simulate the cohort
simOutputs2 = cohort2.simulate()

# graph survival curve
PathCls.graph_sample_path(sample_path=simOutputs2.get_survival_curve(),
                          title='Survival curve, no drug',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')
Exemplo n.º 3
0
def gestureDetect():
    global voiceState,clockFlag
    lastRes=0
    while voiceState=="CLOCK" or voiceState=="NEWS":
        """1.拍照 """
        camera.start_preview()
        time.sleep(1)
        #mixer.music.stop()
        camera.capture('./image.jpg')
        camera.stop_preview()
        image = get_file_content('./image.jpg')

        """ 2.调用手势识别 """
        raw = str(client.gesture(image))
        text = demjson.decode(raw) # decode 返回的json
        try:
            res = text['result'][0]['classname']
        except:
            print('Nothing detected!' )
        else:
            if res==lastRes:
                print('Nothing detected!' )
            else:
                lastRes=res
                print('Detect' + hand[res])
                if state=="CLOCK":
                    if clockFlag== "appear" and hand[res]=="Previous News or clock disappear":
                        #MMC.showAlert("Hide clock! Got it!",2000)
                        #time.sleep(2)
                        MMC.hideModule("clock")
                        clockFlag="disappear"
                    else if clockFlag=="disappear" and hand[res]== "Next News or clock appear":
                        #MMC.showAlert("Show clock! Got it!",2000)
                        #time.sleep(2)
                        MMC.showModule("clock")
                        clockFlag="appear"
                if state == "NEWS":
                    if hand[res]=="Previous News or clock disappear":
                        #MMC.showAlert("Previous news! Got it!",2000)
                        #sleep(2)
                        MMC.previousArtical()
                    if hand[res]=="Next News or clock appear":
                        #MMC.showAlert("Next news! Got it!",2000)
                        #sleep(2)
                        MMC.nextArtical()
                    if hand[res]=="Read More":
                        #MMC.showAlert("Read the news! Got it!",1000)
                        MMC.readMore()
                    if hand[res]=="Read Less":
                        MMC.readLess()
Exemplo n.º 4
0
def news():
    global voiceState
    MMC.showAlert("Read the news! Got it!",1000)
    voiceState="NEWS"
    print(voiceState)
Exemplo n.º 5
0
def clock():
    global voiceState
    MMC.showAlert("Set clock! Got it!",2000)
    time.sleep(2)
    voiceState="CLOCK"
    print(voiceState)
Exemplo n.º 6
0
def wakeup():
    global voiceState
    voiceState="WAKEUP"
    MMC.setBrightness(100)
    print(voiceState)
Exemplo n.º 7
0
camera.resolution = (1280, 720)
#声音设置
#logging.basicConfig()
#logger = logging.getLogger("snowboy") # 终端打印提示信息
voiceState="SLEEP"; # WAKEUP,CLOCK,HELLO,NEWS;control gesture
clockFlag="appear" # appear,disappear
interrupted = False

# confirm the num of models
if len(sys.argv) != 6:    
    print("Error: need to specify 5 model names")
    print("Usage: python demo.py 1st.model 2nd.model ... 5th.model")
    sys.exit(-1)
models = sys.argv[1:]

MMC.setBrightness(0)
# capture SIGINT signal, e.g., Ctrl+C
signal.signal(signal.SIGINT, singalHandler)

sensitivity = [0.5]*len(models)
detector = snowboydecoder.HotwordDetector(models, sensitivity=sensitivity)
callbacks = [lambda: wakeup(),
             lambda: sleep(),
             lambda: clock(),
             lambda: hello(),
             lambda: news()]
print('Listening... Press Ctrl+C to exit')

voiceThread = Thread(target=voiceDetect(), args=())
gestureThread =Thread(target=gestureDetect(), args=())
Exemplo n.º 8
0
import PC as P
import MMC as MarkovCls
import SMM as SMarkov
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# create a cohort
cohort = MarkovCls.Cohort(id=0, therapy=P.Therapies.NO_DRUG)

# simulate the cohort
simOutputs = cohort.simulate()

# print the outcomes of this simulated cohort
SMarkov.print_outcomes(simOutputs, 'No drug:')
Exemplo n.º 9
0
def gestureDetect():
    global voiceState, clockFlag
    print("start gestureDetect!")

    lastRes = 0
    while True:
        #if voiceState!="CLOCK" and voiceState!="NEWS":
        #continue
        """1.拍照 """

        #camera.start_preview(fullscreen=False,window=(100,20,620,540))
        time.sleep(1)
        camera.capture('./image.jpg')
        #camera.stop_preview()
        image = get_file_content('./image.jpg')
        """ 2.调用手势识别 """
        raw = str(client.gesture(image))
        text = demjson.decode(raw)  # decode 返回的json
        try:
            res = text['result'][0]['classname']
        except:
            print('Nothing detected!')
            lastres = "None"
        else:
            if res == lastRes:
                print('Nothing detected!')
            else:
                lastRes = res
                print('Detect ' + hand[res])
                if voiceState == "CLOCK":
                    if clockFlag == "appear" and (res == "Thumb_up"
                                                  or res == "One"):
                        print("hide clock")
                        MMC.hideModule("clock")
                        clockFlag = "disappear"
                    elif clockFlag == "disappear" and res == "Thumb_down":
                        #MMC.showAlert("Show clock! Got it!",2000)
                        #time.sleep(2)
                        print("show clock")
                        MMC.showModule("clock")
                        clockFlag = "appear"
                if voiceState == "NEWS":
                    if hand[res] == "Previous News or clock disappear":
                        #MMC.showAlert("Previous news! Got it!",2000)
                        #sleep(2)
                        MMC.previousArtical()
                    if hand[res] == "Next News or clock appear":
                        #MMC.showAlert("Next news! Got it!",2000)
                        #sleep(2)
                        MMC.nextArtical()
                    if hand[res] == "Read More":
                        #MMC.showAlert("Read the news! Got it!",1000)
                        MMC.readMore()
                    if hand[res] == "Read Less":
                        MMC.readLess()
Exemplo n.º 10
0
def hello():
    global voiceState
    voiceState = "HELLO"
    MMC.showAlert("Good afterNoon, my darling!", 2000)
    time.sleep(2)
    print(voiceState)
Exemplo n.º 11
0
def wakeup():
    global voiceState
    if voiceState == "SLEEP":
        voiceState = "WAKEUP"
        MMC.setBrightness(100)
    print(voiceState)