comment here

This commit is contained in:
2023-03-16 15:35:38 +07:00
parent 44676ec29c
commit e4c4752cf5

View File

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