Exemplo n.º 1
0
    def GET(self):
        i = web.input(camuid="", date="", hour="")
        camuid = i.camuid
        date = i.date
        hour = i.hour
        configLoad.load_cameras()
        camera_list = configLoad.globalConfig['cameras']
        theCam = {}
        for camera in camera_list:
            if camera['uid'] == camuid:
                theCam = camera
                break

        camDir = theCam['base_path']
        hisDir = camDir + '/history/'

        folder_list = []

        folderDir = hisDir + date
        pics = os.listdir(folderDir)
        pics = [x for x in pics if '.jpg' in x]
        pics.sort()

        picList = []
        hour = str(hour)
        hour = hour.zfill(2)
        for pic in pics:
            if hour == pic[9:11]:
                picList.append(pic)

        print folderDir, ": ", len(pics), "pics"

        folder_list.append([folderDir, picList, camuid])

        return render.cam_history_pics(folder_list)
Exemplo n.º 2
0
    def GET(self):
        configLoad.load_cameras();
        configLoad.load_camera_config();
        result_to_show=[];
        for camera in configLoad.globalConfig['cameras']:
            frames_path=camera['frame_path'];

            if camera.has_key('savedProgress'):
                cameradata={};
                cameradata['uid']=camera['uid'];
                oneImage=camera['savedProgress'];
                resimage_path=camera['result_personarea_path']+'/'+oneImage.replace(source_flag,result_flag);
                #resimage = Image.open(camera['result_personarea_path']+'/'+oneImage.replace(source_flag,result_flag))
                cameradata['image']=resimage_path;
                frames=[];
                with open(camera['result_person_box_path']+'/'+oneImage.replace(source_flag,boundingbox_flag)) as fframes:
                    for line in fframes:
                        values=line.split(' ');
                        frames.append((int(values[0]),int(values[1]),int(values[2]),int(values[3]),float(values[4])));
                cameradata['frames']=frames;

                
                result_to_show.append(cameradata);
        i = web.input(orderby="default");
        if i.orderby=='count':
            #print len(result_to_show[0]['frames'])
            result_to_show.sort(key=lambda x:len(x['frames']),reverse=True);
        return render.mainpage(result_to_show);
Exemplo n.º 3
0
    def GET(self):
        configLoad.load_cameras()
        configLoad.load_camera_config()
        result_to_show = []
        for camera in configLoad.globalConfig['cameras']:
            frames_path = camera['frame_path']

            if camera.has_key('savedProgress'):
                cameradata = {}
                cameradata['uid'] = camera['uid']
                oneImage = camera['savedProgress']
                resimage_path = camera[
                    'result_personarea_path'] + '/' + oneImage.replace(
                        source_flag, result_flag)
                #resimage = Image.open(camera['result_personarea_path']+'/'+oneImage.replace(source_flag,result_flag))
                cameradata['image'] = resimage_path
                frames = []
                with open(camera['result_person_box_path'] + '/' +
                          oneImage.replace(source_flag, boundingbox_flag)
                          ) as fframes:
                    for line in fframes:
                        values = line.split(' ')
                        frames.append(
                            (int(values[0]), int(values[1]), int(values[2]),
                             int(values[3]), float(values[4])))
                cameradata['frames'] = frames

                result_to_show.append(cameradata)
        i = web.input(orderby="default")
        if i.orderby == 'count':
            #print len(result_to_show[0]['frames'])
            result_to_show.sort(key=lambda x: len(x['frames']), reverse=True)
        return render.mainpage(result_to_show)
Exemplo n.º 4
0
    def GET(self):
        i = web.input(camuid="")
        camuid = i.camuid
        configLoad.load_cameras()
        camera_list = configLoad.globalConfig['cameras']
        theCam = {}
        for camera in camera_list:
            if camera['uid'] == camuid:
                theCam = camera
                break

        camDir = theCam['base_path']
        hisDir = camDir + '/history/'

        folders = os.listdir(hisDir)
        folders.sort()
        folders.reverse()

        folder_list = []
        for folder in folders:
            folderDir = camDir + '/history/' + folder
            pics = os.listdir(folderDir)
            pics = [x for x in pics if '.jpg' in x]
            pics.sort()
            print folderDir, ": ", len(pics), "pics"
            folder_list.append([folderDir, pics, camuid])

        return render.cam_history(folder_list)
Exemplo n.º 5
0
    def GET(self):
        configLoad.load_cameras()
        configLoad.load_mode_config()
        camera_list = configLoad.globalConfig['cameras']

        mode_config = ConfigParser.ConfigParser()
        mode_config.read('./mode_config')
        mode_list = []

        for index, section in enumerate(mode_config.sections()):
            if section != "Default":
                option_list = ""
                for option in mode_config.options(section):
                    if option != "runtime" and option != "week":
                        option_list = option_list + option + ", "
                mode_list.append({
                    'mode_name':
                    section,
                    'week':
                    mode_config.get(section, 'week'),
                    'run_time':
                    mode_config.get(section, 'runtime'),
                    'cameras':
                    option_list
                })
                print 'mode_name', section, 'cameras', option_list
        data_to_pass = [camera_list, mode_list]
        return render.setmode(data_to_pass)
Exemplo n.º 6
0
    def GET(self):
        #__init__
        picurl = ''
        taskid = ''
        name = ''
        subpage = 0
        mfiles = []
        pagenum = 1
        width = 640
        height = 480

        configLoad.load_cameras()
        configLoad.load_camera_config()
        i = web.input(subpage="0")
        subpage = int(i.subpage)

        if (subpage < 0):
            return "error"

        name = []
        output = {}
        if subpage == 0:
            for camera in configLoad.globalConfig['cameras']:
                name.append(camera['uid'])
        elif subpage == 1:
            i = web.input(taskid="none", pagenum="0")
            pagenum = int(i.pagenum)
            taskid = i.taskid
            if (taskid != 'none'):
                mCameraConfig = None
                for camera in configLoad.globalConfig['cameras']:
                    if taskid == camera['uid']:
                        mCameraConfig = camera
                        break
                if mCameraConfig is not None:
                    biaodingdir = mCameraConfig['frame_path'] + '/'
                    files = os.listdir(biaodingdir)
                    mfiles = [
                        biaodingdir + '/' + mfile for mfile in files
                        if configLoad.source_flag in mfile
                    ]
                    picurl = mfiles[pagenum]
                    print mCameraConfig['config']['config']
                    width = int(mCameraConfig['config']['config']['width'])
                    height = int(mCameraConfig['config']['config']['height'])

        output['IImagePath'] = 'static/' + picurl
        output['taskid'] = taskid
        output['name'] = name
        output['subpage'] = subpage
        output['sumpage'] = len(mfiles)
        output['pagenum'] = pagenum
        output['width'] = width
        output['height'] = height
        #return "hello"
        return render.calibration(output)
Exemplo n.º 7
0
    def GET(self):
        #__init__
        picurl=''
        taskid='';
        name='';
        subpage=0;
        mfiles=[];
        pagenum=1;
        width=640;
        height=480;

        configLoad.load_cameras()
        configLoad.load_camera_config()
        i = web.input(subpage="0")
        subpage=int(i.subpage);

        if (subpage<0):
            return "error"

        name = []
        output = {}
        if subpage==0:
            for camera in configLoad.globalConfig['cameras']:
                name.append(camera['uid']);
        elif subpage==1:
            i = web.input(taskid="none", pagenum="0")
            pagenum = int(i.pagenum)
            taskid = i.taskid
            if (taskid != 'none'):
                mCameraConfig=None;
                for camera in configLoad.globalConfig['cameras']:
                    if taskid == camera['uid']:
                        mCameraConfig=camera;
                        break;
                if mCameraConfig is not None:
                    biaodingdir = mCameraConfig['frame_path'] +'/';
                    files = os.listdir(biaodingdir)
                    mfiles = [biaodingdir + '/' + mfile for mfile in files if configLoad.source_flag in mfile]
                    picurl = mfiles[pagenum]
                    print mCameraConfig['config']['config']
                    width=int(mCameraConfig['config']['config']['width']);
                    height = int(mCameraConfig['config']['config']['height']);


        output['IImagePath'] ='static/'+ picurl
        output['taskid'] = taskid
        output['name'] = name
        output['subpage'] = subpage
        output['sumpage'] = len(mfiles)
        output['pagenum'] = pagenum
        output['width'] = width
        output['height'] = height
        #return "hello"
        return render.calibration(output)
