Exemplo n.º 1
0
def detect_and_draw(img, cascade):
    # allocate temporary images
    global var2
    gray = cv.CreateImage((img.width,img.height), 8, 1)
    small_img = cv.CreateImage((cv.Round(img.width / image_scale),
			       cv.Round (img.height / image_scale)), 8, 1)

    # convert color input image to grayscale
    cv.CvtColor(img, gray, cv.CV_BGR2GRAY)

    # scale input image for faster processing
    cv.Resize(gray, small_img, cv.CV_INTER_LINEAR)

    cv.EqualizeHist(small_img, small_img)

    if(cascade):
        t = cv.GetTickCount()
        faces = cv.HaarDetectObjects(small_img, cascade, cv.CreateMemStorage(0),
                                     haar_scale, min_neighbors, haar_flags, min_size)
        t = cv.GetTickCount() - t
#        print "detection time = %gms" % (t/(cv.GetTickFrequency()*1000.))
        if faces:
            for ((x, y, w, h), n) in faces:
                # the input to cv.HaarDetectObjects was resized, so scale the 
                # bounding box of each face and convert it to two CvPoints
                pt1 = (int(x * image_scale), int(y * image_scale))
                pt2 = (int((x + w) * image_scale), int((y + h) * image_scale))
                cv.Rectangle(img, pt1, pt2, cv.RGB(255, 0, 0), 3, 8, 0)
		print pt1	
		var2=var2+1
		if (var2==10):
			led.face()
			var2=0		
			emotion.happy()
    cv.ShowImage("result", img)
Exemplo n.º 2
0
def detect_and_draw(img, cascade):
    # allocate temporary images
    global var2
    gray = cv.CreateImage((img.width, img.height), 8, 1)
    small_img = cv.CreateImage((cv.Round(
        img.width / image_scale), cv.Round(img.height / image_scale)), 8, 1)

    # convert color input image to grayscale
    cv.CvtColor(img, gray, cv.CV_BGR2GRAY)

    # scale input image for faster processing
    cv.Resize(gray, small_img, cv.CV_INTER_LINEAR)

    cv.EqualizeHist(small_img, small_img)

    if (cascade):
        t = cv.GetTickCount()
        faces = cv.HaarDetectObjects(small_img, cascade,
                                     cv.CreateMemStorage(0), haar_scale,
                                     min_neighbors, haar_flags, min_size)
        t = cv.GetTickCount() - t
        #        print "detection time = %gms" % (t/(cv.GetTickFrequency()*1000.))
        if faces:
            for ((x, y, w, h), n) in faces:
                # the input to cv.HaarDetectObjects was resized, so scale the
                # bounding box of each face and convert it to two CvPoints
                pt1 = (int(x * image_scale), int(y * image_scale))
                pt2 = (int((x + w) * image_scale), int((y + h) * image_scale))
                cv.Rectangle(img, pt1, pt2, cv.RGB(255, 0, 0), 3, 8, 0)
                print pt1
                var2 = var2 + 1
                if (var2 == 10):
                    led.face()
                    var2 = 0
                    emotion.happy()
    cv.ShowImage("result", img)
Exemplo n.º 3
0
                elif data.startswith("red"):
                        data="i found a red object"
                        no_words=len(data)
                        no_char=0
                        sa.stmt=data
                        sa.speak=True
                        speech.say(data)
                elif data.startswith("blue"):
                        data="i found a blue object"
                        no_words=len(data.split())
                        no_char=0
                        sa.stmt=data
                        sa.speak=True
                        speech.say(data)
                elif data.startswith("love"):
                        emotion.happy()
                
	#while 1:
	#	data = raw_input ( "SEND( TYPE q or Q to Quit):" )
	#	if (data == 'Q' or data == 'q'):
	#		client_socket.send (data)

        #               client_socket.close()
	#		break;
	#	else:
	#		client_socket.send(data)
 
    #           data = client_socket.recv(512)
    #           if ( data == 'q' or data == 'Q'):
	#		client_socket.close()
	#		break;