当前位置:网站首页>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)
边栏推荐
- 在PyCharm中配置使用Anaconda环境
- "250000 a year is just the price of cabbage" has become a thing of the past. The annual salary of AI posts has decreased by 8.9%, and the latest salary report has been released
- Redis breakdown penetration avalanche
- Actual combat 8051 drives 8-bit nixie tube
- 2022-02-11 daily clock in: problem fine brush
- The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
- [basic grammar] Snake game written in C language
- Interview question -- output the same characters in two character arrays
- Maximum continuous sub segment sum (dynamic programming, recursive, recursive)
- Pan details of deep learning
猜你喜欢

(完美解决)matplotlib图例(legend)如何自由设置其位置

穀歌 | 蛋白序列的深度嵌入和比對

乾元通多卡聚合路由器的技术解析
![[practical project] autonomous web server](/img/99/892e600b7203c63bad02adb683c8f2.png)
[practical project] autonomous web server

Handler understands the record

Oracle SQL table data loss

Primary school campus IP network broadcasting - Design of primary school IP digital broadcasting system based on campus LAN

Promise

Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis

How to connect the network: Chapter 1 CSDN creation punch in
随机推荐
Gbase8s unique index and non unique index
Dynamic programming - related concepts, (tower problem)
Redis 过期淘汰机制
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology
聊聊如何利用p6spy进行sql监控
JS string and array methods
Yolov5 network structure + code + application details | CSDN creation punch in
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
1107 social clusters (30 points)
How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
How to connect the network: Chapter 1 CSDN creation punch in
2022-02-11 daily clock in: problem fine brush
Webrtc M96 release notes (SDP abolishes Plan B and supports opus red redundant coding)
Introduction to webrtc protocol -- an article to understand dtls, SRTP, srtcp
Notes | numpy-10 Iterative array
最大连续子段和(动态规划,递归,递推)
1115 counting nodes in a BST (30 points)
Introduction to deep learning (II) -- univariate linear regression
ES7 easy mistakes in index creation
Handler understands the record