当前位置:网站首页>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)
边栏推荐
- Go language interface learning notes
- 1111 online map (30 points)
- Promise
- RT thread flow notes I startup, schedule, thread
- 112 stucked keyboard (20 points)
- 编译GCC遇到的“pthread.h” not found问题
- Audio Focus Series: write a demo to understand audio focus and audiomananger
- es7创建索引容易犯的错误
- Redis Introduction et explication des types de données
- [set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)
猜你喜欢

Actual combat 8051 drives 8-bit nixie tube

Intégration profonde et alignement des séquences de protéines Google

Yolov5 model construction source code details | CSDN creation punch in

leetcode860. Lemonade change

Class loading mechanism (detailed explanation of the whole process)

Pessimistic lock and optimistic lock of multithreading

Online VR model display - 3D visual display solution

Technical analysis of qianyuantong multi card aggregation router

Go practice - gorilla / handlers used by gorilla web Toolkit

"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
随机推荐
Bluebridge cup real topic 2020 palindrome date simulation construction provincial competition
5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip
XML Configuration File
appium1.22. Appium inspector after X version needs to be installed separately
Skip table: principle introduction, advantages and disadvantages of skiplist
leetcode860. Lemonade change
[practical project] autonomous web server
Redis expiration elimination mechanism
酒店公共广播背景音乐-基于互联网+的酒店IP网络广播系统设计
Actual combat 8051 drives 8-bit nixie tube
[research materials] annual report of China's pension market in 2021 - Download attached
1099 build a binary search tree (30 points)
1094 the largest generation (25 points)
最大连续子段和(动态规划,递归,递推)
How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
穀歌 | 蛋白序列的深度嵌入和比對
Shallow and first code
appium1.22.x 版本後的 appium inspector 需單獨安裝
1119 pre- and post order traversals (30 points)
[research materials] 2022q1 game preferred casual game distribution circular - Download attached