0

I'm making a face recognition app that uses local camera to capture the face and encodes it into a 128-d numpy array via chaquopy. What I want to make is to send that numpy array over network to a server. The problem is I dont know how to send a numpy array via network or a chaquopy-PyObject efficiently. Please give me advices

I can convert the numpy array into a json file or a string but this time it'll take really long time to execute. Speed is really important so the solution should be the closest to the most efficient way.

1
  • Please provide enough code so others can better understand or reproduce the problem. Commented Nov 12, 2022 at 13:09

1 Answer 1

0

You could convert the array directly to bytes using tobytes, or at a slightly higher level using save. See this question for further discussion.

Sign up to request clarification or add additional context in comments.

5 Comments

For example, if I were to return that numpy array from python would I still be able to send it over network from java as pyobject? Speed is really important so least amount of conversion would suit me more
If you want to handle the network connection on the Java side, then the most efficient solution would be to convert the numpy array to bytes in Python, return the bytes object to Java, and convert it using toJava(byte[].class).
Do you think creating TCP conncetion in java and passing ip adress and port to the python and sending data from there would be more efficient ?
It probably wouldn't make any difference: passing byte arrays between Python and Java is very efficient. So I recommend you first implement your app in the simplest possible way, and then if it's too slow, do some timing tests to work out exactly where the problem is.
Thanks, I'll definitely try that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.