Esempio n. 1
0
def getloglist():

    filename = '../conf/server.txt'
    fileHandle = open(filename, 'r')

    loglist = []
    for line in fileHandle:
        conf = line.split(',')
        length = len(conf)
        if (length >= 5):
            try:
                ser = log.LOG()
                ser.host = conf[0]
                ser.path = conf[1]
                ser.filename = conf[2]
                ser.user = conf[3]
                ser.password = conf[4]
                loglist.append(ser)
            except IndexError:
                print "list index out of range!"
        else:
            print line + " Error, information is not enough!"

    fileHandle.close()

    return loglist
 def __init__(self, json_file_folder_path, all_file_list, state):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True)
     if state == "create_excel":
         self.__read_id_and_timestamp_from_id_json_files(
             json_file_folder_path, all_file_list)
     self.pym.PY_LOG(False, 'D', self.__log_name, 'init finished')
 def __init__(self, target_path):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True)
     self.target_path = ""
     if os.path.exists(target_path):
         self.__target_path = target_path
         self.pym.PY_LOG(False, 'D', self.__class__, 'traget_path: %s is existed' % target_path)
     else:
         self.pym.PY_LOG(False, 'E', self.__class__, 'traget_path: %s is not existed!!' % target_path)
Esempio n. 4
0
 def __init__(self, file_path):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True)
     self.file_path = ""
     if os.path.exists(file_path):
         self.file_path = file_path
         self.pym.PY_LOG(False, 'D', self.__class__,
                         '%s existed!' % file_path)
     else:
         self.pym.PY_LOG(False, 'E', self.__class__,
                         '%s is not existed!' % file_path)
 def __init__(self, fm_process_que, td_que, shm_name, shm_size):
     self.__set_font.config(family='courier new', size=15)
     threading.Thread.__init__(self)
     self.fm_process_queue = fm_process_que
     self.td_queue = td_que
     self.pym = PYM.LOG(True)
     self.shm_id = shared_memory.ShareableList(name=shm_name)
     self.__interval = 1 
     self.__sys_file = None
     self.__cur_target_index = 0
     self.__this_round_end_index = 0
     self.pym.PY_LOG(False, 'D', self.__log_name, 'init finished')
Esempio n. 6
0
 def __init__(self, target_path, file_path, label_id):
     #below(True) = exports log.txt
     self.pym = PYM.LOG(True)
     self.__target_path = target_path
     self.pym.PY_LOG(False, 'D', self.__log_name,
                     'target_path: %s' % target_path)
     self.__track_data_path = target_path + "track_data.json"
     self.pym.PY_LOG(False, 'D', self.__log_name,
                     'track_data.json path: %s' % self.__track_data_path)
     if os.path.exists(self.__track_data_path):
         os.remove(self.__track_data_path)
     self.__file_path = file_path
     self.__label_id = label_id
Esempio n. 7
0
    def __init__(self, algorithm, video_path, label_object_time_in_video, bbox,
                 image_debug, ROI_get_bbox):
        # below(True) = exports log.txt
        self.pym = PYM.LOG(True)

        # 1. make sure video is existed
        self.__video_cap = cv2.VideoCapture(video_path)
        if not self.__video_cap.isOpened():
            self.pym.PY_LOG(False, 'E', self.__class__, 'open video failed!!.')
            sys.exit()

        # 2. reading video strat time at the time that user using VoTT to label trakc object
        # *1000 because CAP_PROP_POS_MESE is millisecond
        self.__video_cap.set(cv2.CAP_PROP_POS_MSEC,
                             label_object_time_in_video * 1000)
        # ex: start time at 50s
        #self.video_cap.set(cv2.CAP_PROP_POS_MSEC, 50000)
        #self.video_cap.set(cv2.CAP_PROP_FPS, 15)  #set fps to change video,but not working!!

        # 3. setting tracker algorithm and init
        self.__tracker = self.__get_algorithm_tracker(algorithm)
        self.pym.PY_LOG(False, 'D', self.__class__,
                        'VoTT_CV_TRACKER initial ok')
        frame = self.capture_video_frame()

        if ROI_get_bbox:
            bbox = self.use_ROI_select('ROI_select', frame)

        self.__tracker.init(frame, bbox)
        self.pym.PY_LOG(False, 'D', self.__class__,
                        'openCV tracker initial ok')

        # 4. for debuging
        self.__image_debug[IMAGE_DEBUG.SW_VWB.value] = image_debug[0]
        self.__image_debug[IMAGE_DEBUG.SE_IWB.value] = image_debug[1]
        self.__image_debug[IMAGE_DEBUG.SE_VWB.value] = image_debug[2]
        if self.__image_debug[IMAGE_DEBUG.SW_VWB.value] == 1 or \
           self.__image_debug[IMAGE_DEBUG.SE_IWB.value] == 1 or \
           self.__image_debug[IMAGE_DEBUG.SE_VWB.value] == 1 :
            self.window_name = 'debug'
            cv2.namedWindow(self.window_name, cv2.WINDOW_NORMAL)
            cv2.resizeWindow(self.window_name, 1280, 720)

        # 5. just show video format information
        self.show_video_format_info()

        self.pym.PY_LOG(False, 'D', self.__class__,
                        'VoTT_CV_TRACKER initial ok')
Esempio n. 8
0
 def __init__(self, video_path, vott_set_fps, frame_size, debug_img_path,
              debug_img_sw):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True)
     self.__video_path = video_path
     self.__vott_video_fps = vott_set_fps
     self.__frame_size = []
     self.__frame_size = frame_size
     self.__debug_img_path = debug_img_path
     self.__debug_img_sw = debug_img_sw
     self.__init_super_resolution()
     self.sift = cv2.xfeatures2d.SIFT_create(1000)
     self.init_for_next_round()
     self.__SIFT_feature_match_point = []
     self.__SIFT_feature_match_ids = []
     self.__final_predict_ids = []
Esempio n. 9
0
 def __init__(self):
     '''
     Constructor
     '''
     self.logger = log.LOG().getlogger()
Esempio n. 10
0
def LOG(text: str, level: int = 3):
    log.LOG('\033[5;30;43m<' + text + '>\033[0m', level)
 def __init__(self, target_path):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True)
     self.__target_path = target_path
Esempio n. 12
0
while True:
    try:
        if array_length < array_new_length: #if new data came in
            if array[len(array)-1] == "ok": #if it's an "ok" then go to a new line
                print ("")
                print len(array)
                print ("array_length = "), array_length
                print ("array_new_length = "), array_new_length
                array_length = array_new_length
            elif array[len(array)-1] == "TURN LED ON PLZ": #if it's a LED ON request
                logint = 1
                print ("TURNING ON THE LED")
                array_length = array_new_length
                LED.LEDON() #execute LEDON() function from LED.py
                log.LOG(logint)
                with open("/home/pi/Desktop/mosquitto_logs.txt", "a") as ins:
                    ins.write('ok\n')
            elif array[len(array)-1] == "TAKE A SELFIE": #if it's a selfie request
                logint = 2
                print ("TAKING A SELFIE")
                camera.CAMERA() #execute CAMERA() function from camera.py
                log.LOG(logint)
                array_length = array_new_length
                print ("COMPRESSING SELFIE")
                compress.COMPRESS() #execute COMPRESS() function from compress.py
                print ("SELFIE COMPRESSED")
                print ("UPLOADING SELFIE")
                upload.UPLOAD() #execute UPLOAD() function from upload.py
                logint = 3
                log.LOG(logint)
Esempio n. 13
0
 def __init__(self):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True)
Esempio n. 14
0
    # below target_path will be wrong!!!
    target_path = video_path.replace("Drone_Source", "Drone_Target")
    l1 = target_path.find("Drone_Target")
    l2 = l1 + len("Drone_Target/")
    temp_path = target_path[l2:]
    l3 = temp_path.find('/')
    last_dir_path = temp_path[:l3]
    target_path = target_path[:l2] + last_dir_path + '/'
    pym.PY_LOG(False, 'D', py_name, 'target_path: %s' % target_path)
    json_file_path = target_path + file_name
    pym.PY_LOG(False, 'D', py_name, 'json_file_path: %s' % json_file_path)
    return video_path, target_path, json_file_path


if __name__ == '__main__':
    # below(True) = exports log.txt
    pym = PYM.LOG(True)

    target_path = '../../Drone_Target/for_python_path.log'
    video_path, target_path, json_file_path = read_file_name_path(target_path)
    #if len(sys.argv[1]) > 1:
    #file_path = file_path + sys.argv[1]
    #print("file_path: %s" % file_path)
    #if len(sys.argv[2]) > 1:
    #algorithm = sys.argv[2]
    #print(algorithm)

    arrived_next_frame = False
    algorithm = 'CSRT'
    main(target_path, json_file_path, video_path, algorithm)
Esempio n. 15
0
    def __init__(self, td_que, fm_process_que):

        self.__amount_of_cur_people = 0
        self.__amount_of_next_people = 0

        self.__init_shared_memory(0)

        self.__process_working = False

        self.__interval = 1

        self.__set_font.config(family='courier new', size=10)
        self.td_queue = td_que
        self.fm_process_queue = fm_process_que
        self.pym = PYM.LOG(True)
        matplotlib.use('TkAgg')

        os_name = self.which_os()
        self.pym.PY_LOG(False, 'D', self.__log_name, 'OS:' + '%s' % os_name)
        self.pym.PY_LOG(False, 'D', self.__log_name,
                        'screenwidth:%d' % self.__root.winfo_screenwidth())
        self.pym.PY_LOG(False, 'D', self.__log_name,
                        'screenheight:%d' % self.__root.winfo_screenheight())

        if os_name == 'Linux':
            #規定窗口大小
            #self.__root.geometry('2000x2000')
            #self.__root.resizable(width = False, height = False)   # 固定长宽不可拉伸
            self.__root.attributes('-zoomed', True)
        elif os_name == 'Windows':
            #self.__root.resizable(width = False, height = False)   # 固定长宽不可拉伸
            self.__root.state('zoomed')
            #self.__root.state('normal')

        self.__root.title("修正 VoTT json file 內的人物ID 版號:" + self.__version)
        self.figure, self.ax = plt.subplots(1, 1, figsize=(16, 8))
        self.pym.PY_LOG(False, 'D', self.__log_name,
                        'self.figure:' + '%s' % self.figure)
        self.__image_logo = Image.open(self.__logo_path)
        plt.imshow(self.__image_logo)
        plt.axis('off')

        #放置標籤
        self.label1 = Tk.Label(self.__root,
                               text='下方會顯示比對的ID人物表',
                               image=None,
                               font=self.__set_font)  #創建一個標籤
        self.label2 = Tk.Label(self.__root,
                               text='處理狀態',
                               image=None,
                               font=self.__set_font)  #創建一個標籤
        self.label2 = Tk.Label(self.__root,
                               text='system state',
                               image=None,
                               font=self.__set_font)  #創建一個標籤
        self.label1.pack()
        self.label2.pack()

        #把繪製的圖形顯示到tkinter視窗上
        self.canvas_draw()

        # list_box
        sc = Tk.Scrollbar(self.__root)
        #sc.pack(side=Tk.RIGHT,fill=Tk.Y)
        self.list_box = Tk.Listbox(self.__root, yscrollcommand=sc.set)
        #self.list_box.pack(side=Tk.TOP, fill=Tk.BOTH, expand=True)
        #self.list_box.pack(side=Tk.LEFT)
        self.list_box.place(width=100, height=800, x=0, y=0)
        self.list_box.insert(1, '==cur_id_list==')

        #把matplotlib繪製圖形的導航工具欄顯示到tkinter視窗上
        toolbar = NavigationToolbar2TkAgg(self.__canvas, self.__root)
        toolbar.update()
        self.__canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.__init_buttons()
        '''
        self.WKU_queue = queue.Queue()
        self.TDU_queue = queue.Queue()
        self.wk = Worker(self.td_queue, self.WKU_queue, self.TDU_queue)
        self.wk.start()
        '''
        self.__root.protocol("WM_DELETE_WINDOW", self.system_quit)

        # entry box for check sec settings
        # max=5 , min=1
        self.check_interval_label = Tk.Label(self.__root,
                                             font=self.__set_font,
                                             text="check interval(sec):")
        self.check_interval_label.place(
            width=400,
            height=30,
            x=self.__root.winfo_screenwidth() / 200,
            y=self.__root.winfo_screenheight() - 180)
        self.entry_check_interval = Tk.Entry(self.__root,
                                             bd=2,
                                             font=self.__set_font)
        #self.entry_check_interval.pack(side = Tk.LEFT)
        self.entry_check_interval.place(
            width=50,
            height=30,
            x=self.__root.winfo_screenwidth() / 200 + 420,
            y=self.__root.winfo_screenheight() - 180)
        #self.entry_check_interval.pack(side = Tk.LEFT)
        self.entry_check_interval.insert(0, "1")

        # load json from specify time,part of >
        self.entry_less_json_time = Tk.Entry(self.__root,
                                             bd=2,
                                             font=self.__set_font)
        self.entry_less_json_time.place(
            width=100,
            height=30,
            x=self.__root.winfo_screenwidth() / 200 + 400,
            y=self.__root.winfo_screenheight() - 230)
        self.entry_less_json_time.insert(0, "1")

        # load json from specify time,part of <
        self.entry_equal_json_time = Tk.Entry(self.__root,
                                              bd=2,
                                              font=self.__set_font)
        self.entry_equal_json_time.place(
            width=100,
            height=30,
            x=self.__root.winfo_screenwidth() / 200,
            y=self.__root.winfo_screenheight() - 230)
        self.entry_equal_json_time.insert(0, "0")
