+ self.video.release()
+
+ def get_frame(self):
+ """
+ get a frane from stream
+ """
+ success, image = self.video.read()
+ return success, image
+
+
+def shelf_inventory(video_capture, camera_info, true=None):
+ """
+ shelf_inventory
+ """
+ global count
+ global mock_func
+
+ labels = "Bottles"
+ count_val = 'ObjCount'
+ process_this_frame = 0
+ i = 0
+ url = config.detection_url + "detect"
+ url_get = config.detection_url + "image"
+
+ while True:
+ success, frame = video_capture.get_frame()
+ if not success:
+ print('read frame from file is failed')
+ break
+
+ i = i+1
+ if i < 10:
+ continue
+
+ i = 0
+
+ if process_this_frame == 0:
+ imencoded = cv2.imencode(".jpg", frame)[1]
+ file = {'file': (
+ 'image.jpg', imencoded.tostring(), 'image/jpeg',
+ {'Expires': '0'})}
+ res = requests.post(url, files=file)
+ data = json.loads(res.text)
+
+ # get image
+ response = requests.get(url_get)
+
+ file = open(app.config['UPLOAD_PATH'] + "sample_image.jpg", "wb")
+ file.write(response.content)
+ file.close()
+
+ inven_info = inventory_info()
+ current_count = data[count_val]
+ if (current_count >= 3):
+ status = "Mostly Filled"
+ elif (current_count == 2):
+ status = "Partially Filled"
+ else:
+ status = "Needs Filling"
+
+ inven_info.setlabel(labels)
+ inven_info.setstatus(status)
+ inven_info.setcurrentCount(current_count)
+ time_sec = time.time()
+ local_time = time.ctime(time_sec)
+ inven_info.time = local_time
+ store_info_db(inven_info)
+ time.sleep(0.30)
+
+
+def db_drop_table(inven_info):
+ """
+ cleanup measrurment before new trigger
+
+ :param inven_info: inven_info object
+ :return: None
+ """
+ global db_client
+ db_client.drop_measurement(inven_info.type)
+
+
+def store_info_db(inven_info):