当前位置:网站首页>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)
边栏推荐
- Bluebridge cup real topic 2020 palindrome date simulation construction provincial competition
- 1115 counting nodes in a BST (30 points)
- Configure and use Anaconda environment in pycharm
- Yolov5 network structure + code + application details | CSDN creation punch in
- BIO、NIO、AIO区别
- appium1.22.x 版本后的 appium inspector 需单独安装
- Pessimistic lock and optimistic lock of multithreading
- Ueditor, FCKeditor, kindeditor editor vulnerability
- Appium 1.22. L'Inspecteur appium après la version X doit être installé séparément
- 1086 tree traversals again (25 points)
猜你喜欢

Compile and decompile GCC common instructions

leetcode435. Non overlapping interval

Congratulations to musk and NADELLA on their election as academicians of the American Academy of engineering, and Zhang Hongjiang and Fang daining on their election as foreign academicians

Pan details of deep learning

Source insight garbled code solution

Yolov5 model construction source code details | CSDN creation punch in

Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis

College campus IP network broadcasting - manufacturer's design guide for college campus IP broadcasting scheme based on campus LAN

Gbase8s unique index and non unique index

Webrtc M96 release notes (SDP abolishes Plan B and supports opus red redundant coding)
随机推荐
Yolov5 model construction source code details | CSDN creation punch in
"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
1086 tree traversals again (25 points)
XML配置文件
appium1.22.x 版本后的 appium inspector 需单独安装
Hotel public broadcasting background music - Design of hotel IP network broadcasting system based on Internet +
Gbase8s composite index (I)
Force GCC to compile 32-bit programs on 64 bit platform
JS function algorithm interview case
Three representations of signed numbers: original code, inverse code and complement code
1106 lowest price in supply chain (25 points)
2022-02-12 daily clock in: problem fine brush
[research materials] annual report of China's pension market in 2021 - Download attached
Webapidom get page elements
Notes | numpy-11 Array operation
Yolov5 input (I) -- mosaic data enhancement | CSDN creative punch in
2022-02-11 daily clock in: problem fine brush
Skip table: principle introduction, advantages and disadvantages of skiplist
Go practice -- use JWT (JSON web token) in golang
Source insight garbled code solution