Exemplo n.º 8
0
    def GET(self):
        configLoad.load_cameras();
        configLoad.load_camera_config();
        result_to_show=[];
        for camera in configLoad.globalConfig['cameras']:
            frames_path=camera['frame_path'];

            if camera.has_key('savedProgress'):
                cameradata={};
                cameradata['uid']=camera['uid'];
                oneImage=camera['savedProgress'];
                resimage_path=camera['result_personarea_path']+'/'+oneImage.replace(source_flag,result_flag);
                #resimage = Image.open(camera['result_personarea_path']+'/'+oneImage.replace(source_flag,result_flag))
                cameradata['image']=resimage_path;
                frames=[];
                with open(camera['result_person_box_path']+'/'+oneImage.replace(source_flag,boundingbox_flag)) as fframes:
                    for line in fframes:
                        values=line.split(' ');
                        frames.append((int(values[0]),int(values[1]),int(values[2]),int(values[3]),float(values[4])));
                cameradata['frames']=frames;
                result_to_show.append(cameradata);
        return render.mainpage(result_to_show);
Exemplo n.º 9
0
run = True

net = maineval_voc.initNet()

source_flag = configLoad.source_flag
result_flag = configLoad.result_flag
boundingbox_flag = configLoad.boundingbox_flag
inter_time = 0.0
clean_time = 0.0

db = MySQLdb.connect("localhost", "root", "lm2323", "people_c")
cursor = db.cursor()

while run:
    configLoad.load_count_config()
    configLoad.load_cameras()
    configLoad.load_camera_config()
    clean_flag = int(
        configLoad.globalConfig['count_config']['default']['cleanflag'])

    for camera in configLoad.globalConfig['cameras']:
        # check max number;
        # camera
        if not os.path.exists(camera['config_path'] + 'Device.ini'):
            continue
        mode_config = ConfigParser.ConfigParser()
        mode_config.read(camera['config_path'] + 'Device.ini')

        camUid = camera['uid'].strip()

        ip = mode_config.get('DEVICE', 'ip')
Exemplo n.º 10
0
    def POST(self):
        i = web.input(action="")
        if i.action == "mode_set":
            i = web.input(camera="", plan_name="", run_time="", week="")
            camera = i.camera.encode('utf8')
            camera_id_list = camera.split(',')
            camera_id_list.pop()
            plan_name = i.plan_name
            plan_name = plan_name.encode('utf8')

            week = i.week
            week = week.encode('utf8')

            #print "camera_id_list",camera_id_list;
            #print "run_time_list",run_time_list;

            configLoad.load_cameras()
            configLoad.load_mode_config()

            mode_config = ConfigParser.ConfigParser()
            mode_config.read('./mode_config')

            mode_config.add_section(plan_name)
            mode_config.set(plan_name, 'week', i.week)
            mode_config.set(plan_name, 'runtime', i.run_time)
            for camera_id in camera_id_list:
                mode_config.set(plan_name, camera_id, 1)

            print "setmode", plan_name, camera_id, week, i.run_time

            # with codecs.open('./mode_config', encoding="utf-8-sig" ) as f:
            # mode_config.write(f);
            mode_config.write(codecs.open('./mode_config', 'w', 'utf-8'))

            configLoad.load_cameras()
            configLoad.load_mode_config()
            camera_list = configLoad.globalConfig['cameras']

            mode_list = []
            for index, section in enumerate(mode_config.sections()):
                if section != "Default":
                    option_list = ""
                    for option in mode_config.options(section):
                        if option != "runtime" and option != "week":
                            option_list = option_list + option + ", "
                    mode_list.append({
                        'mode_name':
                        section,
                        'week':
                        mode_config.get(section, 'week'),
                        'run_time':
                        mode_config.get(section, 'runtime'),
                        'cameras':
                        option_list
                    })
                    print 'mode_name', section, 'cameras', option_list

            data_to_pass = [camera_list, mode_list]
            return render.setmode(data_to_pass)
        if i.action == "mode_delete":
            i = web.input(mode_name="")
            mode_name = i.mode_name
            print "mode_name", mode_name
            print isinstance(mode_name, unicode)
            print mode_name.encode('utf8')

            mode_name = mode_name.encode('utf8')
            mode_config = ConfigParser.ConfigParser()
            mode_config.read('./mode_config')

            runtime = mode_config.get(mode_name, 'runtime')
            cameras = mode_config.options(mode_name)

            mode_config.remove_section(mode_name)

            mode_config.write(codecs.open('./mode_config', 'w', 'utf-8'))

            configLoad.load_cameras()
            configLoad.load_mode_config()
            camera_list = configLoad.globalConfig['cameras']

            mode_list = []
            for index, section in enumerate(mode_config.sections()):
                if section != "Default":
                    option_list = ""
                    for option in mode_config.options(section):
                        if option != "runtime" and option != "week":
                            option_list = option_list + option + ", "
                    mode_list.append({
                        'mode_name':
                        section,
                        'week':
                        mode_config.get(section, 'week'),
                        'run_time':
                        mode_config.get(section, 'runtime'),
                        'cameras':
                        option_list
                    })
                    print 'mode_name', section, 'cameras', option_list

            data_to_pass = [camera_list, mode_list]
            return render.setmode(data_to_pass)
