相关疑难解决方法(0)

无法读取从 Python 发送的 Node.js 中的 Base64 编码图像

我正在尝试实现 Node.js 和 Python 之间的通信。对于此任务,我使用 Node.js 的 python-shell NPM 模块来运行 Python 脚本并读取打印输出。我想在 Python 上做一些 OpenCV 图像处理的东西,将图像发送到 Node.js 并在应用程序上提供它。

这是 Node.js 部分:

let {PythonShell} = require('python-shell')

let options = {
  mode: 'text',
  pythonOptions: ['-u'], // get print results in real-time
  args: ['value1', 'value2', 'value3']
};

PythonShell.run('engine.py', options, function (err, results) {
  if (err) throw err;
  // results is an array consisting of messages collected during execution
/*   var fs = require("fs");

  fs.writeFile("arghhhh.jpeg", Buffer.from(results, "base64"), function(err) {}); */
  console.log(results.toString())
});
Run Code Online (Sandbox Code Playgroud)

这是Python部分:

from …
Run Code Online (Sandbox Code Playgroud)

python base64 buffer opencv node.js

4
推荐指数
1
解决办法
811
查看次数

标签 统计

base64 ×1

buffer ×1

node.js ×1

opencv ×1

python ×1