finish detector

This commit is contained in:
Siwat Sirichai 2023-09-23 02:12:07 +07:00
parent d067ba3ac8
commit 5702af8c36
3 changed files with 8 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -3,21 +3,23 @@ import cv2
import base64 import base64
import requests import requests
#Capture Image # #Capture Image
cam = cv2.VideoCapture(0) # cam = cv2.VideoCapture(0)
ret, img = cam.read() # ret, img = cam.read()
#Save Image # #Save Image
cv2.imwrite("cam_test_img_pre.jpg",img) # cv2.imwrite("cam_test_img_pre.jpg",img)
img = cv2.imread("cam_test_img_pre.jpg")
#Encode Image #Encode Image
ret, jpg_buffer = cv2.imencode('.jpg',img) ret, jpg_buffer = cv2.imencode('.jpg',img)
b64_img = base64.b64encode(jpg_buffer) b64_img = base64.b64encode(jpg_buffer)
print(b64_img)
#Send Image to Server #Send Image to Server
data = {"image":b64_img.decode("utf-8")} data = {"image":b64_img.decode("utf-8")}
req = requests.post("http://localhost:5000/process_image",json=data) req = requests.post("http://localhost:5000/process_image",json=data)
print(req.content)
#Decode Image #Decode Image
img_nparr = np.frombuffer(base64.b64decode(b64_img),np.uint8) img_nparr = np.frombuffer(base64.b64decode(b64_img),np.uint8)