From e4c4752cf53c83fae1eb41cc42db7a22e3830a00 Mon Sep 17 00:00:00 2001 From: narawat Date: Thu, 16 Mar 2023 15:35:38 +0700 Subject: [PATCH] comment here --- src/interface.jl | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index d8f63ba..16ee00b 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -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 # # ---------------------------------------------------------------------------- #