示例#1
0
def main():
    if len(sys.argv) >= 2 and sys.argv[1] == '-h':
        exit_usage(0)
    if len(sys.argv) != 4:
        exit_usage(1)
    net = sys.argv[1]
    weight_file = sys.argv[2]
    img_dir = sys.argv[3]

    detect.init(net, weight_file)
    files = sorted(os.listdir(img_dir))
    run_time = 0
    img_num = 0
    for f in files:
        if f.split('.')[-1] != 'jpg':
            continue
        file_path = img_dir + '/' + f
        img = cv2.imread(file_path, 1)
        time_start = time.time()
        bbox = detect.run(img, img.shape[0], img.shape[1])
        time_end = time.time()
        run_time = run_time + time_end - time_start
        img_num = img_num + 1
        print("[%.6f, %.6f, %.6f, %.6f]" %
              (bbox[0], bbox[1], bbox[2], bbox[3]))
        draw_bbox(img, bbox)

    detect.cleanup()
    print("total image number: %d" % img_num)
    print("frames per second of detection: %.6f" % (img_num / run_time))
示例#2
0
def qloop():
    detect.init()
    global done, sq_id, frames_cnt

    prev = None
    while not done:
        name = squeue.pop(sq_id)
        if sq_id is None:
            prev = sq_id
            continue
        if prev is None:
            logging.debug(("Begin", sq_id))
            prepare.init()

        prev = sq_id
        cls = handle_img(name)
        frames_cnt += 1
示例#3
0
def main():
    game.init(1280, 960)

    available_letters = ['a', 'b', 'c', 'd', 'e']
    game.set_property('available_letters', available_letters)

    global_states = {
        'main_menu': MainMenu(),
        'tutorial': Tutorial(),
        'game': Game()
    }

    ## Set initial state
    game.set_global_states(global_states, 'main_menu')

    game.update.subscribe(update)
    game.draw.subscribe(draw)

    detect.init()

    game.start()
示例#4
0
    return True


def end():
    global ended, sq_id
    ended = True
    sq_id = None


def count():
    return sq_cnt


def processed():
    return frames_cnt


if __name__ == "__main__":
    test_folder = sys.argv[1] if len(sys.argv) > 1 else "test_data"
    detect.init()
    prepare.init()
    flist = [f for f in os.listdir(test_folder)]
    flist.sort()

    for f in flist:
        handle_img(os.path.join(test_folder, f))
else:
    T = threading.Thread(target=qloop)
    T.daemon = True
    T.start()
示例#5
0
from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from detect import init
from detect import detect
from parl.utils import logger
import os
import time

# Create your views here.
params = init()

people_num = 0
battery_remaining_level = 0
bandwidth_quality = 0
local_people_confidence_sum = 0
local_process_time = 0


def objectdetect(request):
    print("接受请求")
    # params=init();
    # detect(params)
    fileImage = request.FILES.get("fileImage")
    # print(fileImage)

    if fileImage:
        origin_image_path = os.path.join(
            "/software/ObjectDetectionProject/data/images")
        w = open(os.path.join(origin_image_path, fileImage.name), 'wb+')
        for chunk in fileImage.chunks():
            w.write(chunk)
示例#6
0
from math import *
from random import random
import pygame, time, os
from helper import ir
from sprite import MovingSprite
import kinect as kin
import detect

fullscreen = 1
n_sprites = 12
sprite_speed = 200
speedup = 1.05
points = 10


detect.init()
detect.warmup()
detect.take_zero()


os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.init()
W, H = 800, 600  # will be overriden by fullscreen
if fullscreen:
    screen = pygame.display.set_mode( (0,0), pygame.FULLSCREEN )
    W = pygame.display.Info().current_w
    H = pygame.display.Info().current_h
else:
    screen = pygame.display.set_mode( (W,H) )
    
screen.fill((0,0,0))
示例#7
0
	#print "val"+str(count)
	return count

def getUser(sock):
	try:
		userinfo = userlog.getInfo()
	except:	
		userinfo = configure.init(sock)
	return userinfo

if __name__=="__main__":	
	sock = connectify.createCon()
	userinfo = getUser(sock)
	while 1:
		print "in loop"
		updatelist = detect.init()
		count = countUpdates(updatelist) 
		sock.send('2'+userinfo)
		content = sock.recv(1024)
		print "count value : "+content
		if content!= '0':
			for i in range(0,int(content)):
				sock.send('3'+userinfo)
				updatelist = updateClient.init(sock, updatelist)
		#print updatelist
		if count > 0:
				print "updating log file"
				detect.createlogfile()
		print updatelist
		count = countUpdates(updatelist) 
		time.sleep(2)