Exemplo n.º 11
0
    def GET(self):
        configLoad.load_count_config()
        configLoad.load_cameras()
        configLoad.load_camera_config()
        configLoad.load_mode_config()

        result_to_show = []
        cam_without_person = []
        cam_onalarm = []
        unhandled_num = 0
        clean_flag = int(
            configLoad.globalConfig['count_config']['default']['cleanflag'])
        hidenotrunning_flag = int(configLoad.globalConfig['count_config']
                                  ['default']['hidenotrunningflag'])

        for camera in configLoad.globalConfig['cameras']:

            if camera.has_key(
                    'savedProgress') and camera['savedProgress'].strip() != '':
                cameradata = {}
                cameradata['uid'] = camera['uid']
                oneImage = camera['savedProgress']
                #Cam with people
                if os.path.exists(
                        camera['result_person_box_path'] +
                        oneImage.replace(source_flag, boundingbox_flag)):
                    resimage_path = camera[
                        'result_personarea_path'] + oneImage.replace(
                            source_flag, result_flag)
                    cameradata['image'] = resimage_path

                    frames = []
                    with open(camera['result_person_box_path'] +
                              oneImage.replace(source_flag, boundingbox_flag)
                              ) as fframes:
                        for line in fframes:
                            values = line.split(' ')
                            frames.append((int(values[0]), int(values[1]),
                                           int(values[2]), int(values[3]),
                                           float(values[4])))
                    cameradata['frames'] = frames
                    result_to_show.append(cameradata)
                #Cam without people
                elif clean_flag == 0:
                    resimage_path = camera['result_personarea_path'] + oneImage
                    cameradata['image'] = resimage_path
                    cam_without_person.append(cameradata)

                #Alert pics
                alertUnhandledFolder = 'camera/Alert/unhandled/'
                files = os.listdir(alertUnhandledFolder)
                for file in files:
                    if camera['uid'] + '_' + oneImage.replace(
                            source_flag, result_flag) in file:
                        cameraAlert = {}
                        cameraAlert['uid'] = camera['uid']
                        cameraAlert['path'] = alertUnhandledFolder + file
                        cam_onalarm.append(cameraAlert)
                        break

                #Unhandled pics number
                unhandled_num = len(files)

        result = [
            result_to_show, cam_without_person, clean_flag, cam_onalarm,
            hidenotrunning_flag, unhandled_num
        ]
        return render.mainpage(result)
Exemplo n.º 12
0
import maineval_voc
import time
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np
import boxTu
run=True;

net=maineval_voc.initNet();

source_flag=configLoad.source_flag;
result_flag=configLoad.result_flag;
boundingbox_flag=configLoad.boundingbox_flag

while run:
    configLoad.load_cameras();
    configLoad.load_camera_config();
    for camera in configLoad.globalConfig['cameras']:
        #check max number;
        #camera
        #
        frames_path=camera['frame_path'];
        if camera.has_key('savedProgress'):
            oneImage=CheckNewImage.get_last_new_image(frames_path,filter=source_flag,saved_progress=camera['savedProgress']);
        else:
            oneImage=CheckNewImage.get_last_new_image(frames_path,filter=source_flag);
        if oneImage=='':
            continue;
        originimage = Image.open(frames_path+'/'+oneImage)
        print 'dealing:' + oneImage
        midImage=maineval_voc.processImage(net,originimage)