add img format exports
This commit is contained in:
parent
d063fc3804
commit
8efd2767d7
28
src/seek.py
28
src/seek.py
@ -32,15 +32,14 @@ import base64
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
from ukdi import UKDI
|
||||
|
||||
import time
|
||||
|
||||
class Seek(UKDI):
|
||||
class Seek():
|
||||
|
||||
# get this from lsusb -vd VEND:PROD
|
||||
CAM = None
|
||||
campath = "/home/disp/cam_seek/bin/seek"
|
||||
seekbin = "/home/disp/yoloserv/modules/seek/bin/seek"
|
||||
X = 1902
|
||||
Y = 1080
|
||||
min = 0.0
|
||||
@ -53,7 +52,6 @@ class Seek(UKDI):
|
||||
def describe(self):
|
||||
return "UKDI Seek camera read"
|
||||
|
||||
|
||||
def open(self):
|
||||
# does nothing
|
||||
return
|
||||
@ -64,7 +62,7 @@ class Seek(UKDI):
|
||||
|
||||
# Red the image from a camera as numpy-ready CSV buffer.
|
||||
def hid_read(self):
|
||||
result = subprocess.run([self.campath], stdout=subprocess.PIPE)
|
||||
result = subprocess.run([self.seekbin], stdout=subprocess.PIPE)
|
||||
rows = result.stdout.split(b'\n')
|
||||
print(rows[0],rows[1],rows[3],rows[4])
|
||||
self.X = int(rows[0].decode("utf-8"))
|
||||
@ -78,22 +76,30 @@ class Seek(UKDI):
|
||||
return True
|
||||
|
||||
# return a PNG version of the pic in memory
|
||||
def png(self):
|
||||
def png64(self):
|
||||
_ , im_arr = cv2.imencode('.png', self.data)
|
||||
img_as_txt = base64.b64encode(im_arr)
|
||||
return b'data:image/png;base64, '+img_as_txt
|
||||
return 'data:image/png;base64, '+img_as_txt.decode()
|
||||
|
||||
# return a JPG version of the pic in memory
|
||||
def jpg(self):
|
||||
def jpg64(self):
|
||||
_ , im_arr = cv2.imencode('.jpg', self.data)
|
||||
img_as_txt = base64.b64encode(im_arr)
|
||||
return b'data:image/jpeg;base64,'+img_as_txt
|
||||
return 'data:image/jpeg;base64,'+img_as_txt.decode()
|
||||
|
||||
# return a BMP version of the pic in memory
|
||||
def bmp(self):
|
||||
def bmp64(self):
|
||||
_ , im_arr = cv2.imencode('.bmp', self.data)
|
||||
img_as_txt = base64.b64encode(im_arr)
|
||||
return b'data:image/bmp;base64,'+img_as_txt
|
||||
return 'data:image/bmp;base64,'+img_as_txt.decode()
|
||||
|
||||
|
||||
def img(self,type):
|
||||
_ , im_arr = cv2.imencode(type, self.data)
|
||||
return im_arr
|
||||
|
||||
def numpy(self):
|
||||
return self.data
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user