コード例 #1
0
ファイル: server.py プロジェクト: sensecollective/johnnypi
def callbackSee(client, userdata, message):
	print "Topic="+message.topic
	image = camera.takePicture()
	awsUtils.copyLocalFileToS3(image)
	print "Picture uploaded"
	labels = RekognitionApi.detectLabels(reko, image)
	RekognitionUtils.printLabelsInformation(labels)
	faces = RekognitionApi.detectFaces(reko, image)
	newImage, faceCounter = RekognitionUtils.generateOutputImage(image, faces)
	faceMessage, labelMessage = RekognitionUtils.generateMessages(faceCounter, labels)
	print "Face message: " + faceMessage
	print "Label message: " + labelMessage
	PollyApi.speak(polly, faceMessage)
    	PollyApi.speak(polly, labelMessage)
	if message.payload == "tweet":
		tweet.tweet(newImage, faceMessage)
		print "Tweet sent"
コード例 #2
0
ファイル: server.py プロジェクト: sensecollective/johnnypi
def callbackSee(client, userdata, message):
    print "Topic=" + message.topic
    print "Message=" + message.payload
    image = camera.takePicture()
    if message.payload.startswith("mxnet"):
        # Detect image with MXNet
        mxnetimage = inception.load_image(image)
        prob = inception.predict(mxnetimage, model)
        topN = inception.get_top_categories(prob, synsets)
        print topN
        speech = inception.get_top1_message(topN)
        print speech
        PollyApi.speak(polly, speech)
        if message.payload.endswith("tweet"):
            tweet.tweet(image, speech)
            print "Tweet sent"
    elif message.payload.startswith("reko"):
        # Detect image with Rekognition
        awsUtils.copyLocalFileToS3(image)
        print "Picture uploaded"
        labels = RekognitionApi.detectLabels(reko, image)
        RekognitionUtils.printLabelsInformation(labels)
        faces = RekognitionApi.detectFaces(reko, image)
        celebs = RekognitionApi.detectCelebrities(reko, image)
        newImage, faceCounter = RekognitionUtils.generateOutputImage(
            image, faces)
        faceMessage, labelMessage = RekognitionUtils.generateMessages(
            faceCounter, celebs, labels)
        print "Face message: " + faceMessage
        #print "Label message: " + labelMessage
        PollyApi.speak(polly, faceMessage)
        #PollyApi.speak(polly, labelMessage)
        if message.payload.endswith("tweet"):
            tweet.tweet(newImage, faceMessage)
            print "Tweet sent"
    else:
        print "Wrong Command, Please Enter Again"