Я хочу захватить изображение с помощью камеры Raspberry Pi и отправить это изображение в мое приложение для Android через подключение к каналу Bluetooth RFCOMM ... Я отправляю изображение в байтах из сценария Python, но я не знаю, как его получить это в Android как байты и отображать его в виде изображения ???
Я пытаюсь получить строку и успех в ней, но я не знаю, как получить изображение в приложении для Android ???
это мой скрипт на python, есть предложения в андроиде, пожалуйста ??
import os
import picamera
import lightblue
import glob
import time
import RPi.GPIO as GPIO
from bluetooth import *
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(23,GPIO.IN)
GPIO.setup(25,GPIO.IN)
GPIO.setup(24,GPIO.OUT)
camera=picamera.PiCamera()
prev_input=0
input1=GPIO.input(23)
input2=GPIO.input(25)
connection=False
server_sock=BluetoothSocket(RFCOMM)
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)
port=server_sock.getsockname()[1]
uuid="94f39d29-7d6d-437d-973b-fba39e49d4ee"
advertise_service(server_sock,"BagPiServer",service_id=uuid,service_classes=[uuid,SERIAL_PORT_CLASS],profiles=[SERIAL_PORT_PROFILE])
while True:
if(connection==False):
print("Waiting for connection on RFCOMM channel %d" %port)
client_sock,client_info=server_sock.accept()
connection=True
print("The Bag accepted connection from ",client_info)
GPIO.output(24,1)
try:
data=client_sock.recv(1024)
if(data=="disconnect"):
print("Client wanted to disconnect")
client_sock.close()
connection=False
elif(data=="connect"):
msg="nothing"
time.sleep(5)
if((not prev_input) and input1):
msg="B"
image=camera.capture(stream,'a1.jpeg')
try:
myfile=open(image,'rb')
bytes=myfile.read()
client_sock.sendall(bytes)
finally:
connectiom.close()
else:
msg="F"
client_sock.send(msg)
time.sleep(5)
client_sock.close()
except IOError:
print("Connection disconnected")
GPIO.output(24,0)
client_sock.close()
connection=False
pass
except BluetoothError:
print("something want error with bluetooth")
except KeyboardInterrupt:
print("\nDisconnected")
client_sock.close()
server_sock.close()
break