server
This commit is contained in:
parent
9e990d1b81
commit
b852a340ca
Binary file not shown.
After Width: | Height: | Size: 103 KiB |
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
|
@ -1,10 +1,26 @@
|
|||
import numpy as np
|
||||
import cv2
|
||||
import os
|
||||
import base64
|
||||
import requests
|
||||
|
||||
#Capture Image
|
||||
cam = cv2.VideoCapture(0)
|
||||
ret, img = cam.read()
|
||||
|
||||
ret, frame = cam.read()
|
||||
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
||||
#Save Image
|
||||
cv2.imwrite("cam_test_img_pre.jpg",img)
|
||||
|
||||
#Encode Image
|
||||
ret, jpg_buffer = cv2.imencode('.jpg',img)
|
||||
b64_img = base64.b64encode(jpg_buffer)
|
||||
print(b64_img)
|
||||
|
||||
#Send Image to Server
|
||||
data = {"image":b64_img.decode("utf-8")}
|
||||
req = requests.post("http://localhost:5000/process_image",json=data)
|
||||
|
||||
#Decode Image
|
||||
img_nparr = np.frombuffer(base64.b64decode(b64_img),np.uint8)
|
||||
img = cv2.imdecode(img_nparr,cv2.IMREAD_COLOR)
|
||||
cv2.imwrite("cam_test_img_post.jpg",img)
|
||||
|
||||
cv2.imwrite("cam_test_img.jpg",img)
|
|
@ -1,3 +1,4 @@
|
|||
pyserial
|
||||
line_notify
|
||||
opencv-python
|
||||
requests
|
|
@ -0,0 +1,27 @@
|
|||
from flask import Flask, request
|
||||
import json
|
||||
import cv2
|
||||
import base64
|
||||
import numpy as np
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
return '<h1>Ching Chong Bing Bong Ding Dong!!</h1>'
|
||||
|
||||
|
||||
@app.route('/process_image', methods=['POST'])
|
||||
def process_image():
|
||||
print(request.data)
|
||||
request_data = json.loads(request.data.decode("utf-8"))
|
||||
img_nparr = np.frombuffer(base64.b64decode(request_data['image']), np.uint8)
|
||||
img = cv2.imdecode(img_nparr,cv2.IMREAD_COLOR)
|
||||
cv2.imwrite("retrieved_img.jpg",img)
|
||||
print(request_data)
|
||||
return "Bing Bong!"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
|
@ -0,0 +1,3 @@
|
|||
flask
|
||||
opencv-python
|
||||
deepface
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"listeners": {
|
||||
"*:80": {
|
||||
"pass": "routes"
|
||||
}
|
||||
},
|
||||
"routes": [{
|
||||
"match": {
|
||||
"uri": "*"
|
||||
},
|
||||
"action": {
|
||||
"pass": "applications/racist_application"
|
||||
}
|
||||
}],
|
||||
"applications": {
|
||||
"racist_application": {
|
||||
"type": "python",
|
||||
"processes": 10,
|
||||
"working_directory": "/www/store/cart/",
|
||||
"path": "/www/store/",
|
||||
"home": ".virtualenv/",
|
||||
"module": "cart.run"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue