+ global count
+ labels = "bottles"
+ process_this_frame = 0
+ while True:
+ success, frame = video_capture.get_frame()
+ if not success:
+ break
+ if process_this_frame == 0:
+ url = config.detection_url + "/v1/obj_detection/detect"
+ # info1 = cv2.imencode(".jpg", rgb_small_frame)[1].tobytes()
+ data = json.loads(requests.post(url, data=frame,
+ verify=config.ssl_cacertpath).text)
+ inven_info = inventry_info()
+ current_count = data[count]
+ labels = data[labels]
+ total_count = inven_info.current_count + inven_info.total_count
+ inven_info.setcurrentcount(current_count)
+ inven_info.settotalcount(total_count)
+ inven_info.setlabel(labels)
+ inven_info.utime = time.time()
+ store_data(inven_info)
+
+
+def store_info_db(inven_info):
+ """
+ Send "shelf" data to InfluxDB
+
+ :param inven_info: Inventry object
+ :return: None
+ """
+ global db_client
+ json_body = [
+ {
+ "measurement": inven_info.type,
+ "tags": {
+ "object": "bottles",
+ },
+ "fields": {
+ "time": inven_info.time,
+ "Current Count": inven_info.current_count,
+ "Total Count": inven_info.total_count,
+ }
+ }]
+ db_client.write_points(json_body)
+
+
+def create_database():
+ """
+ Connect to InfluxDB and create the database
+
+ :return: None
+ """
+ global db_client
+
+ proxy = {"http": "http://{}:{}".format(config.IPADDRESS, config.PORT)}
+ db_client = InfluxDBClient(host=config.IPADDRESS, port=config.PORT,
+ proxies=proxy, database=config.DATABASE_NAME)
+ db_client.create_database(config.DATABASE_NAME)