comment here
This commit is contained in:
@@ -30,7 +30,6 @@ vecToDict(vec::Vector{UInt8}) = copy(JSON3.read(String(vec)))
|
||||
cv = pyimport("cv2")
|
||||
base64 = pyimport("pybase64")
|
||||
np = pyimport("numpy")
|
||||
jsons = pyimport("jsons")
|
||||
|
||||
using imageUtils
|
||||
|
||||
@@ -43,18 +42,16 @@ vecToDict(vec::Vector{UInt8}) = copy(JSON3.read(String(vec)))
|
||||
# frame_1 = cv.imread("20.jpg")
|
||||
|
||||
_, buffer = cv.imencode(".jpg", frame_1)
|
||||
jpg_as_text = base64.b64encode(buffer).decode("utf-8")
|
||||
juliaDict = Dict("img"=> jpg_as_text)
|
||||
pythonDict = pydict(juliaDict)
|
||||
jsonStr = jsons.dumps(pythonDict)
|
||||
# mqtt publish jsonStr
|
||||
jpg_as_pyStr = base64.b64encode(buffer).decode("utf-8")
|
||||
jpg_as_juliaStr = pyconvert(String, jpg_as_pyStr)
|
||||
juliaDict = Dict("img"=> jpg_as_juliaStr)
|
||||
publish(mqttClient, "sometopic", JSON3.write(juliaDict)) # mqtt publish
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# server - receive image #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# mqtt receive jsonStr
|
||||
pythonDict = jsons.loads(jsonStr)
|
||||
juliaDict = pyconvert(Dict, pythonDict)
|
||||
img_str = payload["img"] # payload received thru mqtt
|
||||
buf = base64.b64decode(juliaDict["img"])
|
||||
buffer = np.frombuffer(buf, dtype=np.uint8)
|
||||
frame_1 = cv.imdecode(buffer, 1)
|
||||
@@ -69,7 +66,6 @@ vecToDict(vec::Vector{UInt8}) = copy(JSON3.read(String(vec)))
|
||||
frame_2 = np.array(img_bgr) # julia's PythonCall python-obj numpy array
|
||||
"""
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# mqtt #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
Reference in New Issue
Block a user