如何结合Python 32位和64位模块

时间:2018-04-28 12:11:09

标签: python tensorflow robotics nao-robot

对于我的一个机器人项目,我试图从Nao Robot的相机中获取图像并使用Tensorflow进行物体识别。

问题在于Robot的NaoQi API是基于Python2.7 32bit构建的。 (http://doc.aldebaran.com/1-14/dev/python/install_guide.html

Tensorflow对象识别API仅适用于64位。 (https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.mdhttps://www.tensorflow.org/install/install_windows

我正在使用Windows 10,我安装了Python 2.7 32位和3.6 64位,我可以独立运行模块,但我无法在两者之间传递图像。

是否有解决此问题的解决方法?谢谢。

1 个答案:

答案 0 :(得分:2)

如果您说一个模块仅为32位而另一个仅为64位,我认为没有办法让两个模块在同一个解释器中工作。

因此,考虑运行两个解释器,让它们通过消息交换,远程过程调用等相互通信。

我强烈反对使用共享内存部分,UNIX或TCP套接字,因为有太多的低级别细节需要处理,这会分散您对工作真正目标的注意力。

相反,请考虑一些高级库,例如zeromq,它也有python bindings并且使用起来很简单:你可以沿着线路发送二进制数据,字符串或python对象,这将使用pickle自动序列化和反序列化。

有用的读物​​:

客户端示例:

import zmq

context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")

print("Sending request...")
socket.send_string("Hello")
#  Get the reply.
message = socket.recv_string()
print(f"Received reply: {message}")

示例服务器:

import zmq

context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")

while True:
    message = socket.recv_string()
    print(f"Received request: {message}")
    socket.send_string("Hello")

socket.send_string()类似,您有socket.send_json()socket.send_pyobj()

检查the documentation