Esempio n. 16
0
 def __init__(self, video_path):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True) 
     self.__video_path = video_path 
Esempio n. 17
0
 def on_clicked_log(self):
     print("log")
     log.LOG()
Esempio n. 18
0
import json
import random
import codecs
from patent import Patent
from spider import SoopatSpider
from parser import Parser
from downloader import Downloader
from optparse import OptionParser
from argparse import ArgumentParser

__DESCRIPTION__ = "soopat tool, to parse soopat content and write to noteexpress style"
__VERSION__ = 0.2
__CONTACT__ = 'For more information, please contact [email protected]'

logfile = 'soopt_downloader.log'
logger = log.LOG(logfile).getlogger()


def get_patent_page_num(search_result_num, default_page_num=5):
    page_size = 10
    real_page_num = (search_result_num + page_size / 2) / page_size

    if real_page_num < default_page_num:
        return real_page_num
    else:
        return default_page_num


def get_page_patents(keyword, page_num):
    patent_index = page_num * 10
    spider = SoopatSpider()
Esempio n. 19
0
 def __init__(self, file_path):
     # below(True) = exports log.txt
     self.pym = PYM.LOG(True)
     self.__file_path = file_path
Esempio n. 20
0
 def on_clicked_log(self):
     log.LOG()
Esempio n. 21
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
create_author : Bilery Zoo([email protected])
create_time   : 2019-06-09
program       : *_* MySQL/MariaDB handler utility *_*
"""

import sys
import typing

import baseutil

import log

logger = log.LOG().logger()

c_flag = False
try:
    import _mysql_connector
except ModuleNotFoundError:
    logger.warning(
        'Import "_mysql_connector" failed, fall back to strictly use "mysql.connector"...'
    )
else:
    c_flag = True
finally:
    import mysql.connector

DBException = _mysql_connector.MySQLInterfaceError if c_flag else mysql.connector.errors.Error