Ejemplo n.º 1
0
    #print height, " ", width
    #sleep(5)
    #gray = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
    #height, width = gray.shape[:2]
    # Our operations on the frame come here, doing some manipulation to reduce effects from surrounding objects,
    #light&shadow play, etc 
    gray = cv2.medianBlur(gray, 5)
    #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    gray = cv2.bilateralFilter(gray, 5, 25, 25)

    #cv2.rectangle(gray, (width/2-150, height/2-150), (width/2+200, height/2+150), (255,0,0), 2)

    cv2.imshow('frame',gray) #showing image
    #gray = gray.copy()[height/2-150:height/2+150,width/2-150:width/2+200]
    image = Image.fromarray(gray) #turning array into image
    speech = ocr.ocr_image(image) #ocr-ing image by Tesseract
    #print type(speech)
    #speech = ocr.get_utf8_text()
    if ocr.get_mean_confidence() >= 63 and len(speech.strip()) >1:
        tts.say(str(speech))
        print speech 
    sleep(1)
    #robot speech

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
#cap.release()
camProxy.unsubscribe(videoClient)
cv2.destroyAllWindows()
Ejemplo n.º 2
0
    cv2.imshow('frame',gray) #showing image

    if cv2.waitKey(1) & 0xFF == ord('p'):
        cv2.imwrite('pic{:>05}.jpg'.format(i), gray) 
        i += 1
     
    #gray = gray.copy()[height/2-150:height/2+150,width/2-150:width/2+200]
    image = Image.fromarray(gray) #turning array into image
    #img = cv2.QueryFrame(image)  

        
    speech = ocr.ocr_image(image) #ocr-ing image by Tesseract
    #print type(speech)
    #speech = ocr.get_utf8_text()
    wordList = re.sub("[^\w]", " ",  str(speech)).split()
    if ocr.get_mean_confidence() >= 63:
        for word in wordList:
            print word
           # print dict.dictionary
            if dict.find_word(word.strip()):
                tts.say(word)
                print " the word is " + word
       # tts.say(str(speech))
      #  print speech 
    sleep(1)
    #robot speech

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture