Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyodbc
- from neuro import Neuro
- from frame import Frame
- server = '10.0.0.43'
- database = 'mb'
- username = 'usrMB'
- password = 'asdqaz'
- class Processing(object):
- def __init__(self, save_path, sqr_percent, classes):
- self.conn = pyodbc.connect('DSN=MSSQL;UID=usrMB;PWD=asdqaz')
- self.get_tasks = 'SELECT ID_task_for_analisis, ID_Request ' \
- 'FROM TasksForAnalisis WHERE id_type_processing = 1 AND Date_completed IS NULL'
- self.get_photo_video = 'SELECT is_photo, Link_Download, time_st, Time_fin, ID_Video FROM PhotoVideoRequests ' \
- 'WHERE ID_request = %s'
- self.update_detected_items = 'INSERT INTO DetectedItems(ID_Video, ID_task_for_analisis, ID_Type_item, ' \
- 'X_top_right, Y_top_right, X_bottom_left, Y_bottom_left, Date_add) ' \
- 'VALUES (%s,%s,%s,%s,%s,%s,%s,%s)'
- self.update_event_alarm = ''
- self.update_task_for_analisis_date_completed = 'UPDATE TasksForAnalisis SET ' \
- 'Date_comleted = CONVERT(time, SYSDATETIME())' \
- ' WHERE ID_task_for_analisis = %s'
- def process(self):
- cursor = self.conn.cursor()
- cursor.execute(self.get_tasks)
- results = cursor.fetchall()
- for result in results:
- print("TasksForAnalisis field:", result)
- task_id, request_id = result[0], result[1]
- # get photo_video
- cursor.execute(self.get_photo_video % request_id)
- photo_videos = cursor.fetchall()
- for photo_video in photo_videos:
- is_photo, link_for_download, time_start, time_end, video_id = photo_video[0], photo_video[1], \
- photo_video[2], photo_video[3], \
- photo_video[4]
- # download file by link... #image_path, save_path, interest_zones=None, yolo_thresh=0.13, sqr_percent=40
- images, frames = Frame.image_treatment(image_path, self.save_path, interest_zones, yolo_thresh,
- self.sqr_percent)
- print("images:", images)
- print('frames:', frames)
- alarm = 0
- for i in range(len(images)):
- p = self.neuro_network.predict(images[i])
- print('predict:', p, self.neuro_network.get_real_class_name_by_number(p))
- if self.neuro_network.is_alarm_class(p):
- alarm = 1
- if self.neuro_network.get_real_class_name_by_number(p) in self.classes:
- continue
- type_object_id = self.neuro_network.our_class_db_mapper(p)
- insert = self.update_detected_items % (video_id, task_id, type_object_id, frames[i][0],
- frames[i][1], frames[i][2], frames[i][3])
- cursor.execute(insert)
- self.conn.commit()
- cursor.execute(self.update_task_for_analisis_date_completed % task_id)
- self.conn.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement