Advertisement
Guest User

Untitled

a guest
Apr 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. import pyodbc
  2. #from neuro import Neuro
  3.  
  4.  
  5. server = '10.0.0.43'
  6. database = 'mb'
  7. username = 'usrMB'
  8. password = 'asdqaz'
  9.  
  10.  
  11. class Processing(object):
  12. def __init__(self, image_path, save_path, sqr_percent):
  13. self.save_path = save_path
  14. self.image_path = image_path
  15. self.sqr_percent = sqr_percent
  16.  
  17. self.conn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
  18.  
  19. self.cam_zone_command = "SELECT id_cam, id_type_zone, sensitivity, x1, y1 ,x2, y2, x3, y3, x4, y4 " \
  20. "FROM CamZones WHERE id_cam = '%s' AND (" \
  21. "SELECT id_type_processing FROM TypesProcessingZone WHERE id_type_zone = '%s') = 1;"
  22.  
  23. self.sql_command = 'SELECT id, id_video, shopNo, date_add, id_cam, id_type_processing, data_processing, alarm ' \
  24. 'FROM TasksForAnalisis WHERE id_type_processing = 1'
  25.  
  26. self.update_task_alarm = "UPDATE TasksForAnalisis SET alarm = %s WHERE id = '%s'"
  27.  
  28. self.times_for_video = "SELECT link_download FROM times_for_video WHERE id = '%s'"
  29.  
  30. def close_connection(self):
  31. self.conn.close()
  32.  
  33.  
  34. def get_db_version(self):
  35. cursor = self.conn.cursor()
  36. cursor.execute("SELECT @@version;")
  37. row = cursor.fetchone()
  38. while row:
  39. print(row)
  40. break
  41.  
  42. def process(self):
  43. self.neuro_network = Neuro()
  44.  
  45. cursor = self.conn.cursor()
  46. cursor.execute(self.sql_command)
  47. results = cursor.fetchall()
  48. for result in results:
  49. print("MAIN:", result)
  50. cursor.execute(self.times_for_video % result[1])
  51. link_for_download = cursor.fetchone()[0]
  52. print('Link for download', link_for_download)
  53. #Frame.download_image(link_for_download, self.image_path)
  54.  
  55. interest_zones = []
  56. yolo_thresh = 0.13
  57.  
  58. cursor.execute(self.cam_zone_command % (result[1], result[5]))
  59. for row in cursor.fetchall():
  60. print('SUBQUERY:', row)
  61.  
  62. interest_zones.append(row[3])
  63. interest_zones.append(row[4])
  64. interest_zones.append(row[5])
  65. interest_zones.append(row[6])
  66.  
  67. interest_zones.append(row[7])
  68. interest_zones.append(row[8])
  69. interest_zones.append(row[9])
  70. interest_zones.append(row[10])
  71.  
  72. yolo_thresh = float(row[2])
  73. #images = Frame.image_treatment(self.image_path, self.save_path, interest_zones, yolo_thresh,
  74. # self.sqr_percent)
  75. #if neuro_network.predict_images_with_alarm(images):
  76. # cursor.execute(self.update_task_alarm % ('TRUE', result[0]))
  77.  
  78.  
  79. if __name__ == '__main__':
  80. p = Processing('.', '.', '.')
  81. p.get_db_version()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement