简体   繁体   中英

How to combine Python 32bit and 64bit modules

For one my Robotics projects, I am trying to grab an image from Nao Robot's camera and use Tensorflow for object recognition.

The problem is that the Robot's NaoQi API is built on Python2.7 32bit. ( http://doc.aldebaran.com/1-14/dev/python/install_guide.html )

The Tensorflow Object recognition API works only with 64bit. ( https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md and https://www.tensorflow.org/install/install_windows )

I am using Windows 10 and I have both Python 2.7 32 bit and 3.6 64bit installed and I am able to run the modules independently but I am unable to pass the image between the two.

Are there any workarounds to address this issue? Thank you.

I don't think there is a way to have both modules work in the same interpreter if you say one is 32bit only and the other 64bit only.

So, consider running two interpreters, and having them communicate with each other with message exchange, remote procedure call, and such.

I strongly discourage to use shared memory sections, UNIX or TCP sockets, as there are too many low level details to handle that would distract you from the real objective of your work.

Instead, consider some high level library such as zeromq which has also python bindings and it's very simple to use: you can send binary data, strings or python objects along the wire, which would be automatically serialized and deserialized using pickle.

Useful readings:

Example client:

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}")

Example server:

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")

Similarly to socket.send_string() , you have socket.send_json() , and socket.send_pyobj() .

Check the documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM