Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyodbc
- #from neuro import Neuro
- server = '10.0.0.43'
- database = 'mb'
- username = 'usrMB'
- password = 'asdqaz'
- class Processing(object):
- def __init__(self, image_path, save_path, sqr_percent):
- self.save_path = save_path
- self.image_path = image_path
- self.sqr_percent = sqr_percent
- self.conn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
- self.cam_zone_command = "SELECT id_cam, id_type_zone, sensitivity, x1, y1 ,x2, y2, x3, y3, x4, y4 " \
- "FROM CamZones WHERE id_cam = '%s' AND (" \
- "SELECT id_type_processing FROM TypesProcessingZone WHERE id_type_zone = '%s') = 1;"
- self.sql_command = 'SELECT id, id_video, shopNo, date_add, id_cam, id_type_processing, data_processing, alarm ' \
- 'FROM TasksForAnalisis WHERE id_type_processing = 1'
- self.update_task_alarm = "UPDATE TasksForAnalisis SET alarm = %s WHERE id = '%s'"
- self.times_for_video = "SELECT link_download FROM times_for_video WHERE id = '%s'"
- def close_connection(self):
- self.conn.close()
- def get_db_version(self):
- cursor = self.conn.cursor()
- cursor.execute("SELECT @@version;")
- row = cursor.fetchone()
- while row:
- print(row)
- break
- def process(self):
- self.neuro_network = Neuro()
- cursor = self.conn.cursor()
- cursor.execute(self.sql_command)
- results = cursor.fetchall()
- for result in results:
- print("MAIN:", result)
- cursor.execute(self.times_for_video % result[1])
- link_for_download = cursor.fetchone()[0]
- print('Link for download', link_for_download)
- #Frame.download_image(link_for_download, self.image_path)
- interest_zones = []
- yolo_thresh = 0.13
- cursor.execute(self.cam_zone_command % (result[1], result[5]))
- for row in cursor.fetchall():
- print('SUBQUERY:', row)
- interest_zones.append(row[3])
- interest_zones.append(row[4])
- interest_zones.append(row[5])
- interest_zones.append(row[6])
- interest_zones.append(row[7])
- interest_zones.append(row[8])
- interest_zones.append(row[9])
- interest_zones.append(row[10])
- yolo_thresh = float(row[2])
- #images = Frame.image_treatment(self.image_path, self.save_path, interest_zones, yolo_thresh,
- # self.sqr_percent)
- #if neuro_network.predict_images_with_alarm(images):
- # cursor.execute(self.update_task_alarm % ('TRUE', result[0]))
- if __name__ == '__main__':
- p = Processing('.', '.', '.')
- p.get_db_version()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement