- if mock_func == 1:
- inven_info = inventory_info()
- mock_table(inven_info)
- else:
- 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 = inventory_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)
- local_store(inven_info)
-
-
-def local_store(inven_info):
+ 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):