当前位置:网站首页>Transferring images using flask
Transferring images using flask
2022-07-03 05:16:00 【Qianyu QY】
client :
import requests
import os
import cv2
import time
import base64
url = "http://180.201.5.153:1212"
filename = '13_rgb.png'
start_time = time.time()
# Read images
img = cv2.imread(filename)
# The encoded image is bytes
success, encoded_image = cv2.imencode(".jpg", img)
img_bytes = encoded_image.tobytes()
img_bytes = base64.b64encode(img_bytes)
img_bytes = img_bytes.decode('ascii')
# Upload image Waiting for feedback
data = {
'img': img_bytes}
r = requests.post(url, data=data)
result = r.text
print(result)
sum_t = time.time() - start_time
print('sum time: ', sum_t)
Server side
# -*- coding: UTF-8 -*-
from flask import request, Flask
import os
import cv2
import torch
import base64
import math
import numpy as np
from sgdn.sgdn import SGDN
app = Flask(__name__)
@app.route("/", methods=['POST'])
def get_frame():
img = request.form.get('img')
if img:
# Decode image data
img = base64.b64decode(img.encode('ascii'))
image_data = np.fromstring(img, np.uint8)
image_data = cv2.imdecode(image_data, cv2.IMREAD_COLOR)
print(image_data.shape)
cv2.imwrite('/home/wangdx/research/mir_robot/grasp_server/1.png', image_data)
toClient = str({
'cls': 1})
print("success")
return toClient
else:
return 'failed'
if __name__ == "__main__":
app.run("0.0.0.0", port=1212)
边栏推荐
- Covering Safari and edge, almost all mainstream browsers have realized webgl 2.0 support
- Introduction to deep learning - definition Introduction (I)
- [set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)
- 音频焦点系列:手写一个demo理解音频焦点与AudioMananger
- Detailed explanation of yolov5 training own data set
- [backtrader source code analysis 5] rewrite several time number conversion functions in utils with Python
- Go language interface learning notes Continued
- Problems encountered in fuzzy query of SQL statements
- Interview question -- output the same characters in two character arrays
- "Hands on deep learning" pytorch edition Chapter II exercise
猜你喜欢

BIO、NIO、AIO区别

JQ style, element operation, effect, filtering method and transformation, event object

Burp suite plug-in based on actual combat uses tips

Yolov5 model construction source code details | CSDN creation punch in
![[research materials] annual report of China's pension market in 2021 - Download attached](/img/24/622aeeb38de16ac84128b362ceeddb.jpg)
[research materials] annual report of China's pension market in 2021 - Download attached

【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)

Gbase8s unique index and non unique index

Appium 1.22. L'Inspecteur appium après la version X doit être installé séparément

谷歌 | 蛋白序列的深度嵌入和比对

(subplots usage) Matplotlib how to draw multiple subgraphs (axis field)
随机推荐
Shuttle + alluxio accelerated memory shuffle take-off
Common methods of JS array
Make your own dataset
Redis expiration elimination mechanism
Go practice -- closures in golang (anonymous functions, closures)
[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)
"Hands on deep learning" pytorch edition Chapter II exercise
(subplots用法)matplotlib如何绘制多个子图(轴域)
Notes | numpy-10 Iterative array
【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)
Yolov5 network structure + code + application details | CSDN creation punch in
Webrtc protocol introduction -- an article to understand ice, stun, NAT, turn
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
Notes | numpy-08 Advanced index
Redis Introduction et explication des types de données
Web APIs exclusivity
Go practice -- use JWT (JSON web token) in golang
[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
Basic knowledge of reflection (detailed explanation)
Why is go language particularly popular in China